https://github.com/angelodotnet/identitymanager
Example showing a management of users, roles, permissions, modules and licenses using .NET 8 Minimal API and Entity Framework Core
https://github.com/angelodotnet/identitymanager
Last synced: over 1 year ago
JSON representation
Example showing a management of users, roles, permissions, modules and licenses using .NET 8 Minimal API and Entity Framework Core
- Host: GitHub
- URL: https://github.com/angelodotnet/identitymanager
- Owner: AngeloDotNet
- License: mit
- Created: 2025-02-20T00:34:07.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-05T08:07:34.000Z (over 1 year ago)
- Last Synced: 2025-03-09T06:07:06.012Z (over 1 year ago)
- Language: C#
- Homepage:
- Size: 16.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Identity Manager
Example showing a management of users, roles, permissions, modules and licenses using .NET 8 Minimal API and Entity Framework Core
> [!IMPORTANT]
> **The MinimalApi.Identity.API library used in this sample project, is still under development of new implementations.**
### 🛠️ Installation
This example uses the MinimalApi.Identity.API library available on NuGet.
Just search for MinimalApi.Identity.API in the Package Manager GUI or run the following command in the .NET CLI:
```shell
dotnet add package MinimalApi.Identity.API
```
### 🚀 Configuration
Adding this sections in the _appsettings.json_ file:
```json
{
"Kestrel": {
"Limits": {
"MaxRequestBodySize": 5242880
}
},
"JwtOptions": {
"Issuer": "[ISSUER]",
"Audience": "[AUDIENCE]",
"SecurityKey": "[SECURITY-KEY]",
},
"NetIdentityOptions": {
"RequireUniqueEmail": true,
"RequireDigit": true,
"RequiredLength": 8,
"RequireUppercase": true,
"RequireLowercase": true,
"RequireNonAlphanumeric": true,
"RequiredUniqueChars": 4,
"RequireConfirmedEmail": true,
"MaxFailedAccessAttempts": 3,
"AllowedForNewUsers": true,
"DefaultLockoutTimeSpan": "00:05:00"
},
"SmtpOptions": {
"Host": "smtp.example.org",
"Port": 25,
"Security": "StartTls",
"Username": "Username del server SMTP",
"Password": "Password del server SMTP",
"Sender": "MyApplication ",
"SaveEmailSent": false
},
"UsersOptions": {
"AssignAdminRoleOnRegistration": "admin@example.org"
},
"ConnectionStrings": {
"DefaultConnection": "Data Source=[HOSTNAME];Initial Catalog=[DATABASE];User ID=[USERNAME];Password=[PASSWORD];Encrypt=False"
}
}
```
> **Note**: If SaveEmailSent is false, only emails that failed while sending will be saved, if SaveEmailSent is true, both emails that were sent successfully and emails that failed will be saved
Registering services at _Program.cs_ file:
```csharp
var builder = WebApplication.CreateBuilder(args);
var connectionString = builder.Configuration.GetDatabaseConnString("DefaultConnection");
//...
var jwtOptions = builder.Configuration.GetSettingsOptions(nameof(JwtOptions));
var identityOptions = builder.Configuration.GetSettingsOptions(nameof(NetIdentityOptions));
var smtpOptions = builder.Configuration.GetSettingsOptions(nameof(SmtpOptions));
builder.Services
.AddRegisterServices(connectionString, jwtOptions, identityOptions)
.AddAuthorization(options =>
{
options.AddDefaultAuthorizationPolicy(); // Adds default authorization policies
// Here you can add additional authorization policies
});
builder.Services
.AddSwaggerConfiguration()
.AddRegisterOptions(builder.Configuration);
var app = builder.Build();
//...
app.UseAuthentication();
app.UseAuthorization();
//...
app.UseMapEndpoints();
app.Run();
```
### 📝 License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
### ⭐ Give a Star
If you find this project useful, please give it a ⭐ on GitHub to show your support and help others discover it!
### 🤝 Contributing
Suggestions are always welcome! Feel free to open suggestion issues in the repository and we will implement them as possible.