Documentation ¶
Index ¶
- type AuthService
- func (a *AuthService) CheckForRefresh() (bool, error)
- func (a *AuthService) GetServiceID() string
- func (a *AuthService) GetServiceReg(serviceID string) (*ServiceReg, error)
- func (a *AuthService) GetServiceRegWithPubKey(serviceID string) (*ServiceReg, error)
- func (a *AuthService) LoadServices() error
- func (a *AuthService) SetMaxRefreshCacheFreq(freq int)
- func (a *AuthService) SetMinRefreshCacheFreq(freq int)
- func (a *AuthService) SubscribeServices(serviceIDs []string, reload bool) error
- func (a *AuthService) UnsubscribeServices(serviceIDs []string)
- func (a *AuthService) ValidateServiceRegistration(serviceHost string) error
- func (a *AuthService) ValidateServiceRegistrationKey(privKey *rsa.PrivateKey) error
- type PubKey
- type RemoteServiceRegLoaderImpl
- type ServiceReg
- type ServiceRegLoader
- type ServiceRegSubscriptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthService ¶
type AuthService struct {
// contains filtered or unexported fields
}
AuthService contains the configurations to interface with the auth service
func NewAuthService ¶
func NewAuthService(serviceID string, serviceHost string, serviceLoader ServiceRegLoader) (*AuthService, error)
NewAuthService creates and configures a new AuthService instance
func NewTestAuthService ¶
func NewTestAuthService(serviceID string, serviceHost string, serviceLoader ServiceRegLoader) (*AuthService, error)
NewTestAuthService creates and configures a new AuthService instance for testing purposes
func (*AuthService) CheckForRefresh ¶ added in v0.1.11
func (a *AuthService) CheckForRefresh() (bool, error)
func (*AuthService) GetServiceID ¶
func (a *AuthService) GetServiceID() string
GetServiceID returns the ID of the implementing service
func (*AuthService) GetServiceReg ¶
func (a *AuthService) GetServiceReg(serviceID string) (*ServiceReg, error)
GetServiceReg returns the service registration record for the given ID if found
func (*AuthService) GetServiceRegWithPubKey ¶ added in v0.1.20
func (a *AuthService) GetServiceRegWithPubKey(serviceID string) (*ServiceReg, error)
GetServiceReg returns the service registration record for the given ID if found and validates the PubKey
func (*AuthService) LoadServices ¶
func (a *AuthService) LoadServices() error
LoadServices loads the subscribed service registration records and caches them
This function will be called periodically after refreshCacheFreq, but can be called directly to force a cache refresh
func (*AuthService) SetMaxRefreshCacheFreq ¶ added in v0.1.11
func (a *AuthService) SetMaxRefreshCacheFreq(freq int)
SetMaxRefreshCacheFreq sets the minimum frequency at which cached service registration records are refreshed in minutes
The default value is 60
func (*AuthService) SetMinRefreshCacheFreq ¶ added in v0.1.11
func (a *AuthService) SetMinRefreshCacheFreq(freq int)
SetMinRefreshCacheFreq sets the minimum frequency at which cached service registration records are refreshed in minutes
The default value is 1
func (*AuthService) SubscribeServices ¶
func (a *AuthService) SubscribeServices(serviceIDs []string, reload bool) error
SubscribeServices subscribes to the provided services
If reload is true and one of the services is not already subscribed, the service registrations will be reloaded immediately
func (*AuthService) UnsubscribeServices ¶
func (a *AuthService) UnsubscribeServices(serviceIDs []string)
UnsubscribeServices unsubscribes from the provided service
func (*AuthService) ValidateServiceRegistration ¶
func (a *AuthService) ValidateServiceRegistration(serviceHost string) error
ValidateServiceRegistration validates that the implementing service has a valid registration for the provided service ID and hostname
func (*AuthService) ValidateServiceRegistrationKey ¶
func (a *AuthService) ValidateServiceRegistrationKey(privKey *rsa.PrivateKey) error
ValidateServiceRegistrationKey validates that the implementing service has a valid registration for the provided keypair
type PubKey ¶
type PubKey struct { Key *rsa.PublicKey `json:"-" bson:"-"` KeyPem string `json:"key_pem" bson:"key_pem" validate:"required"` Alg string `json:"alg" bson:"alg" validate:"required"` Kid string `json:"-" bson:"-"` }
PubKey represents a public key object including the key and related metadata
func (*PubKey) LoadKeyFromPem ¶
LoadKeyFromPem parses "KeyPem" and sets the "Key" and "Kid"
type RemoteServiceRegLoaderImpl ¶
type RemoteServiceRegLoaderImpl struct { *ServiceRegSubscriptions // contains filtered or unexported fields }
RemoteServiceRegLoaderImpl provides a ServiceRegLoader implemntation for a remote auth service
func NewRemoteServiceRegLoader ¶
func NewRemoteServiceRegLoader(authServicesUrl string, subscribedServices []string) *RemoteServiceRegLoaderImpl
NewRemoteServiceRegLoader creates and configures a new RemoteServiceRegLoaderImpl instance for the provided auth services url
func (*RemoteServiceRegLoaderImpl) LoadServices ¶
func (r *RemoteServiceRegLoaderImpl) LoadServices() ([]ServiceReg, error)
LoadServices implements ServiceRegLoader interface
type ServiceReg ¶
type ServiceReg struct { ServiceID string `json:"service_id" bson:"service_id" validate:"required"` Host string `json:"host" bson:"host" validate:"required"` PubKey *PubKey `json:"pub_key" bson:"pub_key"` }
ServiceReg represents a service registration record
type ServiceRegLoader ¶
type ServiceRegLoader interface { // LoadServices loads the service registration records for all subscribed services LoadServices() ([]ServiceReg, error) //GetSubscribedServices returns the list of currently subscribed services GetSubscribedServices() []string // SubscribeService subscribes the loader to the given service // Returns true if the specified service was added or false if it was already found SubscribeService(serviceID string) bool // UnsubscribeService unsubscribes the loader from the given service // Returns true if the specified service was removed or false if it was not found UnsubscribeService(serviceID string) bool }
ServiceRegLoader declares an interface to load the service registrations for specified services
type ServiceRegSubscriptions ¶
type ServiceRegSubscriptions struct {
// contains filtered or unexported fields
}
ServiceRegSubscriptions defined a struct to hold service registration subscriptions
This struct implements the subcription part of the ServiceRegLoader interface If you subscribe to the reserved "all" service ID, all registered services will be loaded
func NewServiceRegSubscriptions ¶
func NewServiceRegSubscriptions(subscribedServices []string) *ServiceRegSubscriptions
NewServiceRegSubscriptions creates and configures a new ServiceRegSubscriptions instance
func (*ServiceRegSubscriptions) GetSubscribedServices ¶
func (r *ServiceRegSubscriptions) GetSubscribedServices() []string
GetSubscribedServices returns the list of subscribed services
func (*ServiceRegSubscriptions) SubscribeService ¶
func (r *ServiceRegSubscriptions) SubscribeService(serviceID string) bool
SubscribeService adds the given service ID to the list of subscribed services if not already present
Returns true if the specified service was added or false if it was already found
func (*ServiceRegSubscriptions) UnsubscribeService ¶
func (r *ServiceRegSubscriptions) UnsubscribeService(serviceID string) bool
UnsubscribeService removed the given service ID from the list of subscribed services if presents
Returns true if the specified service was removed or false if it was not found