Bitzsoft.Integrations.IdentityProvider 1.0.2

dotnet add package Bitzsoft.Integrations.IdentityProvider --version 1.0.2
                    
NuGet\Install-Package Bitzsoft.Integrations.IdentityProvider -Version 1.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Bitzsoft.Integrations.IdentityProvider" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Bitzsoft.Integrations.IdentityProvider" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="Bitzsoft.Integrations.IdentityProvider" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Bitzsoft.Integrations.IdentityProvider --version 1.0.2
                    
#r "nuget: Bitzsoft.Integrations.IdentityProvider, 1.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Bitzsoft.Integrations.IdentityProvider@1.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Bitzsoft.Integrations.IdentityProvider&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=Bitzsoft.Integrations.IdentityProvider&version=1.0.2
                    
Install as a Cake Tool

Bitzsoft.Integrations.IdentityProvider

身份提供者抽象层 — 统一接口定义、基础模型与结果包装。

屏蔽 Okta、Keycloak、Auth0 等供应商差异,提供一致的用户创建、查询、更新、删除、激活/停用、密码重置与用户组管理 API。

功能特性

  • 统一供应商接口 IIdentityProviderService:12 个异步方法覆盖用户与用户组全生命周期
  • 统一结果包装IdentityProviderResult 携带成功标志与错误信息
  • 统一异常 IdentityProviderException:封装供应商标识、错误码与请求 ID
  • 不可变模型设计:集合返回 List<T>,属性使用 init 保证只读

安装

dotnet add package Bitzsoft.Integrations.IdentityProvider
<PackageReference Include="Bitzsoft.Integrations.IdentityProvider" Version="1.0.0" />

接口

IIdentityProviderService

统一的身份提供者供应商接口。

方法 返回类型 说明
ProviderName string 供应商标识(如 OktaKeycloak
CreateUserAsync Task<IdentityUser> 创建用户,返回用户信息
GetUserAsync Task<IdentityUser> 查询单个用户
UpdateUserAsync Task<IdentityProviderResult> 更新用户信息
DeleteUserAsync Task<IdentityProviderResult> 删除用户
ListUsersAsync Task<List<IdentityUser>> 分页查询用户列表
ActivateUserAsync Task<IdentityProviderResult> 激活用户
DeactivateUserAsync Task<IdentityProviderResult> 停用用户
ResetPasswordAsync Task<IdentityProviderResult> 重置用户密码
AddUserToGroupAsync Task<IdentityProviderResult> 将用户加入用户组
RemoveUserFromGroupAsync Task<IdentityProviderResult> 将用户移出用户组
ListGroupsAsync Task<List<IdentityGroup>> 查询用户组列表

核心模型

关键字段 说明
CreateUserRequest UserNameFirstNameLastNameEmailPhonePasswordActivate 创建用户请求
UpdateUserRequest UserIdFirstNameLastNameEmailPhone 更新用户请求
ListUsersRequest SearchPageIndexPageSizeStatus 用户列表查询参数
IdentityUser UserIdUserNameFirstNameLastNameEmailPhoneStatusCreatedAtLastLoginAtMfaEnabled 用户信息
IdentityGroup GroupIdNameDescription 用户组信息
UserGroupRequest UserIdGroupId 用户组操作请求
IdentityProviderResult SuccessErrorMessage 操作结果
IdentityProviderException 统一异常(继承 IntegrationException

枚举

枚举 说明
UserStatus 用户状态:Active / Inactive / Suspended / Provisioned / Locked / Deleted

使用示例

抽象层本身只定义接口与模型,具体实现由各供应商包提供。以下示例假设已注册某个供应商实现:

public class UserService(IIdentityProviderService idp)
{
    public async Task<string> ProvisionAsync(string userName, string email)
    {
        var user = await idp.CreateUserAsync(new CreateUserRequest
        {
            UserName = userName,
            Email = email,
            Activate = true
        });
        return user.UserId;
    }

    public Task<IdentityProviderResult> ResetPasswordAsync(string userId)
        => idp.ResetPasswordAsync(userId);
}

多供应商解析

同一应用注册多个供应商时,通过 IIntegrationProviderResolver<IIdentityProviderService> 按供应商 ID 解析:

var resolver = serviceProvider.GetRequiredService<IIntegrationProviderResolver<IIdentityProviderService>>();
var okta = resolver.GetRequired("okta");
var user = await okta.GetUserAsync(userId);

依赖

相关包

供应商 包名
统一抽象 Bitzsoft.Integrations.IdentityProvider
Okta Bitzsoft.Integrations.IdentityProvider.Okta
Keycloak Bitzsoft.Integrations.IdentityProvider.Keycloak
Auth0 Bitzsoft.Integrations.IdentityProvider.Auth0
聚合包 Bitzsoft.Integrations.IdentityProvider.All
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (4)

Showing the top 4 NuGet packages that depend on Bitzsoft.Integrations.IdentityProvider:

Package Downloads
Bitzsoft.Integrations.IdentityProvider.Auth0

Auth0 身份提供者实现 — OAuth2 Client Credentials 令牌缓存 + Management API,实现 IIdentityProviderService 统一接口,支持用户 CRUD、激活/停用/重置密码、用户组管理

Bitzsoft.Integrations.IdentityProvider.Keycloak

Keycloak 身份提供者实现 — OAuth2 Client Credentials 令牌缓存 + Admin REST API,实现 IIdentityProviderService 统一接口,支持用户 CRUD、激活/停用、重置密码与用户组管理

Bitzsoft.Integrations.IdentityProvider.Okta

Okta 身份提供者实现 — API Token Bearer(SSWS)鉴权 + HttpClient,实现 IIdentityProviderService 统一接口,支持用户 CRUD、激活/停用/重置密码、用户组管理

Bitzsoft.Integrations.IdentityProvider.All

身份提供者服务聚合包 — 包含全部供应商实现(Okta / Keycloak / Auth0)

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.2 201 8/29/2026
1.0.1 234 8/3/2026
1.0.0 225 8/2/2026