1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-11-09 02:05:59 +01:00
galene/token/token.go
2024-05-01 22:39:48 +02:00

27 lines
583 B
Go

package token
import (
"errors"
)
var ErrUsernameRequired = errors.New("username required")
type Token interface {
Check(host, group string, username *string) (string, []string, error)
}
func Parse(token string, keys []map[string]interface{}) (Token, error) {
// both getStateful and parseJWT may return nil, which we
// shouldn't cast into an interface before testing for nil.
jwt, err := parseJWT(token, keys)
if err != nil {
// parses correctly but doesn't validate
return nil, err
}
if jwt != nil {
return jwt, nil
}
s, _, err := Get(token)
return s, err
}