Refactor auth: add token and store implementations (#1230)
* Refactor auth: add token and memory implementations * Fix typo * Remove memory auth (implemented already by the store implementation), revert default to noop * Add grpc header * Global Config * config/global => util/config * Rename package to remove confict * Tweak * Improve Error Handling
This commit is contained in:
		| @@ -1,39 +1,36 @@ | ||||
| package auth | ||||
|  | ||||
| var ( | ||||
| 	DefaultAuth Auth = new(noop) | ||||
| 	DefaultAuth = NewAuth() | ||||
| ) | ||||
|  | ||||
| type noop struct { | ||||
| 	options Options | ||||
| // NewAuth returns a new default registry which is noop | ||||
| func NewAuth(opts ...Option) Auth { | ||||
| 	return noop{} | ||||
| } | ||||
|  | ||||
| // String name of implementation | ||||
| func (a *noop) String() string { | ||||
| type noop struct{} | ||||
|  | ||||
| func (noop) Init(opts ...Option) error { | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (noop) Options() Options { | ||||
| 	return Options{} | ||||
| } | ||||
|  | ||||
| func (noop) Generate(id string, opts ...GenerateOption) (*Account, error) { | ||||
| 	return nil, nil | ||||
| } | ||||
|  | ||||
| func (noop) Revoke(token string) error { | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (noop) Validate(token string) (*Account, error) { | ||||
| 	return nil, nil | ||||
| } | ||||
|  | ||||
| func (noop) String() string { | ||||
| 	return "noop" | ||||
| } | ||||
|  | ||||
| // Init the svc | ||||
| func (a *noop) Init(...Option) error { | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // Options set in init | ||||
| func (a *noop) Options() Options { | ||||
| 	return a.options | ||||
| } | ||||
|  | ||||
| // Generate a new auth Account | ||||
| func (a *noop) Generate(id string, ops ...GenerateOption) (*Account, error) { | ||||
| 	return nil, nil | ||||
| } | ||||
|  | ||||
| // Revoke an authorization Account | ||||
| func (a *noop) Revoke(token string) error { | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // Validate a  account token | ||||
| func (a *noop) Validate(token string) (*Account, error) { | ||||
| 	return nil, nil | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user