auth.login_ex¶
Authenticate using one of a variety of mechanisms
NOTE: mechanisms with a _PLAIN suffix indicate that they involve passing plain-text passwords or password-equivalent strings and should not be used on untrusted / insecure transport. Available mechanisms will be expanded in future releases.
params: This takes a single argument consistning of a JSON object with the following keys:
mechanism: the mechanism by which to authenticate to the backend the exact parameters to use vary by mechanism and are described below
PASSWORD_PLAIN username: username with which to authenticate password: password with which to authenticate login_options: dictionary with additional authentication options
API_KEY_PLAIN username: username with which to authenticate api_key: API key string login_options: dictionary with additional authentication options
AUTH_TOKEN_PLAIN token: authentication token string login_options: dictionary with additional authentication options
OTP_TOKEN otp_token: one-time password token. This is only permitted if a previous auth.login_ex call responded with “OTP_REQUIRED”.
login_options user_info: boolean - include auth.me output in successful responses.
raises: CallError: a middleware CallError may be raised in the following circumstances.
An multistep challenge-response authentication mechanism is being used and the specified mechanism does not match the expected next step for authentication. In this case the errno will be set to EBUSY.
OTP_TOKEN mechanism was passed without an explicit request from a previous authentication step. In this case the errno will be set to EINVAL.
Current authenticator assurance level prohibits the use of the specified authentication mechanism. In this case the errno will be set to EOPNOTSUPP.
returns: JSON object containing the following keys:
response_type: string indicating the results of the current authentication mechanism. This is used to inform client of nature of authentication error or whether further action will be required in order to complete authentication.
<additional keys per response_type>
Notes about response types:
SUCCESS: additional key: user_info: includes auth.me output for the resulting authenticated credentials.
OTP_REQUIRED additional key: username: normalized username of user who must provide an OTP token.
AUTH_ERR Generic authentication error corresponds to PAM_AUTH_ERR and PAM_USER_UNKOWN from libpam. This may be returned if the account does not exist or if the credential is incorrect.
EXPIRED The specified credential is expired and not suitable for authentication.
REDIRECT Authentication must be performed on different server.
No Additional Items
Tuple Validation
Parameter 1: login_data
login_data
Authentication data specifying mechanism and credentials.
AuthApiKeyPlain
Type: objectNo Additional Properties
Mechanism
Type: constAuthentication mechanism identifier for plain API key authentication.
Must be one of:
- "API_KEY_PLAIN"
"API_KEY_PLAIN"
Username
Type: stringUsername associated with the API key.
Api Key
Type: stringAPI key for authentication.
AuthCommonOptions
Type: object Default: {"user_info": true}Additional options for the authentication process.
No Additional PropertiesUser Info
Type: boolean Default: trueWhether to include detailed user information in the authentication response.
AuthPasswordPlain
Type: objectNo Additional Properties
Mechanism
Type: constAuthentication mechanism identifier for plain password authentication.
Must be one of:
- "PASSWORD_PLAIN"
"PASSWORD_PLAIN"
Username
Type: stringUsername for authentication.
Password
Type: stringPassword for authentication.
AuthCommonOptions
Type: object Default: {"user_info": true}Additional options for the authentication process.
No Additional PropertiesUser Info
Type: boolean Default: trueWhether to include detailed user information in the authentication response.
AuthTokenPlain
Type: objectNo Additional Properties
Mechanism
Type: constAuthentication mechanism type for plain token login.
Must be one of:
- "TOKEN_PLAIN"
"TOKEN_PLAIN"
Token
Type: stringAuthentication token (masked for security).
AuthCommonOptions
Type: object Default: {"user_info": true}Common authentication options and settings.
No Additional PropertiesUser Info
Type: boolean Default: trueWhether to include detailed user information in the authentication response.
AuthOTPToken
Type: objectNo Additional Properties
Mechanism
Type: constAuthentication mechanism identifier for one-time password tokens.
Must be one of:
- "OTP_TOKEN"
"OTP_TOKEN"
Otp Token
Type: stringOne-time password token for authentication.
AuthCommonOptions
Type: object Default: {"user_info": true}Additional options for the authentication process.
No Additional PropertiesUser Info
Type: boolean Default: trueWhether to include detailed user information in the authentication response.
Result
Authentication response indicating success, failure, or additional steps required.
AuthRespSuccess
Type: objectNo Additional Properties
Response Type
Type: constAuthentication response type indicating successful login.
Must be one of:
- "SUCCESS"
"SUCCESS"
Authenticated user information or null
if not available.
AuthUserInfo
Type: objectNo Additional Properties
Pw Name
Type: stringName of the user.
Pw Gecos
Type: stringFull username or comment field.
Pw Dir
Type: stringUser home directory.
Pw Shell
Type: stringUser command line interpreter.
Pw Uid
Type: integerNumerical user ID of the user.
Pw Gid
Type: integerNumerical group id for the user's primary group.
Grouplist
Optional array of group IDs for groups of which this account is a member. If get_groups
is not specified, this value will be null
.
No Additional Items
Each item of this array must be:
Sid
Optional SID value for the account that is present if sid_info
is specified in payload.
Source
Type: enum (of string)The source for the user account.
Must be one of:
- "LOCAL"
- "ACTIVEDIRECTORY"
- "LDAP"
Local
Type: booleanThe account is local to TrueNAS or provided by a directory service.
Attributes
Type: objectCustom user attributes and metadata.
Two Factor Config
Type: objectTwo-factor authentication configuration for the user.
Privilege
Type: objectUser privilege and role information.
Account Attributes
Type: array of stringArray of account attribute names available for this user.
No Additional ItemsEach item of this array must be:
Authenticator
Type: enum (of string)Authentication level achieved (LEVEL1 for password, LEVEL2 for two-factor).
Must be one of:
- "LEVEL_1"
- "LEVEL_2"
AuthRespAuthErr
Type: objectNo Additional Properties
Response Type
Type: constAuthentication response type indicating authentication failure.
Must be one of:
- "AUTH_ERR"
"AUTH_ERR"
AuthRespExpired
Type: objectNo Additional Properties
Response Type
Type: constAuthentication response type indicating the session or token has expired.
Must be one of:
- "EXPIRED"
"EXPIRED"
AuthRespOTPRequired
Type: objectNo Additional Properties
Response Type
Type: constAuthentication response type indicating one-time password is required.
Must be one of:
- "OTP_REQUIRED"
"OTP_REQUIRED"
Username
Type: stringUsername for which OTP is required.
AuthRespAuthRedirect
Type: objectNo Additional Properties
Response Type
Type: constAuthentication response type indicating redirect is required.
Must be one of:
- "REDIRECT"
"REDIRECT"
Urls
Type: array of stringArray of URLs to redirect to for authentication completion.
No Additional ItemsEach item of this array must be:
Required roles: