mirror of
https://github.com/jech/galene.git
synced 2024-11-14 04:35:57 +01:00
a6314a7384
Stateful tokens look just like cryptographic tokens to the client. Unlike cryptographic tokens, they are stored in a file and are revokable and editable.
19 lines
376 B
Go
19 lines
376 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) {
|
|
t, err := getStateful(token)
|
|
if err == nil && t != nil {
|
|
return t, nil
|
|
}
|
|
return parseJWT(token, keys)
|
|
}
|