NAME

WWW::Suffit::Server::API::Admin - The Suffit API controller for admin management

SYNOPSIS

use WWW::Suffit::Server::API::Admin;

DESCRIPTION

The Suffit API controller for admin management

This module uses the following configuration directives:

JWS_Algorithm

Allowed JWS signing algorithms: HS256, HS384, HS512, RS256, RS384, RS512

HS256   HMAC+SHA256 integrity
HS384   HMAC+SHA384 integrity
HS512   HMAC+SHA512 integrity
RS256   RSA+PKCS1-V1_5 + SHA256 signature
RS384   RSA+PKCS1-V1_5 + SHA384 signature
RS512   RSA+PKCS1-V1_5 + SHA512 signature

Default: HS256

SessionExpires
SessionExpires +1h
SessionExpires 3600

This directive defines time of session expiration in formatted time units

Default: 3600 (1 hour)

TokenExpires
TokenExpires  +1d
TokenExpires  86400
TokenExpires  20h
TokenExpires  1M

This directive defines expiration period of the issued JWT tokens

Default: 86400 (1 day)

METHODS

List of internal methods

group_enroll

See "POST /api/admin/group/GROUPNAME/enroll"

group_del

See "DELETE /api/admin/group/GROUPNAME"

group_members

See "GET /api/admin/group/GROUPNAME/members"

group_get

See "GET /api/admin/group" and "GET /api/admin/group/GROUPNAME"

group_set

See "POST /api/admin/group" and "PUT /api/admin/group/GROUPNAME"

settings

See "GET /api/admin/settings"

realm_del

See "DELETE /api/admin/realm/REALMNAME"

realm_get

See "GET /api/admin/realm" and "GET /api/admin/realm/REALMNAME"

realm_set

See "POST /api/admin/realm" and "PUT /api/admin/realm/REALMNAME"

requirement_get

See "GET /api/admin/requirement"

route_del

See "DELETE /api/admin/route/ROUTENAME"

route_get

See "GET /api/admin/route" and "GET /api/admin/route/ROUTENAME"

route_set

See "POST /api/admin/route" and "PUT /api/admin/route/ROUTENAME"

See "GET /api/admin/search/route"

route_sysadd

See "POST /api/admin/sysroute"

route_sysget

See "GET /api/admin/sysroute"

user_del

See "DELETE /api/admin/user/USERNAME"

user_get

See "GET /api/admin/user" and "GET /api/admin/user/USERNAME"

user_groups

See "GET /api/admin/user/USERNAME/groups"

user_passwd

See "PUT /api/admin/user/USERNAME/passwd"

See "GET /api/admin/search/user"

user_set

See "POST /api/admin/user" and "PUT /api/admin/user/USERNAME"

API METHODS

List of API methods

GET /api/admin/group

Gets list of all existing groups

# curl -v -H "Authorization: OWL eyJh...Bh7g" \
  https://owl.localhost:8695/api/admin/group

> GET /api/admin/group HTTP/1.1
> Host: owl.localhost:8695
> User-Agent: curl/7.68.0
> Accept: */*
> Authorization: OWL eyJh...Bh7g
>
< HTTP/1.1 200 OK
< Server: OWL/1.00
< Date: Mon, 15 May 2023 14:48:22 GMT
< Content-Length: 292
< Content-Type: application/json;charset=UTF-8
<
[
  {
    "description": "OWL Administrators",
    "groupname": "admin",
    "id": 3
  }
]

POST /api/admin/group

Adds new group

# curl -v -H "Authorization: OWL eyJh...Bh7g" \
  -X POST -d '{
    "groupname": "FooBar",
    "description": "Test group",
    "members": ["alice", "test"]
  }' \
  https://owl.localhost:8695/api/admin/group

> POST /api/admin/group HTTP/1.1
> Host: owl.localhost:8695
> User-Agent: curl/7.68.0
> Accept: */*
> Authorization: OWL eyJh...Bh7g
> Content-Length: 112
> Content-Type: application/x-www-form-urlencoded
>
< HTTP/1.1 200 OK
< Date: Mon, 15 May 2023 15:00:57 GMT
< Content-Length: 70
< Server: OWL/1.00
< Content-Type: application/json;charset=UTF-8
<
{
  "description": "Test group",
  "groupname": "FooBar",
  "id": 9,
  "status": true
}

