Slide 18
Slide 18 text
3.1 認証バックエンドを Go で実装!
18
● 認証メソッドやパスワード認証
var ok bool
switch req.Method {
case "login", "plain":
ok = (account.Secret == req.Pass)
case "cram-md5":
expected := CramGetExpected(crypto.MD5, []byte(account.Secret), []byte(req.Salt))
ok = (expected == req.Pass)
default:
return ErrNotPermittedMethod
}
if !ok {
return ErrPasswordIncorrect
}