2021-11-09 06:11:01 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2021-11-09 23:03:32 +00:00
|
|
|
// SimpleScoper is a simple Scoper
|
|
|
|
type SimpleScoper struct {
|
2021-11-09 06:11:01 +00:00
|
|
|
Key string
|
|
|
|
}
|
|
|
|
|
|
|
|
// Scope fulfills Scoper
|
2021-11-09 23:03:32 +00:00
|
|
|
func (s SimpleScoper) Scope(scope Scope) string {
|
2021-11-09 06:11:01 +00:00
|
|
|
switch scope {
|
|
|
|
case Identification:
|
|
|
|
return s.Key + ".login"
|
|
|
|
case Recovery:
|
|
|
|
return s.Key + ".answer"
|
|
|
|
case Authentication:
|
|
|
|
fallthrough
|
|
|
|
default:
|
|
|
|
return s.Key
|
|
|
|
}
|
|
|
|
}
|
2021-11-09 23:03:32 +00:00
|
|
|
|
|
|
|
// DefaultScoper is the default Scoper
|
|
|
|
var DefaultScoper = SimpleScoper{
|
|
|
|
Key: "com.lyndir.masterpassword",
|
|
|
|
}
|