GET /api/admin/group/GROUPNAME

Gets group's data by groupname

# curl -v -H "Authorization: OWL eyJh...Bh7g" \
  https://owl.localhost:8695/api/admin/group/admin

> GET /api/admin/group/admin HTTP/1.1
> Host: owl.localhost:8695
> User-Agent: curl/7.68.0
> Accept: */*
> Authorization: OWL eyJh...Bh7g
>
< HTTP/1.1 200 OK
< Content-Length: 77
< Content-Type: application/json;charset=UTF-8
< Date: Mon, 15 May 2023 14:50:45 GMT
< Server: OWL/1.00
<
{
  "description": "OWL Administrators",
  "groupname": "admin",
  "id": 3,
  "status": true
}

PUT /api/admin/group/GROUPNAME

Edit the group

# curl -v -H "Authorization: OWL eyJh...Bh7g" \
  -X PUT -d '{
    "id": 9,
    "description": "Test group",
    "members": ["test"]
  }' \
  https://owl.localhost:8695/api/admin/group/FooBar

> PUT /api/admin/group/FooBar HTTP/1.1
> Host: owl.localhost:8695
> User-Agent: curl/7.68.0
> Accept: */*
> Authorization: OWL eyJh...Bh7g
> Content-Length: 91
> Content-Type: application/x-www-form-urlencoded
>
< HTTP/1.1 200 OK
< Content-Type: application/json;charset=UTF-8
< Date: Mon, 15 May 2023 15:06:28 GMT
< Content-Length: 70
< Server: OWL/1.00
<
{
  "description": "Test group",
  "groupname": "FooBar",
  "id": 9,
  "status": true
}

DELETE /api/admin/group/GROUPNAME

Delete group by groupname

# curl -v -X DELETE -H "Authorization: OWL eyJh...Bh7g" \
  https://owl.localhost:8695/api/admin/group/FooBar

> DELETE /api/admin/group/FooBar HTTP/1.1
> Host: owl.localhost:8695
> User-Agent: curl/7.68.0
> Accept: */*
> Authorization: OWL eyJh...Bh7g
>
< HTTP/1.1 200 OK
< Date: Mon, 15 May 2023 15:13:31 GMT
< Server: OWL/1.00
< Content-Type: application/json;charset=UTF-8
< Content-Length: 30
<
{
  "code": "E0000",
  "status":true
}

POST /api/admin/group/GROUPNAME/enroll

Add user to group members

# curl -v -H "Authorization: OWL eyJh...j1rM" \
  -X POST -d '{
    "groupname": "wheel",
    "username": "bob"
  }' \
  https://owl.localhost:8695/api/admin/group/wheel/enroll

> POST /api/admin/group/wheel/enroll HTTP/1.1
> Host: owl.localhost:8695
> User-Agent: curl/7.68.0
> Accept: */*
> Authorization: OWL eyJh...j1rM
> Content-Length: 65
> Content-Type: application/x-www-form-urlencoded
>
< HTTP/1.1 200 OK
< Content-Length: 52
< Date: Fri, 12 May 2023 13:18:34 GMT
< Content-Type: application/json;charset=UTF-8
< Server: OWL/1.00
<
{
  "groupname": "wheel",
  "status": true,
  "username": "bob"
}

GET /api/admin/group/GROUPNAME/members

Gets user list of group by groupname

# curl -v -H "Authorization: OWL eyJh...Bh7g" \
  https://owl.localhost:8695/api/admin/group/admin/members

