client

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SaaSBaseURL is the base URL for the SaaS offering. The SaaS offering is optional and the magiclinksdev project
	// can be self-hosted.
	SaaSBaseURL = "https://magiclinks.dev"
	// SaaSIss is the iss claim for JWTs in the SaaS offering.
	SaaSIss = SaaSBaseURL
)

Variables

View Source
var (
	// ErrClientConfig indicates there is an error with the client configuration.
	ErrClientConfig = errors.New("client config invalid")
	// ErrNotReady indicates the magiclinksdev server deployment is not ready.
	ErrNotReady = errors.New("magiclinksdev server deployment is not ready")
)

Functions

This section is empty.

Types

type Client

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

Client is a client for the magiclinksdev project.

func New

func New(apiKey, aud uuid.UUID, baseURL, iss string, options Options) (Client, error)

New creates a new magiclinksdev client. The apiKey and aud are tied to the service account being used. The baseURL is the HTTP(S) location of the magiclinksdev deployment. Only use HTTPS in production. For the SaaS offering, use the SaaSBaseURL constant. The iss is the issuer of the JWTs, which is in the configuration of the magiclinksdev deployment. For the SaaS offering, use the SaaSIss constant. Providing an empty string for the iss will disable issuer validation.

func (Client) EmailLinkCreate

EmailLinkCreate calls the /email-link/create endpoint and returns the appropriate response.

func (Client) JWTCreate

JWTCreate calls the /jwt/create endpoint and returns the appropriate response.

func (Client) JWTValidate

JWTValidate calls the /jwt/validate endpoint and returns the appropriate response. In most cases, it would be best to use the LocalJWTValidate method instead. The LocalJWTValidate method will use a cached version of the JWK Set, which saves a network call.

func (Client) LinkCreate

LinkCreate calls the /link/create endpoint and returns the appropriate response.

func (Client) LocalJWTValidate

func (c Client) LocalJWTValidate(token string, claims jwt.Claims) (*jwt.Token, error)

LocalJWTValidate validates a JWT locally. If the claims argument is not nil, its value will be passed directly to jwt.ParseWithClaims. The claims should be unmarshalled into the provided non-nil pointer after the function call. See the documentation for jwt.ParseWithClaims for more information. Registered JWT claims will be validated regardless if claims are specified or not.

func (Client) Ready

func (c Client) Ready(ctx context.Context) error

Ready calls the /ready endpoint. An error is returned if the service is not ready.

func (Client) ServiceAccountCreate

ServiceAccountCreate calls the /admin/service-account/create endpoint and returns the appropriate response.

type Options

type Options struct {
	DisableKeyfunc bool
	KeyfuncOptions *keyfunc.Options
	HTTP           *http.Client
}

Options are used to configure the Client.

Jump to

Keyboard shortcuts

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