oidc-lite

Application

Overview

The ApplicationService is a crucial component of our NestJS application, responsible for managing application-related operations. It provides functionality for creating, updating, retrieving, and deleting applications, as well as managing their OAuth configurations and associated roles and scopes.

Sequence Diagram

Applications Sequence Diagram

Create Application

Request

Creates a new application with random ID.

POST /api/application

Creates a new application with given ID.

POST /api/application/:applicationId

Request Parameters

Request Headers

Request Body

Response

Response Codes

Code Description
200 The request was successful. The response will contain a JSON body.
400 The request was invalid and/or malformed. The response will contain an Errors JSON Object with the specific errors. This status will also be returned if a paid Auth Service license is required and is not present.
401 You did not supply a valid Authorization header. The header was omitted or your API key was not valid. The response will be empty.
500 There was an internal error. A stack trace is provided and logged in the Auth Service log files. The response will be empty.

Update An Application

Request

Updates an existing Application

PATCH /application/:applicationId

Request Parameters

Request Headers

Request Body

Response

Response Codes

Code Description
200 The request was successful. The response will contain a JSON body.
400 The request was invalid and/or malformed. The response will contain an Errors JSON Object with the specific errors. This status will also be returned if a paid Auth Service license is required and is not present.
401 You did not supply a valid Authorization header. The header was omitted or your API key was not valid. The response will be empty
404 The object you are trying to update doesn’t exist. The response will be empty.
500 There was an internal error. A stack trace is provided and logged in the Auth Service log files. The response will be empty.

Return Application

Request

Return All Applications

GET /application

Return An Application

GET /application/:applicationId

Request Headers

Request Parameters

Response

Response Codes

Code Description
200 The request was successful. The response will contain a JSON body.
400 The request was invalid and/or malformed. The response will contain an Errors JSON Object with the specific errors. This status will also be returned if a paid Auth Service license is required and is not present.
401 You did not supply a valid Authorization header. The header was omitted or your API key was not valid. The response will be empty
404 The object you are trying to update doesn’t exist. The response will be empty.
500 There was an internal error. A stack trace is provided and logged in the Auth Service log files. The response will be empty.

Delete Application

Request

Deletes an application (soft or hard delete).

DELETE /application/:applicationId

Request Headers

Request Parameters

Response

Response Codes

Code Description
200 The request was successful. The response will contain a JSON body.
400 The request was invalid and/or malformed. The response will contain an Errors JSON Object with the specific errors. This status will also be returned if a paid Auth Service license is required and is not present.
401 You did not supply a valid Authorization header. The header was omitted or your API key was not valid. The response will be empty
404 The object you are trying to update doesn’t exist. The response will be empty.
500 There was an internal error. A stack trace is provided and logged in the Auth Service log files. The response will be empty.

Return Oauth Configuration

Request

Retrieves the OAuth configuration for a specific application.

GET /application/:applicationId/oauth-configuration

Request Headers

Request Parameters

Response

Response Codes

Code Description
200 The request was successful. The response will contain a JSON body.
400 The request was invalid and/or malformed. The response will contain an Errors JSON Object with the specific errors. This status will also be returned if a paid Auth Service license is required and is not present.
401 You did not supply a valid Authorization header. The header was omitted or your API key was not valid. The response will be empty
404 The object you are trying to update doesn’t exist. The response will be empty.
500 There was an internal error. A stack trace is provided and logged in the Auth Service log files. The response will be empty.


Application Scopes

Overview

The ApplicationScopesService is a crucial component of our NestJS application, responsible for managing OAuth scopes for applications. It provides functionality for creating, updating, and deleting scopes associated with specific applications.

Key Features

  1. Scope CRUD operations
  2. Tenant-based authorization
  3. Application-specific scope management
  4. Detailed error handling and logging

Create Scope

Request

Create Scope with random id

POST /application/:applicationId/scope

Create Scope with given id

POST /application/:applicationId/scope/:scopeId

Request Parameters

Request Headers

Response

Response Codes

Code Description
200 The request was successful. The response will contain a JSON body.
400 The request was invalid and/or malformed. The response will contain an Errors JSON Object with the specific errors. This status will also be returned if a paid Auth Service license is required and is not present.
401 You did not supply a valid Authorization header. The header was omitted or your API key was not valid. The response will be empty
404 The object you are trying to update doesn’t exist. The response will be empty.
500 There was an internal error. A stack trace is provided and logged in the Auth Service log files. The response will be empty.

