You can add a user using the CLI tool, REST API or the PPaaS Console as shown below:
Adding a user via the CLI
Overview
CLI command | add-user |
Description | Add a new user. |
Command format | add-user -u <USERNAME> -p <PASSWORD> -r <ROLE_NAME> -f <FIRST_NAME> -l <LAST_NAME> -e <EMAIL> -pr <PROFILE_NAME> |
Parameter definition
Short option | Long option | Description | Required | Example value |
---|---|---|---|---|
-u |
| Username given to the user. | Yes | kim |
-p |
| User's password. | Yes | admin123 |
-r | --role-name | Role assigned to the user. When adding a user in Stratos, only the following values are allowed for the property "role":
| Yes | admin |
-f |
| User's first name. | Yes | Kim |
-l |
| User's last name. | Yes | Myers |
-e |
| User's email address. | Yes | [email protected] |
-pr | --profile-name | User's profile name. | Yes | dev |
Example
Add a user with the username: kim, name: Kim Myers, password: admin123, email: [email protected], role: admin and profile: dev.
add-user -u kim -p admin123 -r admin -f Kim -l Myers -e [email protected] -pr dev
Sample output
User added successfully: [user] kim
Adding a user via the REST API
Overview
Description | Add a user. |
Resource Path | /users |
HTTP Method | POST |
Request/Response Format | application/json |
Command format | curl -X POST -H "Content-Type: application/json" -d @'<JSON_PAYLOAD>' -k -v -u <USERNAME>:<PASSWORD> https://<PRIVATE_PAAS_HOST>:<PRIVATE_PAAS_HTTPS_PORT>/api/users
|
Example
Add the user defined in the user.json
file.
curl -X POST -H "Content-Type: application/json" -d @'user.json' -k -v -u admin:admin https://localhost:9443/api/users
Sample output
> POST /api/users HTTP/1.1 > Host: localhost:9443 > Authorization: Basic YWRtaW46YWRtaW4= > User-Agent: curl/7.43.0 > Accept: */* > Content-Type: application/json > Content-Length: 136 > < HTTP/1.1 201 Created < Date: Tue, 13 Oct 2015 17:33:27 GMT < Location: https://localhost:9443/api/users/kim < Content-Type: application/json < Transfer-Encoding: chunked < Server: WSO2 Carbon Server < {"status":"success","message":"User added successfully: [user] kim"}
You will come across the following HTTP status codes while adding a user:
HTTP status code | 201, 400, 409, 500 See the descriptions of the HTTP status codes here. |
Location header URL |
|
Adding a user via the PPaaS Console
Follow the instructions below to add a user:
Only users who belong to the admin user role are allowed to add users in PPaaS.
- Click Users on the home page.
- Click Manage Users.
- Click Add New Users.
- Enter the required details. For property definitions, see User Resource Definition.
- Click SAVE USER.
Sample user JSON
{ "userName": "kim", "credential": "kim12345", "role": "admin", "firstName": "Frank", "lastName": "Myers", "email": "[email protected]" }