2019-04-24 21:52:08 +00:00
|
|
|
package handlers
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/tstranex/u2f"
|
2020-04-05 12:37:21 +00:00
|
|
|
|
|
|
|
"github.com/authelia/authelia/internal/authentication"
|
2019-04-24 21:52:08 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// MethodList is the list of available methods.
|
|
|
|
type MethodList = []string
|
|
|
|
|
|
|
|
type authorizationMatching int
|
|
|
|
|
2020-06-21 13:40:37 +00:00
|
|
|
// UserInfo is the model of user info and second factor preferences.
|
|
|
|
type UserInfo struct {
|
|
|
|
// The users display name.
|
|
|
|
DisplayName string `json:"display_name"`
|
|
|
|
|
2020-01-05 23:03:16 +00:00
|
|
|
// The preferred 2FA method.
|
2019-04-24 21:52:08 +00:00
|
|
|
Method string `json:"method" valid:"required"`
|
2019-12-07 11:18:22 +00:00
|
|
|
|
2020-04-20 21:03:38 +00:00
|
|
|
// True if a security key has been registered.
|
2019-12-07 11:18:22 +00:00
|
|
|
HasU2F bool `json:"has_u2f" valid:"required"`
|
|
|
|
|
2020-04-20 21:03:38 +00:00
|
|
|
// True if a TOTP device has been registered.
|
2019-12-07 11:18:22 +00:00
|
|
|
HasTOTP bool `json:"has_totp" valid:"required"`
|
2019-04-24 21:52:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// signTOTPRequestBody model of the request body received by TOTP authentication endpoint.
|
|
|
|
type signTOTPRequestBody struct {
|
|
|
|
Token string `json:"token" valid:"required"`
|
|
|
|
TargetURL string `json:"targetURL"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// signU2FRequestBody model of the request body of U2F authentication endpoint.
|
|
|
|
type signU2FRequestBody struct {
|
|
|
|
SignResponse u2f.SignResponse `json:"signResponse"`
|
|
|
|
TargetURL string `json:"targetURL"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type signDuoRequestBody struct {
|
|
|
|
TargetURL string `json:"targetURL"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// firstFactorBody represents the JSON body received by the endpoint.
|
|
|
|
type firstFactorRequestBody struct {
|
|
|
|
Username string `json:"username" valid:"required"`
|
|
|
|
Password string `json:"password" valid:"required"`
|
|
|
|
TargetURL string `json:"targetURL"`
|
|
|
|
// Cannot require this field because of https://github.com/asaskevich/govalidator/pull/329
|
|
|
|
// TODO(c.michaud): add required validation once the above PR is merged.
|
|
|
|
KeepMeLoggedIn *bool `json:"keepMeLoggedIn"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// redirectResponse represent the response sent by the first factor endpoint
|
|
|
|
// when a redirection URL has been provided.
|
|
|
|
type redirectResponse struct {
|
|
|
|
Redirect string `json:"redirect"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// TOTPKeyResponse is the model of response that is sent to the client up successful identity verification.
|
|
|
|
type TOTPKeyResponse struct {
|
|
|
|
Base32Secret string `json:"base32_secret"`
|
|
|
|
OTPAuthURL string `json:"otpauth_url"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// StateResponse represents the response sent by the state endpoint.
|
|
|
|
type StateResponse struct {
|
|
|
|
Username string `json:"username"`
|
|
|
|
AuthenticationLevel authentication.Level `json:"authentication_level"`
|
|
|
|
DefaultRedirectionURL string `json:"default_redirection_url"`
|
|
|
|
}
|
|
|
|
|
2020-04-20 21:03:38 +00:00
|
|
|
// resetPasswordStep1RequestBody model of the reset password (step1) request body.
|
2019-04-24 21:52:08 +00:00
|
|
|
type resetPasswordStep1RequestBody struct {
|
|
|
|
Username string `json:"username"`
|
|
|
|
}
|
|
|
|
|
2020-04-20 21:03:38 +00:00
|
|
|
// resetPasswordStep2RequestBody model of the reset password (step2) request body.
|
2019-04-24 21:52:08 +00:00
|
|
|
type resetPasswordStep2RequestBody struct {
|
|
|
|
Password string `json:"password"`
|
|
|
|
}
|