client

package
v0.0.0-...-20ebf41 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Claims

type Claims struct {
	Name  string `json:"name,omitempty"`
	Level string `json:"level"`
	jwt.RegisteredClaims
}

Claims is a struct representing the claims returned by the authentication service.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a struct representing the authentication service client.

func NewClient

func NewClient(baseURL string, timeout time.Duration, logger *log.Logger) *Client

NewClient creates a new instance of the authentication service client.

func (*Client) GenerateAnonymousTokens

func (c *Client) GenerateAnonymousTokens(ctx context.Context) (*Tokens, error)

GenerateAnonymousTokens generates anonymous tokens from the authentication service.

func (*Client) Middleware

func (c *Client) Middleware(next http.Handler) http.Handler

Middleware handles authentication / authorization for a request.

func (*Client) Refresh

func (c *Client) Refresh(ctx context.Context, payload RefreshPayload) (*Tokens, error)

Refresh refreshes the access token using the refresh token.

func (*Client) ValidateAccessToken

func (c *Client) ValidateAccessToken(ctx context.Context, payload ValidationPayload) (*Claims, error)

ValidateAccessToken validates the access token.

type RefreshPayload

type RefreshPayload struct {
	RefreshToken string `json:"refreshToken"`
}

RefreshPayload is a struct representing the payload for the refresh token request.

type Tokens

type Tokens struct {
	RefreshToken           string `json:"refreshToken,omitempty"`
	AccessToken            string `json:"accessToken"`
	AccessTokenExpiration  int64  `json:"accessTokenExpiration"`
	RefreshTokenExpiration int64  `json:"refreshTokenExpiration,omitempty"`
}

Tokens is a struct representing the tokens returned by the authentication service.

type ValidationPayload

type ValidationPayload struct {
	AccessToken string `json:"accessToken"`
}

ValidationPayload is a struct representing the payload for the access token validation request.

Jump to

Keyboard shortcuts

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