Login: P4 Code Review login
Get P4 Code Review user session details
Summary
Get P4 Code Review session details of a user.
GET /api/v11/session
Description
Get the P4 Code Review session details of a user.
Example usage
Get the session details for bruno:
curl -u "bruno:<ticket>" https://my-swarm-host/api/v11/session
P4 Code Review responds with:
HTTP/1.1 200 OK
{
"error": null,
"messages": [{
"code": "user-login-successful",
"text": "User logged in."
}],
"data" : {
"user": {
"User": "bruno",
"Type": "standard",
"Email": "bruno@swarm.local",
"FullName": "bruno",
"isAdmin": true,
"isSuper": false
}
}
}
If a request fails
<error code>:
-
401 Incorrect or missing credentials
-
403 Unauthorized
HTTP/1.1 <response error code>
{
"error": <error code>,
"messages": [{
"code" : "<code string>",
"text" : "<error message>"
}],
"data" : null
}
Create a new P4 Code Review user session
Summary
Create a new P4 Code Review user session.
POST /api/v11/session
Description
Create a new P4 Code Review user session.
When creating a new P4 Code Review user session with a valid sso user, you must call Get SSO authentication URL API endpoint to get the navigation URL. This navigation URL must be opened in a web browser to login the user. Once the user is logged in, a login successful message for this user is displayed in the Create a new P4 Code Review user session API endpoint.
Parameters
| Parameter | Description | Type | Parameter Type | Required |
|---|---|---|---|---|
|
method |
Login service type identifier. The default value is basic.
|
string |
body |
No |
|
username |
Username |
string |
body |
Yes |
|
password |
User ticket (recommended) or password If your P4 Server is set to security level 3 or higher, you must use a ticket value for the password parameter. |
string |
body |
Yes |
|
remember |
|
Boolean |
body |
No |
Example usage
Create a new P4 Code Review session for bruno using the basic method
curl -X POST -H "Content-Type: application/json" -d "@mybodyfilename.txt" "https://my-swarm-host/api/v11/session"
The "mybodyfilename.txt" file contains the login details for bruno:
{
"method":"basic",
"username": "bruno",
"password": "A1AFB97F0F218DF7B122F229C7DECA46",
"remember": false
}
P4 Code Review responds with:
HTTP/1.1 200 OK
{
"error": null,
"messages": [
{
"code": "user-login-successful",
"text": "User logged in."
}
],
"data" : {
"user": {
"User": "bruno",
"Type": "standard",
"Email": "bruno@swarm.local",
"FullName": "bruno",
"isAdmin": true,
"isSuper": false
}
}
}
Create a new P4 Code Review session for bruno using the sso method:
curl -X POST -H "Content-Type: application/json" -d "@mybodyfilename.txt" "https://my-swarm-host/api/v11/session"
The "mybodyfilename.txt" file contains the login details for bruno:
{
"method":"sso",
"username": "bruno",
"remember": false
}
P4 Code Review responds with:
HTTP/1.1 200 OK
{
"error": null,
"messages": [
{
"code": "user-login-successful",
"text": "User logged in."
}
],
"data" : {
"user": {
"User": "bruno",
"Type": "standard",
"Email": "bruno@swarm.local",
"FullName": "bruno",
"isAdmin": true,
"isSuper": false
}
}
}
If a request fails
<error code>:
-
401 Incorrect or missing credentials
-
403 Unauthorized
HTTP/1.1 <response error code>
{
"error": <error code>,
"messages": [{
"code" : "<code string>",
"text" : "<error message>"
}],
"data" : null
}
Get SSO authentication URL
Summary
Get P4 Code Review SSO authentication URL.
GET /api/v11/get-sso-auth-url
Description
Get P4 Code Review SSO authentication URL.
Example usage
Get P4 Code Review SSO authentication URL for bruno.
curl -u "bruno:<ticket>" https://my-swarm-host/api/v11/get-sso-auth-url
P4 Code Review responds with:
HTTP/1.1 200 OK
{
"data": {
"url": "https://10.153.120.29:3000/oidc/login/01HR6QMK0MPC5J506C2WG5ZZ0R?instanceId=none",
"isValid": true,
"errors": null
},
"messages": null,
"error": null
}
If a request fails
<error code>:
-
401 Incorrect or missing credentials
-
403 Unauthorized
HTTP/1.1 <response error code>
{
"error": <error code>,
"messages": [{
"code" : "<code string>",
"text" : "<error message>"
}],
"data" : null
}
Login to P4 Code Review with SAML
P4 Code Review now supports P4 AS (HAS) as a Single Sign-On (SSO) provider. This helps to simplify configuration and create a more robust SSO solution.
Summary
Login to P4 Code Review with SAML
POST /api/v11/saml/login
Description
Login to P4 Code Review with SAML.
Parameters
| Parameter | Description | Type | Parameter Type | Required |
|---|---|---|---|---|
|
method |
Login service type identifier is set to use saml configuration to login to P4 Code Review. |
string |
body |
No |
|
redirect |
Options are:
|
string |
query |
No |
Example usage
Login in to P4 Code Review with SAML
Login in to P4 Code Review with SAML.
curl -X POST -u "super:<ticket>" "https://myswarm-url/api/v11/saml/login"
On successful login P4 Code Review responds with:
HTTP/1.1 200 OK
{
"error": null,
"messages": [],
"data" : {
"isValid": "true",
"url": "<url to redirect to>"
}
}
Login in to P4 Code Review with SAML and redirect=false
Login in to P4 Code Review with SAML and redirect=false
curl -X POST -u "super:<ticket>" "https://myswarm-url/api/v11/saml/login?redirect=false"
On successful login P4 Code Review responds with:
HTTP/1.1 200 OK
{
"error": null,
"messages": [],
"data" : {
"isValid": "true"
}
}
If a request fails
<error code>:
400 Error occurred with the SAML login
HTTP/1.1 <response error code>
{
"error": <error code>,
"messages": [{
"code" : "<code string>",
"text" : "<error message>"
}],
"data" : null
}
Logout of a P4 Code Review user session
Summary
Logout of a P4 Code Review user session.
DELETE /api/v11/session
Description
Logout of a P4 Code Review user session.
Example usage
Logout bruno of a P4 Code Review user session.
curl -X DELETE -u "bruno:<ticket>" https://my-swarm-host/api/v11/session
P4 Code Review responds with:
HTTP/1.1 200 OK
{
"error": null,
"messages": [
{
"code": "user-logged-out",
"text": "Successful Logout."
}
],
"data": {
"url": "/"
}
}
If a request fails
<error code>:
-
401 Incorrect or missing credentials
-
403 Unauthorized
HTTP/1.1 <response error code>
{
"error": <error code>,
"messages": [{
"code" : "<code string>",
"text" : "<error message>"
}],
"data" : null
}