Skip to content

Authentification API

Robin Lafontaine edited this page Feb 13, 2025 · 13 revisions

API Documentation

This documentation provides details about all available endpoints. Endpoints are grouped by their functionality.


Authentication Endpoints

POST /authenticate (authenticate user and obtain JWT token)

Parameters

Name Type Data Type Description
email required string The user's email address
password required string The user's password

Responses

HTTP Code Content-Type Response
200 application/json {"token": "jwt_token_string"}
401 string User does not exist or Invalid credentials provided
500 string An error occurred during authentication

Example cURL

curl -L -X POST 'http://localhost/v1/authenticate' \
-H 'Content-Type: application/json' \
--data-raw '{"email": "user@example.com", "password": "password"}'

User Management Endpoints

POST /change-password (update the user's password associated with the JWT)

Parameters

The request body should contain:

Name Type Data Type Description
currentPassword required string The user's current password
newPassword required string The new password that meets security criteria

Responses

HTTP Code Content-Type Response
200 string Password changed successfully
400 string New password does not meet security requirements
401 string Current password is incorrect
404 string User not found

Example cURL

curl -L -X POST 'http://localhost/v1/authenticate/change-password' \
-H 'Authorization: Bearer {JWT}' \
-H 'Content-Type: application/json' \
--data-raw '{"currentPassword": "currentPass", "newPassword": "NewPass123"}'
POST /reset-password?{email} (reset the requested user password)

Parameters

Name Type Data Type Description
email required string The specific user email

Responses

HTTP Code Content-Type Response
200 string Password reset successfully
404 string User not found
500 string Error sending email

Example cURL

curl -L -X POST 'http://localhost/v1/authenticate/reset-password?email=user@example.com' \
-H 'Authorization: Bearer {JWT}'
GET /need-change-password (return true if the user associated with the JWT needs to change his password, false otherwise)

Parameters

None

Responses

HTTP Code Content-Type Response
200 string True or False
404 string User not found

Example cURL

curl -L -X GET 'http://localhost/v1/authenticate/need-change-password' \
-H 'Authorization: Bearer {JWT}'
POST /delete-user?{email} (delete the requested user)

Allowed Role

ADMIN

Parameters

Name Type Data Type Description
email required string The specific user email

Responses

HTTP Code Content-Type Response
200 string User deleted successfully
404 string User not found

Example cURL

curl -L -X POST 'http://localhost/v1/authenticate/delete-user?email=user@example.com' \
-H 'Authorization: Bearer {JWT}'
GET /export-users (export users in csv file)

Allowed Role

ADMIN

Parameters

None

Responses

HTTP Code Content-Type Response
200 csv Users' info in CSV format
500 string Error exporting users: {error message}

Example cURL

curl -L -X GET 'http://localhost/v1/authenticate/export-users' \
-H 'Authorization: Bearer {JWT}'
POST /register (register a new user)

Allowed Role

ADMIN

Parameters

The request body should contain:

Name Type Data Type Description
firstName required string The first name of the new user
lastName required string The last name of the new user
email required string The email of the new user
position required string The position/job title of the new user
role required ADMIN or USER The role for the new user

Responses

HTTP Code Content-Type Response
200 string User registered successfully
409 string User already exists
500 string Error sending email

Example cURL

curl -L -X POST 'http://localhost/v1/authenticate/register' \
-H 'Authorization: Bearer {JWT}' \
-H 'Content-Type: application/json' \
--data-raw '{"firstName": "John", "lastName": "Doe", "email": "john.doe@example.com", "position": "Manager", "role": "ADMIN"}'
GET /get-user (return the user's infos associated with the JWT)

Parameters

None

Responses

HTTP Code Content-Type Response
200 application/json {"id": int, "firstName": "string", "lastName": "string", "email": "string", "position": "string", "role": "ADMIN" or "USER"}
404 string User not found

Example cURL

curl -L -X GET 'http://localhost/v1/authenticate/get-user' \
-H 'Authorization: Bearer {JWT}'
GET /get-all-users (retrieve all users in Gophish DTO format)

Allowed Role

ADMIN

Responses

HTTP Code Content-Type Response
200 application/json An array of user objects in Gophish DTO format. For example: [{"id": 1, "firstName": "John", "lastName": "Doe", "email": "john.doe@example.com", "position": "Manager", "role": "ADMIN"}, ...]

Example cURL

curl -L -X GET 'http://localhost/v1/get-all-users' \
-H 'Authorization: Bearer {JWT}'

Scan Endpoints

GET /my-scan (retrieve the authenticated user's scan result)

Allowed Roles

USER, ADMIN

Responses

HTTP Code Content-Type Response
200 application/json JSON representation of the scan result
404 string No scan result found for {email}

Example cURL

curl -L -X GET 'http://localhost/v1/my-scan' \
-H 'Authorization: Bearer {JWT}'
POST /admin/scan (retrieve scan result for a specified email)

Allowed Role

ADMIN

Parameters

Name Type Data Type Description
email required string The email address for which to retrieve the scan

Responses

HTTP Code Content-Type Response
200 application/json JSON representation of the scan result
400 string Email must be provided
404 string No scan result found for {email}

Example cURL

curl -L -X POST 'http://localhost/v1/admin/scan' \
-H 'Authorization: Bearer {JWT}' \
-H 'Content-Type: application/json' \
--data-raw '{"email": "user@example.com"}'
POST /my-scan/new (initiate a new scan for the authenticated user)

Allowed Roles

USER, ADMIN

Responses

HTTP Code Content-Type Response
Varies Varies Proxy response from the Spiderfoot API based on scan initiation

Example cURL

curl -L -X POST 'http://localhost/v1/my-scan/new' \
-H 'Authorization: Bearer {JWT}'
POST /admin/scan/new (initiate a new scan for a specified email)

Allowed Role

ADMIN

Parameters

Name Type Data Type Description
email required string The email address to initiate the scan for

Responses

HTTP Code Content-Type Response
Varies Varies Proxy response from the Spiderfoot API based on scan initiation
400 string Email must be provided

Example cURL

curl -L -X POST 'http://localhost/v1/admin/scan/new' \
-H 'Authorization: Bearer {JWT}' \
-H 'Content-Type: application/json' \
--data-raw '{"email": "user@example.com"}'

Clone this wiki locally