> GET /api/admin/group/admin/members HTTP/1.1
> Host: owl.localhost:8695
> User-Agent: curl/7.68.0
> Accept: */*
> Authorization: OWL eyJh...Bh7g
>
< HTTP/1.1 200 OK
< Server: OWL/1.00
< Date: Mon, 15 May 2023 15:19:23 GMT
< Content-Length: 161
< Content-Type: application/json;charset=UTF-8
<
[
  {
    "id": 2,
    "name": "Administrator",
    "role": "Project's Administrator",
    "username": "admin"
  }
]

GET /api/admin/realm

Gets list of all existing realms

# curl -v -H "Authorization: OWL eyJh...Bh7g" \
  https://owl.localhost:8695/api/admin/realm

> GET /api/admin/realm HTTP/1.1
> Host: owl.localhost:8695
> User-Agent: curl/7.68.0
> Accept: */*
> Authorization: OWL eyJh...Bh7g
>
< HTTP/1.1 200 OK
< Content-Type: application/json;charset=UTF-8
< Server: OWL/1.00
< Content-Length: 281
< Date: Mon, 15 May 2023 15:40:09 GMT
<
[
  {
    "description": "This is restricted zone for test only",
    "id": 13,
    "realm": "Restricted zone",
    "realmname": "MagicalForest",
    "satisfy": "Any"
  }
]

POST /api/admin/realm

Adds new realm

# curl -v -H "Authorization: OWL eyJh...ISuA" \
  -X POST -d '{
    "realmname": "MagicalForest",
    "realm": "Restricted zone",
    "satisfy": "Any",
    "description": "This is restricted zone for test only",
    "requirements": [1],
    "provider1": "User/Group",
    "entity1": "Group",
    "op1": "eq",
    "value1": "user",
    "routes": [
      "Stump"
    ]
  }' \
  https://owl.localhost:8695/api/admin/realm

> POST /api/admin/realm HTTP/1.1
> Host: owl.localhost:8695
> User-Agent: curl/7.68.0
> Accept: */*
> Authorization: OWL eyJh...ISuA
> Content-Length: 360
> Content-Type: application/x-www-form-urlencoded
>
< HTTP/1.1 200 OK
< Content-Length: 147
< Content-Type: application/json;charset=UTF-8
< Date: Mon, 15 May 2023 09:17:39 GMT
< Server: OWL/1.00
<
{
  "description": "This is restricted zone for test only",
  "id": 13,
  "realm": "Restricted zone",
  "realmname": "MagicalForest",
  "satisfy": "Any",
  "status": true
}

GET /api/admin/realm/REALMNAME

Gets realm's data by realmname

# curl -v -H "Authorization: OWL eyJh...Bh7g" \
  https://owl.localhost:8695/api/admin/realm/MagicalForest

> GET /api/admin/realm/MagicalForest HTTP/1.1
> Host: owl.localhost:8695
> User-Agent: curl/7.68.0
> Accept: */*
> Authorization: OWL eyJh...Bh7g
>
< HTTP/1.1 200 OK
< Server: OWL/1.00
< Content-Type: application/json;charset=UTF-8
< Date: Mon, 15 May 2023 15:42:05 GMT
< Content-Length: 149
<
{
  "description": "This is restricted zone for test only",
  "id": 13,
  "realm": "Restricted zone",
  "realmname": "MagicalForest",
  "satisfy": "Any",
  "status":true
}

PUT /api/admin/realm/REALMNAME

Sets realm's data

curl -v -H "Authorization: OWL eyJh...Bh7g" \
  -X PUT -d '{
    "id": 13,
    "realmname": "MagicalForest",
    "realm": "Restricted zone",
    "satisfy": "Any",
    "description": "This is restricted zone for test only 2",
    "requirements": [1],
    "provider1": "User/Group",
    "entity1": "Group",
    "op1": "eq",
    "value1": "user",
    "routes": [
      "Stump"
    ]
  }' \
  https://owl.localhost:8695/api/admin/realm/MagicalForest

