github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/net/smtp/auth.go (about)

     1  // Copyright 2010 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package smtp
     6  
     7  // AuthはSMTP認証メカニズムによって実装されます。
     8  type Auth interface {
     9  	Start(server *ServerInfo) (proto string, toServer []byte, err error)
    10  
    11  	Next(fromServer []byte, more bool) (toServer []byte, err error)
    12  }
    13  
    14  // ServerInfoはSMTPサーバーの情報を記録します。
    15  type ServerInfo struct {
    16  	Name string
    17  	TLS  bool
    18  	Auth []string
    19  }
    20  
    21  // PlainAuthは、RFC 4616で定義されているPLAIN認証メカニズムを実装する [Auth] を返します。返されたAuthは、指定したユーザー名とパスワードを使用してホストに認証し、アイデンティティとして動作します。通常、アイデンティティは空の文字列であるべきです。これにより、ユーザー名として機能します。
    22  // PlainAuthは、接続がTLSを使用しているか、またはlocalhostに接続されている場合にのみ認証情報を送信します。それ以外の場合は、認証に失敗し、認証情報は送信されません。
    23  func PlainAuth(identity, username, password, host string) Auth
    24  
    25  // CRAMMD5AuthはRFC 2195で定義されたCRAM-MD5認証メカニズムを実装する [Auth] を返します。
    26  // 返されたAuthは、ユーザー名と秘密情報を使用して、チャレンジ-レスポンスメカニズムを使ってサーバーに認証します。
    27  func CRAMMD5Auth(username, secret string) Auth