github.com/annwntech/go-micro/v2@v2.9.5/auth/provider/provider.go (about) 1 // Package provider is an external auth provider e.g oauth 2 package provider 3 4 import ( 5 "time" 6 ) 7 8 // Provider is an auth provider 9 type Provider interface { 10 // String returns the name of the provider 11 String() string 12 // Options returns the options of a provider 13 Options() Options 14 // Endpoint for the provider 15 Endpoint(...EndpointOption) string 16 // Redirect url incase of UI 17 Redirect() string 18 } 19 20 // Grant is a granted authorisation 21 type Grant struct { 22 // token for reuse 23 Token string 24 // Expiry of the token 25 Expiry time.Time 26 // Scopes associated with grant 27 Scopes []string 28 } 29 30 type EndpointOptions struct { 31 // State is a code to verify the req 32 State string 33 // LoginHint prefils the user id on oauth clients 34 LoginHint string 35 } 36 37 type EndpointOption func(*EndpointOptions) 38 39 func WithState(c string) EndpointOption { 40 return func(o *EndpointOptions) { 41 o.State = c 42 } 43 } 44 45 func WithLoginHint(hint string) EndpointOption { 46 return func(o *EndpointOptions) { 47 o.LoginHint = hint 48 } 49 }