> PUT /api/admin/realm/MagicalForest HTTP/1.1
> Host: owl.localhost:8695
> User-Agent: curl/7.68.0
> Accept: */*
> Authorization: OWL eyJh...ISuA
> Content-Length: 380
> Content-Type: application/x-www-form-urlencoded
>
< HTTP/1.1 200 OK
< Date: Mon, 15 May 2023 09:23:12 GMT
< Content-Type: application/json;charset=UTF-8
< Content-Length: 149
< Server: OWL/1.00
<
{
  "description": "This is restricted zone for test only 2",
  "id": 13,
  "realm": "Restricted zone",
  "realmname": "MagicalForest",
  "satisfy": "Any",
  "status": true
}

DELETE /api/admin/realm/REALMNAME

Delete realm by realmname

# curl -v -X DELETE -H "Authorization: OWL eyJh...Bh7g" \
  https://owl.localhost:8695/api/admin/realm/MagicalForest

> DELETE /api/admin/realm/MagicalForest HTTP/1.1
> Host: owl.localhost:8695
> User-Agent: curl/7.68.0
> Accept: */*
> Authorization: OWL eyJh...Bh7g
>
< HTTP/1.1 200 OK
< Server: OWL/1.00
< Date: Mon, 15 May 2023 15:51:02 GMT
< Content-Length: 30
< Content-Type: application/json;charset=UTF-8
<
{
  "code": "E0000",
  "status": true
}

GET /api/admin/requirement

GET /api/admin/requirement?realmname=<REALMNAME>

Get list of realm's requirement

# curl -v -H "Authorization: OWL eyJh...Bh7g" \
  https://owl.localhost:8695/api/admin/requirement?realmname=Default

> GET /api/admin/requirement?realmname=Default HTTP/1.1
> Host: owl.localhost:8695
> User-Agent: curl/7.68.0
> Accept: */*
> Authorization: OWL eyJh...Bh7g
>
< HTTP/1.1 200 OK
< Server: OWL/1.00
< Content-Type: application/json;charset=UTF-8
< Content-Length: 302
< Date: Mon, 15 May 2023 15:58:04 GMT
<
[
  {
    "entity": "Group",
    "id": 113,
    "op": "eq",
    "provider": "User\/Group",
    "realmname": "Default",
    "value": "admin"
  }
]

GET /api/admin/route

Get list of all existing routes

# curl -v -H "Authorization: OWL eyJh...Bh7g" \
  https://owl.localhost:8695/api/admin/route

> GET /api/admin/route HTTP/1.1
> Host: owl.localhost:8695
> User-Agent: curl/7.68.0
> Accept: */*
> Authorization: OWL eyJh...Bh7g
>
< HTTP/1.1 200 OK
< Date: Mon, 15 May 2023 16:07:18 GMT
< Content-Length: 783
< Server: OWL/1.00
< Content-Type: application/json;charset=UTF-8
<
[
  {
    "base": "https://owl.localhost:8695",
    "id": 14,
    "is_sysroute": 0,
    "method": "ANY",
    "path": "/api/admin/*",
    "realmname": "Default",
    "routename": "AdminAPI",
    "url": "https://owl.localhost:8695/api/admin/*"
  }
]

POST /api/admin/route

Adds route's data

# curl -v -H "Authorization: OWL eyJh...ISuA" \
  -X POST -d '{
    "realmname": "Default",
    "routename": "AdminAPI",
    "method": "ANY",
    "url": "https://owl.localhost:8695/api/admin/*"
  }' \
  https://owl.localhost:8695/api/admin/route

> POST /api/admin/route HTTP/1.1
> Host: owl.localhost:8695
> User-Agent: curl/7.68.0
> Accept: */*
> Authorization: OWL eyJh...ISuA
> Content-Length: 156
> Content-Type: application/x-www-form-urlencoded
>
< HTTP/1.1 200 OK
< Content-Length: 199
< Content-Type: application/json;charset=UTF-8
< Date: Sun, 07 May 2023 13:14:59 GMT
< Server: OWL/1.00
<
{
  base": "https://owl.localhost:8695",
  "id":20,
  "method":"ANY",
  "path":"/api/admin/*",
  "realmname":"Default",
  "routename":"AdminAPI",
  "status":true,
  "url":"https://owl.localhost:8695/api/admin/*"
}

GET /api/admin/route/ROUTENAME

Get route's data by routename

# curl -v -H "Authorization: OWL eyJh...Bh7g" \
  https://owl.localhost:8695/api/admin/route/AdminAPI

> GET /api/admin/route/AdminAPI HTTP/1.1
> Host: owl.localhost:8695
> User-Agent: curl/7.68.0
> Accept: */*
> Authorization: OWL eyJh...Bh7g
>
< HTTP/1.1 200 OK
< Content-Length: 214
< Date: Mon, 15 May 2023 16:09:28 GMT
< Content-Type: application/json;charset=UTF-8
< Server: OWL/1.00
<
{
  "base": "https://owl.localhost:8695",
  "id": 14,
  "is_sysroute": 0,
  "method": "ANY",
  "path": "/api/admin/*",
  "realmname": "Default",
  "routename": "AdminAPI",
  "status": true,
  "url": "https://owl.localhost:8695/api/admin/*"
}

