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

@@ -5,6 +5,7 @@ import (
"sync"
"time"
"github.com/micro/go-micro/v2/auth"
"github.com/micro/go-micro/v2/broker"
"github.com/micro/go-micro/v2/codec"
"github.com/micro/go-micro/v2/debug/trace"
@@ -17,6 +18,7 @@ type Options struct {
Broker broker.Broker
Registry registry.Registry
Tracer trace.Tracer
Auth auth.Auth
Transport transport.Transport
Metadata map[string]string
Name string
@@ -161,6 +163,13 @@ func Tracer(t trace.Tracer) Option {
}
}
// Auth mechanism for role based access control
func Auth(a auth.Auth) Option {
return func(o *Options) {
o.Auth = a
}
}
// Transport mechanism for communication e.g http, rabbitmq, etc
func Transport(t transport.Transport) Option {
return func(o *Options) {