authn

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package authn is used to identify requesters

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	AuthURL     string
	TokenURL    string
	JWKSURL     string
	ID          string
	Secret      string
	CallbackURL string

	// Set to true if you store the tokens in your database for connections to OTHER services.
	// This will skip fetching the public keys from the JWKSURL, speeding up the authentication process.
	// Do NOT set to true if the tokens are provided by the client in order to access YOUR service.
	SkipSignatureValidation bool
	// contains filtered or unexported fields
}

func (*Client) Authenticate

func (c *Client) Authenticate(tokens *Tokens, now time.Time) (bool, error)

Authenticate refreshes the user's access token if its invalid/expired and returns true if it was refreshed.

func (*Client) AuthorizeURL

func (c *Client) AuthorizeURL(state string) string

func (*Client) ExchangeCode

func (c *Client) ExchangeCode(code string) (*Tokens, error)

ExchangeCode exchanges an authorization code for access and refresh tokens

func (*Client) Refresh

func (c *Client) Refresh(tokens *Tokens) error

func (*Client) SyncPublicKeys

func (c *Client) SyncPublicKeys(now time.Time)

SyncPublicKeys syncs the keys if one/more is missing.

func (*Client) ValidateToken

func (c *Client) ValidateToken(token string, now time.Time) error

ValidateToken validates the token and returns an error if it is invalid.

type Tokens

type Tokens struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
}

Jump to

Keyboard shortcuts

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