PUT /api/admin/route/ROUTENAME

Sets route's data

# curl -v -H "Authorization: OWL eyJh...ISuA" \
  -X PUT -d '{
    "id": 20,
    "realmname": "Default",
    "method": "ANY",
    "url": "https://localhost:8695/api/admin/*"
  }' \
  https://owl.localhost:8695/api/admin/route/AdminAPI

> PUT /api/admin/route/AdminAPI HTTP/1.1
> Host: owl.localhost:8695
> User-Agent: curl/7.68.0
> Accept: */*
> Authorization: OWL eyJh...ISuA
> Content-Length: 136
> Content-Type: application/x-www-form-urlencoded
>
< HTTP/1.1 200 OK
< Content-Type: application/json;charset=UTF-8
< Content-Length: 191
< Server: OWL/1.00
< Date: Sun, 07 May 2023 13:22:01 GMT
<
{
  "base":"https://localhost:8695",
  "id":20,
  "method":"ANY",
  "path":"/api/admin/*",
  "realmname":"Default",
  "routename":"AdminAPI",
  "status":true,
  "url":"https://localhost:8695/api/admin/*"
}

DELETE /api/admin/route/ROUTENAME

Delete route by routename

# curl -v -X DELETE -H "Authorization: OWL eyJh...Bh7g" \
  https://owl.localhost:8695/api/admin/route/api-backups

> DELETE /api/admin/route/api-backups HTTP/1.1
> Host: owl.localhost:8695
> User-Agent: curl/7.68.0
> Accept: */*
> Authorization: OWL eyJh...Bh7g
>
< HTTP/1.1 200 OK
< Server: OWL/1.00
< Content-Type: application/json;charset=UTF-8
< Content-Length: 30
< Date: Mon, 15 May 2023 16:55:39 GMT
<
{
  "code": "E0000",
  "status": true
}

GET /api/admin/search/route

GET /api/admin/search/route?text=<FRAGMENT>

Performs search route by fragment

# curl -v -H "Authorization: OWL eyJh...Bh7g" \
  https://owl.localhost:8695/api/admin/search/route?text=a

> GET /api/admin/search/route?text=a HTTP/1.1
> Host: owl.localhost:8695
> User-Agent: curl/7.68.0
> Accept: */*
> Authorization: OWL eyJh...Bh7g
>
< HTTP/1.1 200 OK
< Server: OWL/1.00
< Content-Length: 592
< Content-Type: application/json;charset=UTF-8
< Date: Mon, 15 May 2023 16:17:50 GMT
<
[
  {
    "base": "https://owl.localhost:8695",
    "id": 14,
    "is_sysroute": 0,
    "method": "ANY",
    "path": "/api/admin/*",
    "realmname": "Default",
    "routename": "AdminAPI",
    "url": "https://owl.localhost:8695/api/admin/*"
  }
]

GET /api/admin/search/user

GET /api/admin/search/user?text=<FRAGMENT>

Performs search user by fragment

# curl -v -H "Authorization: OWL eyJh...Bh7g" \
  https://owl.localhost:8695/api/admin/search/user?text=te

> GET /api/admin/search/user?text=te HTTP/1.1
> Host: owl.localhost:8695
> User-Agent: curl/7.68.0
> Accept: */*
> Authorization: OWL eyJh...Bh7g
>
< HTTP/1.1 200 OK
< Content-Length: 66
< Date: Mon, 15 May 2023 12:21:29 GMT
< Server: OWL/1.00
< Content-Type: application/json;charset=UTF-8
<
[
  {
    "id": 3,
    "name": "Test User",
    "role": "Test user",
    "username": "test"
  }
]

GET /api/admin/settings

Gets settings

