Documentation ¶
Index ¶
- Constants
- Variables
- type Client
- func (c Client) EmailLinkCreate(ctx context.Context, req model.EmailLinkCreateRequest) (model.EmailLinkCreateResponse, model.Error, error)
- func (c Client) JWTCreate(ctx context.Context, req model.JWTCreateRequest) (model.JWTCreateResponse, model.Error, error)
- func (c Client) JWTValidate(ctx context.Context, req model.JWTValidateRequest) (model.JWTValidateResponse, model.Error, error)
- func (c Client) LinkCreate(ctx context.Context, req model.LinkCreateRequest) (model.LinkCreateResponse, model.Error, error)
- func (c Client) LocalJWTValidate(token string, claims jwt.Claims) (*jwt.Token, error)
- func (c Client) Ready(ctx context.Context) error
- func (c Client) ServiceAccountCreate(ctx context.Context, req model.ServiceAccountCreateRequest) (model.ServiceAccountCreateResponse, model.Error, error)
- type Options
Constants ¶
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 ¶
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 ¶
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 ¶
func (c Client) EmailLinkCreate(ctx context.Context, req model.EmailLinkCreateRequest) (model.EmailLinkCreateResponse, model.Error, error)
EmailLinkCreate calls the /email-link/create endpoint and returns the appropriate response.
func (Client) JWTCreate ¶
func (c Client) JWTCreate(ctx context.Context, req model.JWTCreateRequest) (model.JWTCreateResponse, model.Error, error)
JWTCreate calls the /jwt/create endpoint and returns the appropriate response.
func (Client) JWTValidate ¶
func (c Client) JWTValidate(ctx context.Context, req model.JWTValidateRequest) (model.JWTValidateResponse, model.Error, error)
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 ¶
func (c Client) LinkCreate(ctx context.Context, req model.LinkCreateRequest) (model.LinkCreateResponse, model.Error, error)
LinkCreate calls the /link/create endpoint and returns the appropriate response.
func (Client) LocalJWTValidate ¶
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 ¶
Ready calls the /ready endpoint. An error is returned if the service is not ready.
func (Client) ServiceAccountCreate ¶
func (c Client) ServiceAccountCreate(ctx context.Context, req model.ServiceAccountCreateRequest) (model.ServiceAccountCreateResponse, model.Error, error)
ServiceAccountCreate calls the /admin/service-account/create endpoint and returns the appropriate response.