Users

users.Authentication

Estimated reading: 9 minutes 1362 views
Namespace:Users
REST:https://[hoster-api-host]/1.0/users/authentication/rest/{method-name}
Scripting:jelastic.users.authentication.{method-name}

This service is responsible for the identification and authentication of registered users. It includes sign-in/out actions, session and tokens management, etc.

Methods

CreateToken (session, [password], description, [tokenTemplate], [apiList], [expiresAt] ) :

Creates a personal access token, which allows executing specific API methods.

URL

https://[hoster-api-host]/1.0/users/authentication/rest/createtoken

Request Parameters

  • session : “string”
    user session or personal access token. (check Signin API to create session)
  • password : “string”
    password for authenticating the current user.
  • description : “string”
    custom description for the created token.
  • tokenTemplate : “string”
    one of standard tokens configurations with the predefined permissions (Marketplace, Maven Plugin, IDE Plugins, Extended Access). You can get the full list with the “GetTokenTemplates” method. If not specified, a “Custom” token with manually provided “apiList” will be created.
  • apiList : “string”
    a comma-separated list of API methods that are allowed by the token. You can get the full list with the “GetTokenApiList” method. For example: [“env.control.CreateEnvironment”, “env.control.RedeployContainersByGroup”, “env.file.AddMountPointByGroup”].
  • expiresAt : “string” (optional)
    expiration date (UTC) for the token. In the format “yyyy-MM-dd hh:mm:ss”, e.g. “2022-11-16 00:00:00”.

Example

Method: POST https://[hoster-api-host]/1.0/users/authentication/rest/createtoken?tokenTemplate=[string]&password=[string]&session=[string]&description=[string]&expiresAt=[string]&apiList=[string]

Response

stdClass Object
(
    [result] => 0
    [debug] => stdClass Object
        (
            [cpu] => stdClass Object
                (
                    [usage] => 0
                    [time] => 0
                )
            [time] => "int"
        )
    [token] => stdClass Object
        (
            [tokenTemplate] => "string"
            [description] => "string"
            [id] => "int"
            [createdOn] => "Timestamp"
            [key] => "string"
            [apiList] => Array
                (
                    [0] => "API1",
                    [1] => "API2",
                )
        )
)

DeleteTokens (session, ids, [password] ) :

Deletes a list of specified personal access tokens on the current account.

URL

https://[hoster-api-host]/1.0/users/authentication/rest/deletetokens

Parameters

  • session : “string”
    user session or personal access token(check Signin API to create session)
  • ids : “string”
    a comma- or semicolon-separated list of target token IDs. For example: 1;4;6. Also, you can use * for selecting all your tokens.
  • password : “string” (optional)
    password for authenticating the current user.

Example

Method: POST
https://[hoster-api-host]/1.0/users/authentication/rest/deletetokens?password=[string]&session=[string]&ids=[string]

Response

stdClass Object
(
    [result] => "Boolean"
    [debug] => stdClass Object
        (
            [cpu] => stdClass Object
                (
                    [usage] => 0
                    [time] => 0
                )
            [time] => "Timestamp"
        )
)

EditToken (session, id, password, [description], [tokenTemplate], [apiList], [expiresAt] ) :

Updates an existing personal access token with a new values.

URL

https://[hoster-api-host]/1.0/users/authentication/rest/edittoken

Parameters

  • session : “string”
  • user session or personal access token.

  • id : “int”

    unique identifier of the target token.

  • password : “string”

    password for authenticating the current user.

  • description : “string” (optional)

    new description for the target token.

  • tokenTemplate : “string” (optional)

    change token configurations to one of the standard presets (Marketplace, Maven Plugin, IDE Plugins, Extended Access). You can get the full list with the “GetTokenTemplates” method. Set as “Custom” to manually provide new permissions via “apiList” parameter.

  • apiList : “string” (optional)

    a comma-separated list of API methods that are allowed by the token. You can get the full list with the “GetTokenApiList” method. For example: [“env.control.CreateEnvironment”, “env.control.RedeployContainersByGroup”, “env.file.AddMountPointByGroup”].

  • expiresAt : “string” (optional)

    new expiration date (UTC) for the token. In the format “yyyy-MM-dd hh:mm:ss”, e.g. “2022-11-16 00:00:00”.

Example

Method: POST

https://[hoster-api-host]/1.0/users/authentication/rest/edittoken?tokenTemplate=[string]&password=[string]&session=[string]&description=[string]&id=[int]&expiresAt=[string]&apiList=[string]