# curl -v -H "Authorization: OWL eyJh...r3bo" \
  https://owl.localhost:8695/api/admin/settings

> GET /api/admin/settings HTTP/1.1
> Host: owl.localhost:8695
> User-Agent: curl/7.68.0
> Accept: */*
> Authorization: OWL eyJh...r3bo
>
< HTTP/1.1 200 OK
< Content-Type: application/json;charset=UTF-8
< Date: Sat, 29 Apr 2023 04:56:56 GMT
< Content-Length: 30
< Server: OWL/1.00
<
{
  "message": "Ok",
  "status": true
}

GET /api/admin/sysroute

Returns list of all existing system routes

# curl -v -H "Authorization: OWL eyJh...Bh7g" \
  https://owl.localhost:8695/api/admin/sysroute

> GET /api/admin/sysroute HTTP/1.1
> Host: owl.localhost:8695
> User-Agent: curl/7.68.0
> Accept: */*
> Authorization: OWL eyJh...Bh7g
>
< HTTP/1.1 200 OK
< Content-Type: application/json;charset=UTF-8
< Date: Mon, 15 May 2023 16:24:11 GMT
< Content-Length: 7860
< Server: OWL/1.00
<
[
  {
    "method": "GET",
    "route": "/api",
    "routename": "api",
    "url": "https://owl.localhost:8695/api"
  }
]

POST /api/admin/sysroute

Adds system route to route list

# curl -v -H "Authorization: OWL eyJh...Bh7g" \
  -X POST -d '{
    "routes": ["api-checkits", "api-backups"]
  }' \
  https://owl.localhost:8695/api/admin/sysroute

> POST /api/admin/sysroute HTTP/1.1
> Host: owl.localhost:8695
> User-Agent: curl/7.68.0
> Accept: */*
> Authorization: OWL eyJh...Bh7g
> Content-Length: 59
> Content-Type: application/x-www-form-urlencoded
>
< HTTP/1.1 200 OK
< Date: Mon, 15 May 2023 16:43:20 GMT
< Server: OWL/1.00
< Content-Type: application/json;charset=UTF-8
< Content-Length: 30
<
{
  "code": "E0000",
  "status": true
}

GET /api/admin/user

Gets list of all existing users

# curl -v -H "Authorization: OWL eyJh...Bh7g" \
  https://owl.localhost:8695/api/admin/user

> GET /api/admin/user HTTP/1.1
> Host: owl.localhost:8695
> User-Agent: curl/7.68.0
> Accept: */*
> Authorization: OWL eyJh...Bh7g
>
< HTTP/1.1 200 OK
< Server: OWL/1.00
< Date: Mon, 15 May 2023 11:53:55 GMT
< Content-Length: 10517
< Content-Type: application/json;charset=UTF-8
<
[
  {
    "algorithm": "SHA256",
    "attributes": "",
    "comment": "Test user for internal testing only",
    "created": 1678741533,
    "email": "test@owl.localhost",
    "flags": 0,
    "id": 3,
    "name": "Test User",
    "not_after": null,
    "not_before": 1678741533,
    "password": "9f86...0a08",
    "private_key": "",
    "public_key": "",
    "role": "Test user",
    "username": "test"
  }
]

POST /api/admin/user

Adds user's data

# curl -v -H "Authorization: OWL eyJh...j1rM" \
  -X POST -d '{
    "username": "bob",
    "name": "Bob",
    "email": "bob@example.com",
    "password": "bob",
    "algorithm": "SHA256",
    "role": "Test user",
    "flags": 0,
    "not_after": null,
    "public_key": null,
    "private_key": null,
    "attributes": null,
    "comment": "Test user for unit testing only"
  }' \
  https://owl.localhost:8695/api/admin/user

