1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-11-23 00:55:58 +01:00
galene/token/token.go

28 lines
583 B
Go
Raw Normal View History

2021-10-29 23:37:05 +02:00
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
2021-10-29 23:37:05 +02:00
}