Home

go-spectre @bbcba946f199110b13eb683687625e2a52d2b503 - refs - log -
-
https://git.jolheiser.com/go-spectre.git
Go implementation for spectre/masterpassword
go-spectre / scope.go
- raw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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",
}