add MICRO_AUTH_TOKEN, parse token in wrapper, preload config and othe… (#1261)

* add MICRO_AUTH_TOKEN, parse token in wrapper, preload config and other things

* fix wrapper panic
This commit is contained in:
Asim Aslam
2020-02-25 22:15:44 +00:00
committed by GitHub
parent 603d37b135
commit 6aaaf54275
14 changed files with 243 additions and 177 deletions

View File

@@ -6,31 +6,42 @@ var (
// NewAuth returns a new default registry which is noop
func NewAuth(opts ...Option) Auth {
return noop{}
var options Options
for _, o := range opts {
o(&options)
}
return &noop{
opts: options,
}
}
type noop struct{}
type noop struct {
opts Options
}
func (noop) Init(opts ...Option) error {
func (n *noop) Init(opts ...Option) error {
for _, o := range opts {
o(&n.opts)
}
return nil
}
func (noop) Options() Options {
return Options{}
func (n *noop) Options() Options {
return n.opts
}
func (noop) Generate(id string, opts ...GenerateOption) (*Account, error) {
func (n *noop) Generate(id string, opts ...GenerateOption) (*Account, error) {
return nil, nil
}
func (noop) Revoke(token string) error {
func (n *noop) Revoke(token string) error {
return nil
}
func (noop) Validate(token string) (*Account, error) {
func (n *noop) Verify(token string) (*Account, error) {
return nil, nil
}
func (noop) String() string {
func (n *noop) String() string {
return "noop"
}