> POST /api/admin/user HTTP/1.1
> Host: owl.localhost:8695
> User-Agent: curl/7.68.0
> Accept: */*
> Authorization: OWL eyJh...j1rM
> Content-Length: 367
> Content-Type: application/x-www-form-urlencoded
>
< HTTP/1.1 200 OK
< Date: Fri, 12 May 2023 12:15:50 GMT
< Content-Type: application/json;charset=UTF-8
< Content-Length: 1530
< Server: OWL/1.00
<
{
  "algorithm": "SHA256",
  "attributes": "",
  "comment": "Test user for unit testing only",
  "created": 1683893750,
  "email": "bob@example.com",
  "flags": 0,
  "id": 13,
  "name": "Bob",
  "not_after": 0,
  "not_before": 1683893750,
  "password": "81b6...8ce9",
  "private_key": "-----BEGIN RSA PRIVATE KEY-----...",
  "public_key": "-----BEGIN RSA PUBLIC KEY-----...",
  "role": "Test user",
  "status": true,
  "username": "bob"
}

GET /api/admin/user/USERNAME

GET /api/admin/user/<USERNAME>
GET /api/admin/user/?username=<USERNAME>

Gets user's data by username

# curl -v -H "Authorization: OWL eyJh...Bh7g" \
  https://owl.localhost:8695/api/admin/user/test

> GET /api/admin/user/test HTTP/1.1
> Host: owl.localhost:8695
> User-Agent: curl/7.68.0
> Accept: */*
> Authorization: OWL eyJh...Bh7g
>
< HTTP/1.1 200 OK
< Server: OWL/1.00
< Content-Length: 1544
< Content-Type: application/json;charset=UTF-8
< Date: Mon, 15 May 2023 12:03:36 GMT
<
{
  "algorithm": "SHA256",
  "attributes": "",
  "comment": "Test user for internal testing only",
  "created": 1678741533,
  "email": "test@owl.localhost",
  "flags": 0,
  "id": 3,
  "name": "Test User",
  "not_after": null,
  "not_before": 1678741533,
  "password": "9f86...0a08",
  "private_key": "",
  "public_key": "",
  "role": "Test user",
  "status": true,
  "username": "test"
}

PUT /api/admin/user/USERNAME

Sets user's data

# curl -v -H "Authorization: OWL eyJh...j1rM" \
  -X PUT -d '{
    "id": 13,
    "username": "bob",
    "name": "Bob Bob",
    "email": "bob@example.com",
    "password": "bob",
    "algorithm": "SHA256",
    "role": "Test user",
    "flags": 0,
    "not_after": null,
    "public_key": null,
    "private_key": null,
    "attributes": null,
    "comment": "Test user for unit testing only"
  }' \
  https://owl.localhost:8695/api/admin/user/bob

> PUT /api/admin/user/bob HTTP/1.1
> Host: owl.localhost:8695
> User-Agent: curl/7.68.0
> Accept: */*
> Authorization: OWL eyJh...j1rM
> Content-Length: 389
> Content-Type: application/x-www-form-urlencoded
>
< HTTP/1.1 200 OK
< Date: Fri, 12 May 2023 12:21:07 GMT
< Content-Type: application/json;charset=UTF-8
< Server: OWL/1.00
< Content-Length: 1536
<
{
  "algorithm": "SHA256",
  "attributes": "",
  "comment": "Test user for unit testing only",
  "created": 1683893750,
  "email": "bob@example.com",
  "flags": 0,
  "id": 13,
  "name": "Bob Bob",
  "not_after": 0,
  "not_before": 1683894066,
  "password": "81b6...8ce9",
  "private_key": "-----BEGIN RSA PRIVATE KEY-----...",
  "public_key": "-----BEGIN RSA PUBLIC KEY-----...",
  "role": "Test user",
  "status": true,
  "username": "bob"
}

DELETE /api/admin/user/USERNAME

Delete user by username

# curl -v -X DELETE -H "Authorization: OWL eyJh...Bh7g" \
  https://owl.localhost:8695/api/admin/user/bob.bob

> DELETE /api/admin/user/bob.bob HTTP/1.1
> Host: owl.localhost:8695
> User-Agent: curl/7.68.0
> Accept: */*
> Authorization: OWL eyJh...Bh7g
>
< HTTP/1.1 200 OK
< Content-Length: 30
< Date: Mon, 15 May 2023 12:11:42 GMT
< Content-Type: application/json;charset=UTF-8
< Server: OWL/1.00
<
{
  "code": "E0000",
  "status": true
}

GET /api/admin/user/USERNAME/groups

Returns list user's groups

