2020-02-03 11:16:02 +03:00
|
|
|
package auth
|
|
|
|
|
|
|
|
var (
|
2020-02-24 18:07:27 +03:00
|
|
|
DefaultAuth = NewAuth()
|
2020-02-03 11:16:02 +03:00
|
|
|
)
|
|
|
|
|
2020-02-24 18:07:27 +03:00
|
|
|
// NewAuth returns a new default registry which is noop
|
|
|
|
func NewAuth(opts ...Option) Auth {
|
2020-02-26 01:15:44 +03:00
|
|
|
var options Options
|
|
|
|
for _, o := range opts {
|
|
|
|
o(&options)
|
|
|
|
}
|
|
|
|
return &noop{
|
|
|
|
opts: options,
|
|
|
|
}
|
2020-02-03 11:16:02 +03:00
|
|
|
}
|
|
|
|
|
2020-02-26 01:15:44 +03:00
|
|
|
type noop struct {
|
|
|
|
opts Options
|
|
|
|
}
|
2020-02-03 11:16:02 +03:00
|
|
|
|
2020-02-26 01:15:44 +03:00
|
|
|
func (n *noop) Init(opts ...Option) error {
|
|
|
|
for _, o := range opts {
|
|
|
|
o(&n.opts)
|
|
|
|
}
|
2020-02-03 11:16:02 +03:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-02-26 01:15:44 +03:00
|
|
|
func (n *noop) Options() Options {
|
|
|
|
return n.opts
|
2020-02-10 11:26:28 +03:00
|
|
|
}
|
|
|
|
|
2020-02-26 01:15:44 +03:00
|
|
|
func (n *noop) Generate(id string, opts ...GenerateOption) (*Account, error) {
|
2020-02-03 11:16:02 +03:00
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
2020-02-26 01:15:44 +03:00
|
|
|
func (n *noop) Revoke(token string) error {
|
2020-02-03 11:16:02 +03:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-02-26 01:15:44 +03:00
|
|
|
func (n *noop) Verify(token string) (*Account, error) {
|
2020-02-03 11:16:02 +03:00
|
|
|
return nil, nil
|
|
|
|
}
|
2020-02-24 18:07:27 +03:00
|
|
|
|
2020-02-26 01:15:44 +03:00
|
|
|
func (n *noop) String() string {
|
2020-02-24 18:07:27 +03:00
|
|
|
return "noop"
|
|
|
|
}
|