DS Server

POST /admin/securityprofiles

Endpoint

POST https://example.com/admin/securityprofiles

Description

Adds a new security profile.

Examples

The following example adds a new security profile with the given information. allowClientCredentialsGrantType belongs to the security profile, not to clientCredentials: inside clientCredentials, DS Server ignores it.

# Request:
curl --location --request POST 'https://trial.dsserver.io/admin/securityprofiles' \
    --header 'Authorization: Basic YWRtaW46YWRtaW5hZG1pbg==' \
    --header 'Content-Type: application/json' \
    --data-raw '{
            "name": "My security profile",
            "allowClientCredentialsGrantType": false,
            "clientCredentials": {
                "id": "GHGGHGD6766",
                "secret": "GHZUZW441543HJUKUU",
                "authorizedRedirectUris": [
                    "https://trial.dsserver.io/oauth/redirect"
                ]
            }
        }'

# Result:
7

The following example adds a security profile with a name only. DS Server generates the client ID and the client secret, which GET /admin/securityprofiles/{id} returns.

# Request:
curl --location --request POST 'https://trial.dsserver.io/admin/securityprofiles' \
    --header 'Authorization: Basic YWRtaW46YWRtaW5hZG1pbg==' \
    --header 'Content-Type: application/json' \
    --data-raw '{ "name": "My security profile" }'

# Result:
8

Authorization

This endpoint supports the Basic authorization method:

Basic

Header fieldDescription
AuthorizationThe username "admin" and your admin password are combined into a string separated by a colon, e.g.: admin:password. The resulting string is encoded using the RFC2045-MIME variant of Base64, except not limited to 76 char/line. The authorization method and a space i.e. "Basic " is then put before the encoded string. For example: Authorization: Basic QWxhZGRpbjpPcGVuU2VzYW1l

Request Payload

TypeValue
SecurityProfileThe SecurityProfile object contains information about the security profile.

SecurityProfile

NameTypeValueOptional
nameStringA user friendly name for the security profile.yes
allowClientCredentialsGrantTypeBooleanSpecifies whether the client credentials grant type is activated or not.yes
expiryDateDateTimeAn expiry date for the security profile, for example "2027-06-30T00:00:00". A date without a time zone offset is taken as the local time of the server. When omitted, the security profile doesn't expire.yes
clientCredentialsClientCredentialsThe ClientCredentials object contains OAuth client credentials for the security profile. When omitted, DS Server generates a client ID and a client secret.yes

ClientCredentials

NameTypeValueOptional
idStringThe client ID of the security profile. When omitted, DS Server generates one.yes
secretStringThe client secret of the security profile. When omitted, DS Server generates one.yes
authorizedRedirectUrisString[]An array of authorized redirect URIs.yes

Success Response

StatusDescription
200On success, the HTTP status code in the response header is 200 (OK). The return value is the new ID of the added security profile.

Error Response

StatusDescription
401A 401 (Unauthorized) is returned, if the user is not authorized.
400A 400 (Bad Request) is returned, if the given client ID exists already. The body is the JSON string "A profile with the given client ID already exists."
400A 400 (Bad Request) is returned, if the body is missing or isn't valid JSON. The body is the JSON string "Requst body cannot be empty." (spelled this way by DS Server).
415A 415 (Unsupported Media Type) is returned, if the Content-Type header isn't application/json.