Response

stdClass Object
(
    [result] => 0
    [debug] => stdClass Object
        (
            [cpu] => stdClass Object
                (
                    [usage] => 0
                    [time] => 0
                )

            [time] => 69
        )

    [token] => stdClass Object
        (
            [lastUsed] => "Timestamp"
            [description] => "string"
            [id] => "int"
            [createdOn] => "Timestamp"
            [expiresAt] => "Timestamp"
            [apiList] => Array
                (
                    [0] => "API1"
                    [1] => "API2"
                )

        )

)

GetPolicyMethods (appid, session, [uniqueName] ) :

Returns a list of API methods allowed by the specified policy.

URL

https://[hoster-api-host]/1.0/users/authentication/rest/edittoken

Parameters

  • appid : “string”
    unique identifier of the target application (required for authentication).
  • session : “string”
    user session or personal access token.
  • uniqueName : “string” (optional)
    unique identifier of the target policy (all policies if not defined).

Response

  • ApiTokenPermissionsResponse
    {
       "behavior": "ALLOW(0) | DENY(1)",
       "error": "string",
       "reason": "int",
       "result": "int",
       "roleId": "int",
       "source": "string",
       "tokenPermissions": [
          {
             "id": "int",
             "isCollaborationAccessible": "boolean",
             "isSafe": "boolean",
             "method": "string",
             "useObjectHash": "boolean"
          },
          "..."
       ]
    }
    

    Example

    https://[hoster-api-host]/1.0/users/authentication/rest/getpolicymethods?uniqueName=[string]&session=[string]&appid=[string]

GetSessions ([appid], session ) :

Returns a list of active sessions.

URL

https://[hoster-api-host]/1.0/users/authentication/rest/getsessions

Parameters

  • appid : “string” (optional)

    unique identifier of the target application (required for authentication).

  • session : “string”

    user session or personal access token.

Example

Method: POST

https://[hoster-api-host]/1.0/users/authentication/rest/getsessions?session=[string]&appid=[string]

Response

stdClass Object
(
    [result] => 0
    [sessions] => Array
        (
            [0] => stdClass Object
                (
                    [uid] => "int"
                    [current] => "boolean"
                    [host] => "ip"
                    [userAgent] => "string"
                    [lastAccess] => "Timestamp"
                    [id] => "int"
                    [createdOn] => "Timestamp"
                )
        )
    [debug] => stdClass Object
        (
            [cpu] => stdClass Object
                (
                    [usage] => 0
                    [time] => 0
                )
            [time] => "int"
        )
)

GetTokenApiList (session, [showPrivate], [sortParam] ) :

Returns list of API methods that can be authenticated with the specified token.

URL

https://[hoster-api-host]/1.0/users/authentication/rest/gettokenapilist

Parameters

  • session : “string”
    user session or personal access token.
  • showPrivate : “boolean” (optional)
    defines whether to show private methods allowed by the token (true) or not (false).
  • sortParam : “string” (optional)
    filter by method name.

Example

Method: POST

https://[hoster-api-host]/1.0/users/authentication/rest/gettokenapilist?sortParam=[string]&showPrivate=[boolean]&session=[string]

Response

stdClass Object
(
    [result] => 0
    [debug] => stdClass Object
        (
            [cpu] => stdClass Object
                (
                    [usage] => 0
                    [time] => 0
                )
            [time] => "int"
        )
    [apiList] => Array
        (
            [0] => "API1"
            [1] => "API2"
        )
)

GetTokenTemplates (session) :

Returns a list of standard token templates with the predefined list of allowed API methods.

URL

https://[hoster-api-host]/1.0/users/authentication/rest/gettokenapilist

Parameters

Example

Method: POST

https://[hoster-api-host]/1.0/users/authentication/rest/gettokentemplates?session=[string]

Response

stdClass Object
(
    [result] => 0
    [debug] => stdClass Object
        (
            [cpu] => stdClass Object
                (
                    [usage] => 0
                    [time] => 0
                )
            [time] => 15
        )
    [templates] => Array
        (
            [0] => stdClass Object
                (
                    [name] => "string"
                    [id] => "int"
                    [apiList] => Array
                        (
                            [0] => "API1"
                            [2] => "API2"
                        )
                )
        )
)

GetTokens (session, [ids] ) :

Returns information about specified tokens.

URL

https://[hoster-api-host]/1.0/users/authentication/rest/gettokens