# curl -v -H "Authorization: OWL eyJh...Bh7g" \
  https://owl.localhost:8695/api/admin/user/test/groups

> GET /api/admin/user/test/groups HTTP/1.1
> Host: owl.localhost:8695
> User-Agent: curl/7.68.0
> Accept: */*
> Authorization: OWL eyJh...Bh7g
>
< HTTP/1.1 200 OK
< Date: Mon, 15 May 2023 12:27:43 GMT
< Server: OWL/1.00
< Content-Length: 64
< Content-Type: application/json;charset=UTF-8
<
[
  {
    "description": "Unprivileged users",
    "groupname": "user",
    "id": 2
  }
]

PUT /api/admin/user/USERNAME/passwd

Set password for user

# curl -v -H "Authorization: OWL eyJh...Bh7g" \
  -X PUT -d '{"password": "test"}' \
  https://owl.localhost:8695/api/admin/user/test/passwd

> PUT /api/admin/user/test/passwd HTTP/1.1
> Host: owl.localhost:8695
> User-Agent: curl/7.68.0
> Accept: */*
> Authorization: OWL eyJh...Bh7g
> Content-Length: 20
> Content-Type: application/x-www-form-urlencoded
>
< HTTP/1.1 200 OK
< Content-Length: 30
< Date: Mon, 15 May 2023 12:34:18 GMT
< Content-Type: application/json;charset=UTF-8
< Server: OWL/1.00
<
{
  "code": "E0000",
  "status": true
}

ERROR CODES

The list of Admin Suffit API error codes

 API   | HTTP  | DESCRIPTION
-------+-------+-------------------------------------------------
 E1200   [400]   Incorrect username
 E1201   [404]   User not found
 E1202   [400]   Incorrect password
 E1203   [400]   Incorrect search text
 E1204   [400]   Incorrect groupname
 E1205   [400]   Incorrect email address
 E1206   [400]   Incorrect full name
 E1207   [400]   Incorrect digest algorithm
 E1208   [400]   Incorrect role
 E1209   [400]   Incorrect flags
 E1210   [404]   Group not found
 E1211   [400]   Incorrect realmname
 E1212   [400]   Incorrect type of requirements list. Array expected
 E1213   [400]   Incorrect type of routes list. Array expected
 E1214   [404]   Realm not found
 E1215   [500]   Can't generate RSA keys (user_set)
 E1216   [500]   Can't set user data to database (user_set)
 E1217   [500]   Can't get data from database by username (user_set)
 E1218   [500]   Can't get data from database by groupname (group_set)
 E1219   [500]   Can't set realm data
 E1220   [500]   Can't group delete (group_del)
 E1221   [500]   Can't set group data (group_set)
 E1222   [500]   Can't user delete (user_del)
 E1223   [500]   Can't set password (user_passwd)
 E1224   [500]   Can't group enroll (group_enroll)
 E1225   [500]   Can't get data from database by realmname (realm_set)
 E1226   [500]   Can't realm delete (realm_del)
 E1227   [400]   Incorrect routename
 E1228   [404]   Route not found
 E1229   [400]   Incorrect URL
 E1230   [500]   Can't set route data (route_set)
 E1231   [500]   Can't get data from database by routename (route_set)
 E1232   [500]   Can't route delete (route_del)
 E1233   [500]   Can't route set (route_sysadd)
 E1234   [400]   Incorrect JWS algorithm (settings)
 E1235   [400]   Incorrect session expires value in seconds (settings)
 E1236   [400]   Incorrect token expires value in seconds (settings)
 E1237   [500]   Can't save meta parameter

* -- this code will be defined later on the interface side

See also list of common Suffit API error codes in "ERROR CODES" in WWW::Suffit::API

HISTORY

See Changes file

TO DO

See TODO file

SEE ALSO

Mojolicious, WWW::Suffit, WWW::Suffit::Server, WWW::Suffit::API

AUTHOR

Serż Minus (Sergey Lepenkov) https://www.serzik.com <abalama@cpan.org>

COPYRIGHT

Copyright (C) 1998-2024 D&D Corporation. All Rights Reserved

LICENSE

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See LICENSE file and https://dev.perl.org/licenses/