Documentation
¶
Index ¶
- Constants
- Variables
- type Client
- 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) LocalJWTValidate(token string, claims jwt.Claims) (*jwt.Token, error)
- func (c Client) MagicLinkCreate(ctx context.Context, req model.MagicLinkCreateRequest) (model.MagicLinkCreateResponse, model.Error, error)
- func (c Client) MagicLinkEmailCreate(ctx context.Context, req model.MagicLinkEmailCreateRequest) (model.MagicLinkEmailCreateResponse, model.Error, error)
- func (c Client) OTPCreate(ctx context.Context, req model.OTPCreateRequest) (model.OTPCreateResponse, model.Error, error)
- func (c Client) OTPEmailCreate(ctx context.Context, req model.OTPEmailCreateRequest) (model.OTPEmailCreateResponse, model.Error, error)
- func (c Client) OTPValidate(ctx context.Context, req model.OTPValidateRequest) (model.OTPValidateResponse, model.Error, 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 platform. The SaaS platform is optional and the magiclinksdev project // is open-source and 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 the official Golang API 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 platform, use the SaaSBaseURL constant. The iss is the issuer of the JWTs, which is in the configuration of the magiclinksdev deployment. For the SaaS platform, use the SaaSIss constant. Providing an empty string for the iss will disable issuer validation.
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) 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 claims argument if it is a non-nil pointer. See the documentation for jwt.ParseWithClaims for more information. Registered JWT claims will be validated regardless if claims are specified or not.
func (Client) MagicLinkCreate ¶ added in v0.6.0
func (c Client) MagicLinkCreate(ctx context.Context, req model.MagicLinkCreateRequest) (model.MagicLinkCreateResponse, model.Error, error)
MagicLinkCreate calls the /magic-link/create endpoint and returns the appropriate response.
func (Client) MagicLinkEmailCreate ¶ added in v0.6.0
func (c Client) MagicLinkEmailCreate(ctx context.Context, req model.MagicLinkEmailCreateRequest) (model.MagicLinkEmailCreateResponse, model.Error, error)
MagicLinkEmailCreate calls the /magic-link-email/create endpoint and returns the appropriate response.
func (Client) OTPCreate ¶ added in v0.6.0
func (c Client) OTPCreate(ctx context.Context, req model.OTPCreateRequest) (model.OTPCreateResponse, model.Error, error)
OTPCreate calls the /otp/create endpoint and returns the appropriate response.
func (Client) OTPEmailCreate ¶ added in v0.6.0
func (c Client) OTPEmailCreate(ctx context.Context, req model.OTPEmailCreateRequest) (model.OTPEmailCreateResponse, model.Error, error)
OTPEmailCreate calls the /otp-email/create endpoint and returns the appropriate response.
func (Client) OTPValidate ¶ added in v0.6.0
func (c Client) OTPValidate(ctx context.Context, req model.OTPValidateRequest) (model.OTPValidateResponse, model.Error, error)
OTPValidate calls the /otp/validate endpoint and returns the appropriate response.
func (Client) Ready ¶
Ready calls the /ready endpoint. An error is returned if the service is not ready to accept requests.
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.