go-spectre/scope.go

40 lines
724 B
Go
Raw Normal View History

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
}
// SimpleScoper is a simple Scoper
type SimpleScoper struct {
Key string
}
// Scope fulfills Scoper
func (s SimpleScoper) 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
}
}
// DefaultScoper is the default Scoper
var DefaultScoper = SimpleScoper{
Key: "com.lyndir.masterpassword",
}