Parameters

  • session : “string”
    user session or personal access token.
  • ids : “string” (optional)
    a comma- or semicolon-separated list of target token IDs. For example: 1;4;6. Also, you can use * for selecting all your tokens.

Example

Method: POST

https://[hoster-api-host]/1.0/users/authentication/rest/gettokens?session=[string]&ids=[string]

Response

stdClass Object
(
    [result] => 0
    [debug] => stdClass Object
        (
            [cpu] => stdClass Object
                (
                    [usage] => 0
                    [time] => 0
                )

            [time] => "int"
        )

    [tokens] => Array
        (
            [0] => stdClass Object
                (
                    [lastUsed] => "Timestamp"
                    [description] => "string"
                    [id] => "int"
                    [createdOn] => "Timestamp"
                    [expiresAt] => "Timestamp"
                    [apiList] => Array
                        (
                            [0] => "API1"
                            [1] => "API2"
                        )
                )
        )
)

RegenerateToken (session, id, password ) :

Generates a new value for the specified token. The previous value is invalidated.

Parameters

  • session : “string”
    user session or personal access token.
  • id : “int”
    unique identifier of the target token.
  • password : “string”
    password for authenticating the current user.

Example

Method: POST

https://[hoster-api-host]/1.0/users/authentication/rest/regeneratetoken?password=[string]&session=[string]&id=[int]

Response

stdClass Object
(
    [result] => 0
    [debug] => stdClass Object
        (
            [cpu] => stdClass Object
                (
                    [usage] => 0
                    [time] => 0
                )

            [time] => "int"
        )
    [token] => stdClass Object
        (
            [tokenTemplate] => "string"
            [description] => "string"
            [id] => "int"
            [createdOn] => "Timestamp"
            [key] => "string"
            [apiList] => Array
                (
                    [0] => "API1"
                )
        )
)

Signin (session,[appid], login, password ) : AuthenticationResponse

Creates a session for the specified user to authenticate different actions within the account. This session is valid until the Signout method is called or session has been expired.

URL

https://[hoster-api-host]/1.0/users/authentication/rest/signin

Parameters

  • session : “string”
    user session or personal access token.
  • appid : “string” (optional)
    unique identifier of the target application (required for authentication).
  • login : “string”
    email address or unique identifier of the target user.
  • password : “string”
    password for authenticating the target user.

Example

Method: POST
POST https://[hoster-api-host]/1.0/users/authentication/rest/signin?password=[string]&appid=[string]&login=[string]

Response

stdClass Object
(
    [result] => 0
    [accessType] => "FULL_ACCESS(0) | RESTRICTED(1)"
    [uid] => "int"
    [debug] => stdClass Object
        (
            [cpu] => stdClass Object
                (
                    [usage] => 0
                    [time] => 0
                )
            [time] => "int"
        )
    [data] => stdClass Object
        (
            [lang] => "string"
        )
    [authConfig] => stdClass Object
        (
            [type] => "string"
        )
    [session] => "string"
    [email] => "string"
    [status] => "ENABLED(0) | SUSPENDED(1)"
)

Signout ([appid], session ) :

Ends (invalidates) the specified session.

URL

https://[hoster-api-host]/1.0/users/authentication/rest/signout

Parameters

  • appid : “string” (optional)

    unique identifier of the target application (required for authentication).

  • session : “string”

    user session or personal access token.

Example

Method: POST

https://[hoster-api-host]/1.0/users/authentication/rest/signout?session=[string]&appid=[string]

Response

stdClass Object
(
    [result] => 0
    [debug] => stdClass Object
        (
            [cpu] => stdClass Object
                (
                    [usage] => 0
                    [time] => 0
                )
            [time] => "int"
        )
)

SignoutSessions ([appid], session, ids ) :

Ends (invalidates) all active sessions for the listed tokens.

URL

https://[hoster-api-host]/1.0/users/authentication/rest/signoutsessions

Parameters

  • appid : “string” (optional)

    unique identifier of the target application (required for authentication).

  • session : “string”

    user session or personal access token.

  • ids : “string”

    a comma- or semicolon-separated list of target token IDs. For example: 1;4;6. Also, you can use * for selecting all your tokens.

Example

Method: POST

https://[hoster-api-host]/1.0/users/authentication/rest/signoutsessions?session=[string]&appid=[string]&ids=[string]

Response

stdClass Object
(
    [result] => 0
    [debug] => stdClass Object
        (
            [cpu] => stdClass Object
                (
                    [usage] => 0
                    [time] => 0
                )
            [time] => "int"
        )
)

Leave a Comment