Implement the Auth interface, with JWT and service implementations.

* Update Auth Interface

* Define Auth Service Implementation

* Support Service Auth

* Add Auth Service Proto

* Remove erronious files

* Implement Auth Service Package

* Update Auth Interface

* Update Auth Interface. Add Validate, remove Add/Remove roles

* Make Revoke interface more explicit

* Refactor serializing and deserializing service accounts

* Fix srv name & update interface to be more explicit

* Require jwt public key for auth

* Rename Variables (Resource.ID => Resource.Name & ServiceAccount => Account)

* Implement JWT Auth Package

* Remove parent, add ID

* Update auth imports to v2. Add String() to auth interface
This commit is contained in:
ben-toogood
2020-02-03 08:16:02 +00:00
committed by GitHub
parent 449bcb46fe
commit d621548120
16 changed files with 1103 additions and 26 deletions

View File

@@ -68,19 +68,26 @@ func (m *memoryStore) Read(key string, opts ...store.ReadOption) ([]*store.Recor
var vals []*memoryRecord
if !options.Prefix {
v, ok := m.values[key]
if !ok {
return nil, store.ErrNotFound
}
vals = []*memoryRecord{v}
} else {
if options.Prefix {
for _, v := range m.values {
if !strings.HasPrefix(v.r.Key, key) {
continue
}
vals = append(vals, v)
}
} else if options.Suffix {
for _, v := range m.values {
if !strings.HasSuffix(v.r.Key, key) {
continue
}
vals = append(vals, v)
}
} else {
v, ok := m.values[key]
if !ok {
return nil, store.ErrNotFound
}
vals = []*memoryRecord{v}
}
//nolint:prealloc

View File

@@ -11,6 +11,8 @@ type Options struct {
Namespace string
// Prefix of the keys used
Prefix string
// Suffix of the keys used
Suffix string
// Alternative options
Context context.Context
}
@@ -45,3 +47,10 @@ func ReadPrefix() ReadOption {
o.Prefix = true
}
}
// ReadSuffix uses the key as a suffix
func ReadSuffix() ReadOption {
return func(o *ReadOptions) {
o.Suffix = true
}
}

View File

@@ -39,6 +39,8 @@ type Record struct {
type ReadOptions struct {
// Read key as a prefix
Prefix bool
// Read key as a suffix
Suffix bool
}
type ReadOption func(o *ReadOptions)