Documentation ¶
Overview ¶
Package to request and verify jwt token
Index ¶
Constants ¶
View Source
const ( // Name of header where jwt token is stored AuthorizationHeaderName = "Authorization" // Name of header where refresh token is stored RefreshTokenHeaderName = "refresh_token" // Key to set claim in context ClaimName = "claim" // Environment variable to point to url for the auth service EnvAuthUrl = "AUTHI_URL" // Url of root path for authi AuthiRootPath = "/user" //Path to login api AuthiLoginPath = "/login" //Path to refresh api AuthiRefreshPath = "/refresh" //Content type for AuthenticateDTO ContentTyp = "application/json; charset=utf-8" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AdapterMock ¶ added in v0.3.0
type AdapterMock struct { RefreshTokenRecordArray []*RefreshTokenRecord RefreshTokenResponseArray []*TokenResponse GetTokenRecordArray []*GetTokenRecord GetTokenResponseArray []*TokenResponse }
func (*AdapterMock) GetToken ¶ added in v0.3.0
func (mock *AdapterMock) GetToken(userId string, password string) (*TokenResponseDTO, error)
func (*AdapterMock) RefreshToken ¶ added in v0.3.0
func (mock *AdapterMock) RefreshToken(userId string, token string, refreshToken string) (*TokenResponseDTO, error)
type AuthAdapter ¶
type AuthAdapter interface { RefreshToken(userId string, token string, refreshToken string) (*TokenResponseDTO, error) GetToken(userId string, password string) (*TokenResponseDTO, error) }
Interface for authentication
func NewAuthiAdapter ¶
func NewAuthiAdapter(correlationId string) AuthAdapter
Initialize auth adapter with public key and url to authi service. Therefor the environment variable AUTH_URL have to be set
type AuthenticateDTO ¶
type AuthenticateDTO struct {
Password string `json:"password" validate:"required"`
}
Request object for authentication
type AuthiAdapter ¶
type AuthiAdapter struct {
// contains filtered or unexported fields
}
Implementation of auth adapter to login and refresh token of user
func (*AuthiAdapter) GetToken ¶
func (authAdapter *AuthiAdapter) GetToken(userId string, password string) (*TokenResponseDTO, error)
Login to get token
func (*AuthiAdapter) RefreshToken ¶
func (authAdapter *AuthiAdapter) RefreshToken(userId string, token string, refreshToken string) (*TokenResponseDTO, error)
Get new token with refresh token from authi service
type Claims ¶
type Claims struct { UserId uuid.UUID `json:"user_id"` jwt.StandardClaims }
Claim with data from the token
type GetTokenRecord ¶ added in v0.3.0
type RefreshTokenRecord ¶ added in v0.3.0
type TokenResponse ¶ added in v0.3.0
type TokenResponse struct { TokenResponseDTO *TokenResponseDTO Err error }
Click to show internal directories.
Click to hide internal directories.