Auth (#1147)
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:
		| @@ -3,6 +3,7 @@ package cmd | ||||
| import ( | ||||
| 	"context" | ||||
|  | ||||
| 	"github.com/micro/go-micro/v2/auth" | ||||
| 	"github.com/micro/go-micro/v2/broker" | ||||
| 	"github.com/micro/go-micro/v2/client" | ||||
| 	"github.com/micro/go-micro/v2/client/selector" | ||||
| @@ -30,6 +31,7 @@ type Options struct { | ||||
| 	Runtime   *runtime.Runtime | ||||
| 	Store     *store.Store | ||||
| 	Tracer    *trace.Tracer | ||||
| 	Auth      *auth.Auth | ||||
|  | ||||
| 	Brokers    map[string]func(...broker.Option) broker.Broker | ||||
| 	Clients    map[string]func(...client.Option) client.Client | ||||
| @@ -40,6 +42,7 @@ type Options struct { | ||||
| 	Runtimes   map[string]func(...runtime.Option) runtime.Runtime | ||||
| 	Stores     map[string]func(...store.Option) store.Store | ||||
| 	Tracers    map[string]func(...trace.Option) trace.Tracer | ||||
| 	Auths      map[string]func(...auth.Option) auth.Auth | ||||
|  | ||||
| 	// Other options for implementations of the interface | ||||
| 	// can be stored in a context | ||||
| @@ -109,6 +112,12 @@ func Tracer(t *trace.Tracer) Option { | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func Auth(a *auth.Auth) Option { | ||||
| 	return func(o *Options) { | ||||
| 		o.Auth = a | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // New broker func | ||||
| func NewBroker(name string, b func(...broker.Option) broker.Broker) Option { | ||||
| 	return func(o *Options) { | ||||
| @@ -164,3 +173,10 @@ func NewTracer(name string, t func(...trace.Option) trace.Tracer) Option { | ||||
| 		o.Tracers[name] = t | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // New auth func | ||||
| func NewAuth(name string, t func(...auth.Option) auth.Auth) Option { | ||||
| 	return func(o *Options) { | ||||
| 		o.Auths[name] = t | ||||
| 	} | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user