Update Scope

Request

Updates an existing scope for an application.

PATCH /application/:applicationId/scope/:scopeId

Request Parameters

Request Headers

Request Body

Response

Response Codes

Code Description
200 The request was successful. The response will contain a JSON body.
400 The request was invalid and/or malformed. The response will contain an Errors JSON Object with the specific errors. This status will also be returned if a paid Auth Service license is required and is not present.
401 You did not supply a valid Authorization header. The header was omitted or your API key was not valid. The response will be empty
404 The object you are trying to update doesn’t exist. The response will be empty.
500 There was an internal error. A stack trace is provided and logged in the Auth Service log files. The response will be empty.

Delete Scope

Request

Deletes a scope from an application.

DELETE /application/:applicationId/scope/:scopeId

Request Parameters

Request Headers

Response

Response Codes

Code Description
200 The request was successful. The response will contain a JSON body.
400 The request was invalid and/or malformed. The response will contain an Errors JSON Object with the specific errors. This status will also be returned if a paid Auth Service license is required and is not present.
401 You did not supply a valid Authorization header. The header was omitted or your API key was not valid. The response will be empty
404 The object you are trying to update doesn’t exist. The response will be empty.
500 There was an internal error. A stack trace is provided and logged in the Auth Service log files. The response will be empty.


Application Roles

Overview

The ApplicationRolesService is a crucial component of our NestJS application, responsible for managing roles for applications. It provides functionality for creating, updating, and deleting roles associated with specific applications.

Key Features

  1. Role CRUD operations
  2. Tenant-based authorization
  3. Application-specific role management
  4. Detailed error handling and logging

Create Role

Request

Creates a new role with random ID.

POST /application/:applicationId/role

Create Role with given id

POST /application/:applicationId/role/:roleId

Request Parameters

Request Headers

Request Body

Response

Response Codes

Code Description
200 The request was successful. The response will contain a JSON body.
400 The request was invalid and/or malformed. The response will contain an Errors JSON Object with the specific errors. This status will also be returned if a paid Auth Service license is required and is not present.
401 You did not supply a valid Authorization header. The header was omitted or your API key was not valid. The response will be empty
404 The object you are trying to update doesn’t exist. The response will be empty.
500 There was an internal error. A stack trace is provided and logged in the Auth Service log files. The response will be empty.

Update Role

Request

Updates an existing role for an application.

PATCH /application/:applicationId/role/:roleId

Request Parameters

Request Headers

Request Body

Response

Response Codes

Code Description
200 The request was successful. The response will contain a JSON body.
400 The request was invalid and/or malformed. The response will contain an Errors JSON Object with the specific errors. This status will also be returned if a paid Auth Service license is required and is not present.
401 You did not supply a valid Authorization header. The header was omitted or your API key was not valid. The response will be empty
404 The object you are trying to update doesn’t exist. The response will be empty.
500 There was an internal error. A stack trace is provided and logged in the Auth Service log files. The response will be empty.

Delete Role

Request

Deletes a role from an application.

DELETE /application/:applicationId/role/:roleId

Request Parameters

Request Headers

Response

Response Codes

Code Description
200 The request was successful. The response will contain a JSON body.
400 The request was invalid and/or malformed. The response will contain an Errors JSON Object with the specific errors. This status will also be returned if a paid Auth Service license is required and is not present.
401 You did not supply a valid Authorization header. The header was omitted or your API key was not valid. The response will be empty
404 The object you are trying to update doesn’t exist. The response will be empty.
500 There was an internal error. A stack trace is provided and logged in the Auth Service log files. The response will be empty.

Error Handling

The service implements comprehensive error handling, throwing appropriate exceptions:

Authorization

All endpoints are protected by authorization headers which requires authorization and x-stencil-tenanid values to be passed in headers, which are verified using the HeaderAuthService.

Usage Notes

  1. Ensure that the necessary environment variables and configurations are set up for Prisma and other dependent services.
  2. The service expects certain headers for authorization, including x-stencil-tenantid for tenant-scoped operations.
  3. When creating or updating roles, make sure to provide all required fields in the DTO objects.
  4. The service interacts closely with the database using Prisma ORM. Ensure your database schema matches the expected structure for applications and roles.
  5. The isDefault and isSuperRole flags in the role data can be used to designate special roles within an application.