Documentation
¶
Index ¶
- Variables
- func DeleteFactor(ctx context.Context, opts DeleteFactorOpts) error
- func SetAPIKey(apiKey string)
- func VerifyFactor(ctx context.Context, opts VerifyChallengeOpts) (interface{}, error)deprecated
- type Challenge
- type ChallengeFactorOpts
- type Client
- func (c *Client) ChallengeFactor(ctx context.Context, opts ChallengeFactorOpts) (Challenge, error)
- func (c *Client) DeleteFactor(ctx context.Context, opts DeleteFactorOpts) error
- func (c *Client) EnrollFactor(ctx context.Context, opts EnrollFactorOpts) (Factor, error)
- func (c *Client) GetFactor(ctx context.Context, opts GetFactorOpts) (Factor, error)
- func (c *Client) VerifyChallenge(ctx context.Context, opts VerifyChallengeOpts) (VerifyChallengeResponse, error)
- func (c *Client) VerifyFactor(ctx context.Context, opts VerifyChallengeOpts) (interface{}, error)deprecated
- type DeleteFactorOpts
- type EnrollFactorOpts
- type Factor
- type FactorType
- type GetFactorOpts
- type RawVerifyChallengeResponse
- type SMSDetails
- type TOTPDetails
- type VerificationResponseError
- type VerifyChallengeOpts
- type VerifyChallengeResponse
- type VerifyChallengeResponseError
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 ¶
func DeleteFactor( ctx context.Context, opts DeleteFactorOpts, ) error
DeleteFactor deletes a factor by ID.
func VerifyFactor
deprecated
func VerifyFactor( ctx context.Context, opts VerifyChallengeOpts, ) (interface{}, error)
Deprecated: Use VerifyChallenge instead
Types ¶
type Challenge ¶
type Challenge 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.
FactorID string `json:"authentication_factor_id"`
}
func ChallengeFactor ¶
func ChallengeFactor( ctx context.Context, opts ChallengeFactorOpts, ) (Challenge, error)
ChallengeFactor Initiates the authentication process for the newly created MFA authorization factor.
type ChallengeFactorOpts ¶
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 ChallengeFactorOpts, ) (Challenge, error)
Initiates the authentication process for the newly created MFA authorization factor, referred to as a challenge.
func (*Client) DeleteFactor ¶
func (c *Client) DeleteFactor( ctx context.Context, opts DeleteFactorOpts, ) error
Deletes an authentication factor.
func (*Client) EnrollFactor ¶
Create an Authentication Factor.
func (*Client) VerifyChallenge ¶
func (c *Client) VerifyChallenge( ctx context.Context, opts VerifyChallengeOpts, ) (VerifyChallengeResponse, error)
Verifies the one time password provided by the end-user.
func (*Client) VerifyFactor
deprecated
func (c *Client) VerifyFactor(ctx context.Context, opts VerifyChallengeOpts) (interface{}, error)
Deprecated: Use VerifyChallenge instead.
type DeleteFactorOpts ¶
type DeleteFactorOpts struct {
// ID of factor to be deleted
FactorID string
}
type EnrollFactorOpts ¶
type EnrollFactorOpts struct {
// Type of factor to be enrolled (sms or totp).
Type FactorType
// Name of the Organization.
TOTPIssuer string
// Email of user.
TOTPUser string
// Phone Number of the User.
PhoneNumber string
}
EnrollFactorOpts contains the options to create an Authentication Factor.
type Factor ¶
type Factor 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 FactorType `json:"type"`
// Details of the totp response will be 'null' if using sms
TOTP TOTPDetails `json:"totp"`
// Details of the sms response will be 'null' if using totp
SMS SMSDetails `json:"sms"`
}
func EnrollFactor ¶
func EnrollFactor( ctx context.Context, opts EnrollFactorOpts, ) (Factor, error)
EnrollFactor creates a MFA authorization factor.
type FactorType ¶
type FactorType string
Type represents the type of Authentication Factor
const ( SMS FactorType = "sms" TOTP FactorType = "totp" )
Constants that enumerate the available Types.
type GetFactorOpts ¶
type GetFactorOpts struct {
// ID of the factor.
FactorID string
}
type RawVerifyChallengeResponse ¶
type RawVerifyChallengeResponse struct {
VerifyChallengeResponse
VerifyChallengeResponseError
}
type SMSDetails ¶
type SMSDetails struct {
PhoneNumber string `json:"phone_number"`
}
type TOTPDetails ¶
type VerificationResponseError ¶
func (VerificationResponseError) Error ¶
func (r VerificationResponseError) Error() string
type VerifyChallengeOpts ¶
type VerifyChallengeResponse ¶
type VerifyChallengeResponse struct {
// Return details of the request
Challenge Challenge `json:"challenge"`
// Boolean returning if request is valid
Valid bool `json:"valid"`
}
func VerifyChallenge ¶
func VerifyChallenge( ctx context.Context, opts VerifyChallengeOpts, ) (VerifyChallengeResponse, error)
VerifyChallenge verifies the one time password provided by the end-user.