Documentation
¶
Index ¶
- Variables
- func DeleteFactor(ctx context.Context, opts DeleteFactorOpts) error
- func SetAPIKey(apiKey string)
- func VerifyChallenge(ctx context.Context, opts VerifyOpts) (interface{}, error)
- func VerifyFactor(ctx context.Context, opts VerifyOpts) (interface{}, error)deprecated
- type ChallengeOpts
- type ChallengeResponse
- type Client
- func (c *Client) ChallengeFactor(ctx context.Context, opts ChallengeOpts) (ChallengeResponse, error)
- func (c *Client) DeleteFactor(ctx context.Context, opts DeleteFactorOpts) error
- func (c *Client) EnrollFactor(ctx context.Context, opts GetEnrollOpts) (EnrollResponse, error)
- func (c *Client) GetFactor(ctx context.Context, opts GetFactorOpts) (EnrollResponse, error)
- func (c *Client) VerifyChallenge(ctx context.Context, opts VerifyOpts) (interface{}, error)
- func (c *Client) VerifyFactor(ctx context.Context, opts VerifyOpts) (interface{}, error)deprecated
- type DeleteFactorOpts
- type EnrollResponse
- type GetEnrollOpts
- type GetFactorOpts
- type RawVerifyResponse
- type VerifyOpts
- type VerifyResponse
- type VerifyResponseError
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidType = errors.New("type must be present and 'sms' or 'totp'") ErrIncompleteArgs = errors.New("need to specify both totp_issuer and totp_user when type is totp") ErrNoPhoneNumber = errors.New("need to specify phone_number when type is sms") ErrMissingAuthId = errors.New("authentication_factor_id' is a required parameter") ErrMissingChallengeId = errors.New("challenge_factor_id' is a required parameter") )
This represents the list of errors that could be raised when using the mfa package
var (
DefaultClient = &Client{
Endpoint: "https://api.workos.com",
}
)
DefaultClient is the client used by SetAPIKey and mfa functions.
Functions ¶
func DeleteFactor ¶ added in v1.19.0
func DeleteFactor( ctx context.Context, opts DeleteFactorOpts, ) error
DeleteFactor deletes a factor by ID.
func VerifyChallenge ¶ added in v1.13.0
func VerifyChallenge( ctx context.Context, opts VerifyOpts, ) (interface{}, error)
VerifyChallenge verifies the one time password provided by the end-user.
func VerifyFactor
deprecated
func VerifyFactor( ctx context.Context, opts VerifyOpts, ) (interface{}, error)
Deprecated: Use VerifyChallenge instead
Types ¶
type ChallengeOpts ¶
type ChallengeResponse ¶
type ChallengeResponse struct {
// The authentication challenge's unique ID
ID string `json:"id"`
// The name of the response type.
Object string `json:"object"`
// The timestamp of when the request was created.
CreatedAt string `json:"created_at"`
// The timestamp of when the request was updated.
UpdatedAt string `json:"updated_at"`
// The timestamp of when the request expires.
ExpiresAt string `json:"expires_at"`
// The authentication factor Id used to create the request.
AuthenticationFactorID string `json:"authentication_factor_id"`
}
func ChallengeFactor ¶
func ChallengeFactor( ctx context.Context, opts ChallengeOpts, ) (ChallengeResponse, error)
ChallengeFactor Initiates the authentication process for the newly created MFA authorization factor.
type Client ¶
type Client struct {
// The WorkOS API Key. It can be found in https://dashboard.workos.com/api-keys.
APIKey string
// Defaults to http.Client.
HTTPClient *http.Client
// The endpoint to WorkOS API. Defaults to https://api.workos.com.
Endpoint string
// The function used to encode in JSON. Defaults to json.Marshal.
JSONEncode func(v interface{}) ([]byte, error)
// contains filtered or unexported fields
}
Client represents a client that performs MFA requests to the WorkOS API.
func (*Client) ChallengeFactor ¶
func (c *Client) ChallengeFactor( ctx context.Context, opts ChallengeOpts, ) (ChallengeResponse, error)
Initiates the authentication process for the newly created MFA authorization factor, referred to as a challenge.
func (*Client) DeleteFactor ¶ added in v1.19.0
func (c *Client) DeleteFactor( ctx context.Context, opts DeleteFactorOpts, ) error
Deletes an authentication factor.
func (*Client) EnrollFactor ¶
func (c *Client) EnrollFactor( ctx context.Context, opts GetEnrollOpts, ) (EnrollResponse, error)
Create an Authentication Factor.
func (*Client) GetFactor ¶ added in v1.19.0
func (c *Client) GetFactor( ctx context.Context, opts GetFactorOpts, ) (EnrollResponse, error)
Retrieves an authentication factor.
func (*Client) VerifyChallenge ¶ added in v1.13.0
func (c *Client) VerifyChallenge( ctx context.Context, opts VerifyOpts, ) (interface{}, error)
Verifies the one time password provided by the end-user.
func (*Client) VerifyFactor
deprecated
func (c *Client) VerifyFactor( ctx context.Context, opts VerifyOpts, ) (interface{}, error)
Deprecated: Use VerifyChallenge instead.
type DeleteFactorOpts ¶ added in v1.19.0
type DeleteFactorOpts struct {
// ID of factor to be deleted
AuthenticationFactorID string
}
type EnrollResponse ¶
type EnrollResponse struct {
// The authentication factor's unique ID
ID string `json:"id"`
// The name of the response type
Object string `json:"object"`
// The timestamp of when the request was created.
CreatedAt string `json:"created_at"`
// The timestamp of when the request was updated.
UpdatedAt string `json:"updated_at"`
// The type of request either 'sms' or 'totp'
Type string `json:"type"`
// Details of the totp response will be 'null' if using sms
Totp map[string]interface{} `json:"totp"`
// Details of the sms response will be 'null' if using totp
Sms map[string]interface{} `json:"sms"`
}
func EnrollFactor ¶
func EnrollFactor( ctx context.Context, opts GetEnrollOpts, ) (EnrollResponse, error)
EnrollFactor creates a MFA authorization factor.
func GetFactor ¶ added in v1.19.0
func GetFactor( ctx context.Context, opts GetFactorOpts, ) (EnrollResponse, error)
GetFactor gets a factor by ID.
type GetEnrollOpts ¶
type GetEnrollOpts struct {
// Type of factor to be enrolled (sms or totp).
Type string
// Name of the Organization.
TotpIssuer string
// Email of user.
TotpUser string
// Phone Number of the User.
PhoneNumber string
}
GetEnrollsOpts contains the options to create an Authentication Factor.
type GetFactorOpts ¶ added in v1.19.0
type GetFactorOpts struct {
// ID of the factor.
AuthenticationFactorID string
}
type RawVerifyResponse ¶
type RawVerifyResponse struct {
VerifyResponse
VerifyResponseError
}