PAS REST API

Authentication

POST /auth/user/+login

Log into the system

Example request:

POST /auth/user/+login HTTP/1.1
Content-Type: application/json

{
    "username": "admin",
    "password": "password"
}

Example response:

HTTP/1.1 200 OK
Content-Type: application/json
Authorization: JWT {jwtoken}

{"status":"success"}
GET /auth/self/+refresh_token

Return new token

Example request:

GET /auth/self/+refresh_token HTTP/1.1
Authorization: JWT {jwtoken}

Example response:

HTTP/1.1 200 OK
Content-Type: application/json
Authorization: JWT {new_jwtoken}

{"status":"success"}

User Management

POST /auth/user/+register

Register user

Example request:

POST /auth/user/+register HTTP/1.1
Content-Type: application/json

{
    "username": "demouser",
    "email": "demouser@example.com",
    "password": "password",
    "password_validate": "password"
}

Example response:

HTTP/1.1 200 OK
Content-Type: application/json

{"status":"success"}
POST /auth/user/{username}/+change_password

Change password

Example request:

POST /auth/user/demouser/+change_password HTTP/1.1
Content-Type: application/json

{
    "new_password": "password",
    "new_password_validate": "password"
}

Example response:

HTTP/1.1 200 OK
Content-Type: application/json

{"status":"success"}

Note

individual user resource management api is the same as model rest api.

GET /auth/self

Get current logged in user. This model inherits from UserModel so all the views from UserModel is inherited.

POST /auth/self/+change_password

Change password

Example request:

POST /auth/self/+change_password HTTP/1.1
Content-Type: application/json

{
    "password": "oldpassword",
    "new_password": "password",
    "new_password_validate": "password"
}

Example response:

HTTP/1.1 200 OK
Content-Type: application/json

{"status":"success"}

Group Management

POST /auth/group/{groupname}/+grant

Grant role

Example request:

POST /auth/group/demogroup/+grant HTTP/1.1
Content-Type: application/json

{
    "mapping": [
        {"user": {"username": "demouser"},
        "roles": ["member"]}
    ]
}

Example response:

HTTP/1.1 200 OK
Content-Type: application/json

{"status":"success"}
POST /auth/group/{groupname}/+revoke

Revoke role

Example request:

POST /auth/group/demogroup/+grant HTTP/1.1
Content-Type: application/json

{
    "mapping": [
        {"user": {"username": "demouser"},
        "roles": ["member"]}
    ]
}

Example response:

HTTP/1.1 200 OK
Content-Type: application/json

{"status":"success"}
GET /auth/group/{groupname}/+members

List members and their roles

Example response:

HTTP/1.1 200 OK
Content-Type: application/json

{
    "users": [
        {
            "username": "demouser",
            "userid": "demouser",
            "roles": ["member"],
            "links": [
                {"rel": "self",
                 "type": "GET",
                 "href": "http://localhost:5000/auth/user/demouser"}
            ]
        }
    ]
}

Note

individual group resource management api is the same as model rest api.

API Key Management

POST /auth/apikey/

Create API key for current logged in user

Example request:

POST /auth/apikey HTTP/1.1
Content-Type: application/json

{
    "password": "password",
    "label": "apikey label"
}

Example response:

HTTP/1.1 200 OK
Content-Type: application/json

{
    "data": {
        "id": 1,
        "uuid": "3aed93a0844e482ca0997d20ab0a1b2a",
        "creator": "285969eefd7547d38fb3a5d06996f93e",
        "created": "2019-01-29T08:37:48.653715",
        "modified": "2019-01-29T08:37:48.653715",
        "state": null,
        "deleted": null,
        "userid": "demouser",
        "label": "apikey label",
        "apikey_identity": "cfaa53c9f583434b9a56ed7a8889f32e",
        "apikey_secret": "df2e6b0f112843bdaa8c695f7ac6603b",
    },
    "links": [
        {
            "rel":"self",
            "href": "http://localhost:5000/auth/apikey/3aed93a0844e482ca0997d20ab0a1b2a"
        },
        {
            "rel": "delete",
            "href": "http://localhost:5000/auth/apikey/3aed93a0844e482ca0997d20ab0a1b2a",
            "method": "DELETE"
        }
    ]
}

Note

individual API key resource management api is the same as model rest api.