Skip to content

Implementation of Azure AD based custom authentication strategy in NestJS

License

Notifications You must be signed in to change notification settings

SwagataChaudhuri/NestJS-AzureAD-Authentication

Repository files navigation

Azure AD Authentication in NestJS

Compile and build codecov Prettier MIT License HitCount

Sample implementation to demonstrate how to implement Azure Active Directory authentication in NestJS using custom strategies.


Description

This repository contains a sample implementation of Azure AD authentication in NestJS using custom strategies. The sample implementation is based on the NestJS official documentation wuth customization to interact and authenticate with Azure Active Directory.


Installation

$ npm install

Configuration

This application has a .env.example file. Please create a .env file and update the values as per the Azure AD application registration. The below table describes the environment variables used in the application:

Environment Variable Description
AZURE_AD_TENANTID Azure AD Tenant ID
AZURE_AD_CLIENTID Azure AD Application Client ID
AZURE_AD_AUDIENCE Azure AD Token Audience

Running the application

The application can be run in two modes, development and production. The development mode supports hot reloading which is beneficial during development. The production mode is optimized for performance.

The root directory also comtains a Dockerfile which can be used to build a docker image of the application for containerization.

Development Mode

Execute the below command to run the application in development mode:

$ npm run start:dev

Production Mode

Execute the below command to run the application in production mode:

$ npm run start:prod

Testing

The application has tests configured using Jest. The tests are located in the test directory. The tests are also configured to generate coverage reports. The coverage reports are generated in the coverage directory.

Unit Tests

Execute the below command to run the unit tests:

$ npm run test

Coverage Reports

Execute the below command to run the tests and generate the coverage reports:

$ npm run test:cov

License

The application and all associated source code are distributed under the MIT License.


Author

Swagata Chaudhuri


Support

In case you find the project helpful, please consider supporting by ⭐ the project.


Contributing

Contributions are welcome! Please feel free to submit a Pull Request in case you find any issues with the code.


Acknowledgements

About

Implementation of Azure AD based custom authentication strategy in NestJS

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published