35 lines
610 B
Go
35 lines
610 B
Go
|
package spectre
|
||
|
|
||
|
// Scope is a key scope
|
||
|
type Scope string
|
||
|
|
||
|
const (
|
||
|
Authentication Scope = "Authentication"
|
||
|
Identification Scope = "Identification"
|
||
|
Recovery Scope = "Recovery"
|
||
|
)
|
||
|
|
||
|
// Scoper returns one of the three available scopes
|
||
|
type Scoper interface {
|
||
|
Scope(Scope) string
|
||
|
}
|
||
|
|
||
|
// SimpleScope is a simple Scoper
|
||
|
type SimpleScope struct {
|
||
|
Key string
|
||
|
}
|
||
|
|
||
|
// Scope fulfills Scoper
|
||
|
func (s SimpleScope) Scope(scope Scope) string {
|
||
|
switch scope {
|
||
|
case Identification:
|
||
|
return s.Key + ".login"
|
||
|
case Recovery:
|
||
|
return s.Key + ".answer"
|
||
|
case Authentication:
|
||
|
fallthrough
|
||
|
default:
|
||
|
return s.Key
|
||
|
}
|
||
|
}
|