An open API service indexing awesome lists of open source software.

https://github.com/codeflow-inc/authentication

An API for user authentication and authorization built with ASP.NET Core, Entity Framework Core, and ASP.NET Core Identity. The project provides a foundation for managing user authentication, role-based access control, and JWT token issuance.
https://github.com/codeflow-inc/authentication

csharp docker dotnet entity-framework identity

Last synced: about 2 months ago
JSON representation

An API for user authentication and authorization built with ASP.NET Core, Entity Framework Core, and ASP.NET Core Identity. The project provides a foundation for managing user authentication, role-based access control, and JWT token issuance.

Awesome Lists containing this project

README

          

# AuthApi

An API for user authentication and authorization built with **ASP.NET Core**, **Entity Framework Core**, and **ASP.NET Core Identity**. The project provides a foundation for managing user authentication, role-based access control, and JWT token issuance.

## Features
- User registration and login.
- JWT token generation and validation for secure API access.
- Role-based access control.
- Extendable user and role models for custom attributes.
- Clean Architecture design pattern for scalability and maintainability.

## Getting Started

### Prerequisites
Before starting, ensure you have the following installed:
- [.NET 8 SDK](https://dotnet.microsoft.com/download/dotnet/8.0)
- [Docker](https://www.docker.com/)

## Project Structure

The project follows **Clean Architecture** principles with the following layers:

- **API**: Handles HTTP requests and responses.
- **Application**: Contains business logic and service implementations.
- **Domain**: Contains core entities and interfaces.
- **Infrastructure**: Handles data persistence and third-party integrations.

## API Endpoints

### Authentication
- **POST /api/auth/register**
Register a new user.
**Request body:**
```json
{
"email": "user@example.com",
"password": "YourStrongPassword123!",
"confirmPassword": "YourStrongPassword123!"
}
```

- **POST /api/auth/login**
Authenticate a user and return a JWT token.
**Request body:**
```json
{
"email": "user@example.com",
"password": "YourStrongPassword123!"
}
```

### Roles
- **GET /api/auth/roles**
Retrieve the roles assigned to the authenticated user.

## Security

- Passwords are hashed using **ASP.NET Core Identity**'s default algorithms.
- JWT tokens are used for stateless authentication and have configurable expiration.
- Follow best practices for storing the JWT secret in environment variables or secure stores like Azure Key Vault.

## Contributing

Contributions are welcome! Please fork the repository and submit a pull request with your changes.

## Future Enhancements
- Implement password recovery functionality.