![]() |
VOOZH | about |
dotnet add package Eaf.Middleware.AzureActiveDirectory --version 9.1.0
NuGet\Install-Package Eaf.Middleware.AzureActiveDirectory -Version 9.1.0
<PackageReference Include="Eaf.Middleware.AzureActiveDirectory" Version="9.1.0" />
<PackageVersion Include="Eaf.Middleware.AzureActiveDirectory" Version="9.1.0" />Directory.Packages.props
<PackageReference Include="Eaf.Middleware.AzureActiveDirectory" />Project file
paket add Eaf.Middleware.AzureActiveDirectory --version 9.1.0
#r "nuget: Eaf.Middleware.AzureActiveDirectory, 9.1.0"
#:package Eaf.Middleware.AzureActiveDirectory@9.1.0
#addin nuget:?package=Eaf.Middleware.AzureActiveDirectory&version=9.1.0Install as a Cake Addin
#tool nuget:?package=Eaf.Middleware.AzureActiveDirectory&version=9.1.0Install as a Cake Tool
O Eaf.Middleware.AzureActiveDirectory é um módulo de autenticação Azure Active Directory do Enterprise Application Foundation (EAF). Este módulo fornece integração completa com Azure AD para autenticação externa e sincronização de usuários, permitindo que usuários autentiquem usando suas credenciais Microsoft 365.
Este módulo suporta OpenID Connect, OAuth 2.0 e sincronização automática de usuários, grupos e propriedades do Azure AD.
Implementação de autenticação externa via Azure AD:
Configurações de conexão Azure AD:
dotnet add package Eaf.Middleware.AzureActiveDirectory --version 10.4.0
Adicione a referência ao seu arquivo .csproj:
<ProjectReference Include="..\Eaf.Middleware.AzureActiveDirectory\Eaf.Middleware.AzureActiveDirectory.csproj" />
No seu módulo principal, herde de MiddlewareAzureActiveDirectoryModule:
[DependsOn(
typeof(MiddlewareAzureActiveDirectoryModule),
typeof(AbpZeroCommonModule)
)]
public class MyAuthenticationModule : AbpModule
{
public override void Initialize()
{
IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());
}
}
No appsettings.json:
{
"AzureAd": {
"Instance": "https://login.microsoftonline.com/",
"TenantId": "your-tenant-id",
"ClientId": "your-client-id",
"CallbackPath": "/signin-oidc",
"Domain": "your-domain.onmicrosoft.com"
}
}
{
"AzureAd": {
"TenantId": "your-tenant-id",
"ClientId": "your-client-id",
"ClientSecret": "your-client-secret",
"GraphScopes": "User.Read Group.Read.All"
}
}
public class AzureAdAuthenticationAppService : ApplicationService
{
private readonly AzureActiveDirectoryAuthenticationSource _azureAdAuthSource;
public AzureAdAuthenticationAppService(AzureActiveDirectoryAuthenticationSource azureAdAuthSource)
{
_azureAdAuthSource = azureAdAuthSource;
}
public async Task<bool> AuthenticateAsync(string token)
{
try
{
var result = await _azureAdAuthSource.AuthenticateAsync(token);
return result != null;
}
catch (Exception ex)
{
Logger.Error(ex, "Azure AD authentication failed");
return false;
}
}
}
public class AzureAdSyncService : ApplicationService
{
private readonly AzureActiveDirectoryAuthenticationSource _azureAdAuthSource;
public AzureAdSyncService(AzureActiveDirectoryAuthenticationSource azureAdAuthSource)
{
_azureAdAuthSource = azureAdAuthSource;
}
public async Task SyncUserAsync(string objectId)
{
var user = await _azureAdAuthSource.CreateOrUpdateUserAsync(
new ExternalAuthUserInfo
{
ProviderName = "AzureActiveDirectory",
ProviderKey = objectId,
Name = "user@domain.com"
}
);
}
}
public class AzureAdGraphService : ApplicationService
{
private readonly GraphServiceClient _graphClient;
public AzureAdGraphService(GraphServiceClient graphClient)
{
_graphClient = graphClient;
}
public async Task<User> GetUserAsync(string userId)
{
return await _graphClient.Users[userId].Request().GetAsync();
}
public async Task<IEnumerable<Group>> GetUserGroupsAsync(string userId)
{
var groups = await _graphClient.Users[userId].MemberOf.Request().GetAsync();
return groups.OfType<Group>();
}
}
Eaf.Middleware.AzureActiveDirectory/
├── AzureActiveDirectory/ # Implementações Azure AD
│ ├── AzureActiveDirectoryAuthenticationSource.cs
│ ├── AzureActiveDirectorySettings.cs
│ └── AzureActiveDirectoryUserManager.cs
└── MiddlewareAzureActiveDirectoryModule.cs # Módulo ABP
public override void PreInitialize()
{
Configuration.Modules.EafAzureAd().ClaimMappings = new Dictionary<string, string>
{
["given_name"] = "FirstName",
["family_name"] = "LastName",
["job_title"] = "JobTitle"
};
}
{
"AzureAd": {
"AutoSyncUsers": true,
"SyncGroups": true,
"SyncIntervalMinutes": 60
}
}
{
"AzureAd": {
"IsMultiTenant": true,
"DefaultTenantId": "default-tenant-id"
}
}
Os testes para este módulo devem ser criados seguindo o padrão dos outros módulos do EAF.
Este projeto faz parte do Enterprise Application Foundation (EAF) e está licenciado sob os mesmos termos do projeto principal.
Para issues e perguntas, consulte o repositório principal do EAF: https://github.com/afonsoft/EAF
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 1 NuGet packages that depend on Eaf.Middleware.AzureActiveDirectory:
| Package | Downloads |
|---|---|
|
Eaf.Middleware.Core
Package Description |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 9.1.0 | 71 | 6/17/2026 |