service

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 28, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecRequest

func ExecRequest(action string, req *http.Request, client *http.Client, ignoreCodes ...int) (*http.Response, error)

ExecRequest executes an HTTP request to a given service. The execution is wrapped in a hystrix command with the name set to the "action" argument.

func NewSignedRequest

func NewSignedRequest(method string, urlStr string, body io.Reader, signature Signature) (*http.Request, error)

NewSignedRequest creates an HTTP request that is signed with the given Signature. The request has its Authorization header populated with the generated JWT.

Types

type ClientServiceAPI

type ClientServiceAPI struct {

	// ServiceURL Clients (Apps) microservice URL.
	ServiceURL string

	// Client pointer to the HTTP client.
	*http.Client

	// Signature is the signature data for the self-issued JWT for access the dependency microservices.
	Signature

	// ClientAuthRepository is the ClientAuthRepository for accessing the locally persisted data.
	db.ClientAuthRepository
}

ClientServiceAPI holds the values for oauth2.ClientService implementation. This combines the access to a remote Clients (Apps) service and locally persisted ClientAuth repository.

func NewClientService

func NewClientService(serverConfig *config.ServerConfig, client *http.Client, keyStore tools.KeyStore) (*ClientServiceAPI, func(), error)

NewClientService creates new oauth2.ClientService.

func (*ClientServiceAPI) ConfirmClientAuth

func (c *ClientServiceAPI) ConfirmClientAuth(userID, clientID string) (*oauth2.ClientAuth, error)

ConfirmClientAuth confirms that the user has authorized the client. It updates the ClientAuth in the client auth repository.

func (*ClientServiceAPI) DeleteClientAuth

func (c *ClientServiceAPI) DeleteClientAuth(clientID, code string) error

DeleteClientAuth removes the clientAuth identified by client id and auth code.

func (*ClientServiceAPI) GetClient

func (c *ClientServiceAPI) GetClient(clientID string) (*oauth2.Client, error)

GetClient retrieves a client data from the clients (apps) microservice.

func (*ClientServiceAPI) GetClientAuth

func (c *ClientServiceAPI) GetClientAuth(clientID, code string) (*oauth2.ClientAuth, error)

GetClientAuth looks up a clientAuth for the specified client and auth code.

func (*ClientServiceAPI) GetClientAuthForUser

func (c *ClientServiceAPI) GetClientAuthForUser(userID, clientID string) (*oauth2.ClientAuth, error)

GetClientAuthForUser looks up a clientAuth for the specified client and user.

func (*ClientServiceAPI) SaveClientAuth

func (c *ClientServiceAPI) SaveClientAuth(clientAuth *oauth2.ClientAuth) error

SaveClientAuth stores the clientAuth in the client auth repository.

func (*ClientServiceAPI) UpdateUserData

func (c *ClientServiceAPI) UpdateUserData(clientID, code, userID, userData string) error

UpdateUserData updates the user data of the clientAuth identified by the client ID and auth code.

func (*ClientServiceAPI) VerifyClientCredentials

func (c *ClientServiceAPI) VerifyClientCredentials(clientID, clientSecret string) (*oauth2.Client, error)

VerifyClientCredentials verifies a client (app) for the supplied credentials on the clients (apps) microservice.

type OAuth2TokenService

type OAuth2TokenService struct {

	// TokenRepository is the db.TokenRepository for persisting the oauth2 tokens.
	db.TokenRepository
}

OAuth2TokenService hold the data for implementation of oauth2.TokenService.

func NewTokenService

func NewTokenService(serverConfig *config.ServerConfig) (*OAuth2TokenService, func(), error)

NewTokenService creates new oauth2.TokenService from a given ServerConfig.

func (*OAuth2TokenService) GetToken

func (t *OAuth2TokenService) GetToken(refreshToken string) (*oauth2.AuthToken, error)

GetToken retrieves a token from the underlying token repository. The token is checked if it is expired.

func (*OAuth2TokenService) GetTokenForClient

func (t *OAuth2TokenService) GetTokenForClient(userID, clientID string) (*oauth2.AuthToken, error)

GetTokenForClient retrieves a token for the client and user from the token repository. The token is checked if it is expired.

func (*OAuth2TokenService) SaveToken

func (t *OAuth2TokenService) SaveToken(token oauth2.AuthToken) error

SaveToken saves the token in the underlying token repositry.

type Signature

type Signature struct {

	// SigningMethod is the method used for signing the JWT. Valid values are "RS256", "RS384" and "RS512".
	SigningMethod string

	// Key is the private key used for signing the JWT.
	Key interface{}

	// Claims is the map of standard and custom defined claims for the JWT.
	Claims map[string]interface{}
}

Signature holds the data for signing the self-issued JWTs for accessing dependencies microservices.

func NewClientSignature

func NewClientSignature(serverName string, securityConf config.Security, keyStore tools.KeyStore) (*Signature, error)

NewClientSignature builds new Signature containing the data and claims for signing the JWT tokens.

func NewSystemSignature

func NewSystemSignature(serverName string, securityConf config.Security, keyStore tools.KeyStore) (*Signature, error)

NewSystemSignature generates a common Signature from a given configuration. This Signature is issued with system authentication and used for communication with other microservices on the platform.

func (*Signature) New

func (s *Signature) New() *Signature

New creates new up-to-date signature.

type UserServiceAPI

type UserServiceAPI struct {
	// ServiceURL is the URL of the user microservice.
	ServiceURL string

	// Client is the http.Client used for all requests.
	*http.Client

	// Signature is the Signature of this server used for signing the self-issued JWTs.
	Signature
}

UserServiceAPI holds the data for implementation of oauth2.UserService.

func NewUserService

func NewUserService(serverConfig *config.ServerConfig, client *http.Client, keyStore tools.KeyStore) (*UserServiceAPI, error)

NewUserService crates new UserServiceAPI from the ServerConfig.

func (*UserServiceAPI) VerifyUser

func (u *UserServiceAPI) VerifyUser(email, password string) (*oauth2.User, error)

VerifyUser makes a call to the user microservice to verify the user credentials.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL