我想用IdServer4提供一项身份服务,将身份验证部分外包给Auth0 -- Auth0处理单点登录和其他内容,并且做得很好--所以不需要重新发明轮子。但是我想将它嵌入到身份服务器(pref )中。IdentityServer4),它通过Auth0处理身份验证,并为用户和机器处理授权本身(声明和范围)。
机器将通过tokenClient通过所谓的客户机凭据(credentials.html)获取令牌。
public static IEnumerable<Client> Clients =>
new List<Client>
{
new Client
{
ClientId = "client",
// no interactive user, use the clientid/secret for authentication
AllowedGrantTypes = GrantTypes.ClientCredentials,
// secret for authentication
ClientSecrets =
{
new Secret("secret".Sha256())
},
// scopes that client has access to
AllowedScopes = { "api1" }
}
};这台机器可以工作。但是,身份服务器如何确保“用户”通过Auth0 (SSO)登录,然后从IdentityServer4本身获得访问令牌(就像机器一样),而不是从Auth0本身获取令牌。我已经将Auth0实现为外部ID提供程序:
services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme;
})
.AddCookie()
.AddOpenIdConnect("Auth0", options => {
options.Authority = "auth0domain";
options.ClientId = "clientId";
options.ClientSecret = "secret";
...
});其余部分,请参见:https://auth0.com/blog/using-csharp-extension-methods-for-auth0-authentication/
当通过等待HttpContext.ChallengeAsync()触发身份验证时,用户可以登录。然后他或她就可以退出了。这个很好用。但是用户从Auth0本身获得了一个访问令牌,我想用IdSrv4生成的令牌来代替它。这个是可能的吗?
发布于 2022-11-18 12:55:49
您需要使用Identity Server作为基本身份验证服务器,并将SSO配置为外部登录名。就像使用google、facebook等登录网站一样,唯一的考虑是SSO服务器应该支持OIDC这样的标准。看看https://docs.duendesoftware.com/identityserver/v6/ui/login/external/ providers.html,您可以在登录回调处理程序中执行任何身份验证工作(例如添加声明)。
发布于 2022-11-18 16:17:01
你和IdentityServer4有联系吗?可能值得将OpenIddict作为一种替代方案来研究。我刚刚实现了这一点,并使用所提供的令牌保护了一个API --这是一个不错的选择。
如果我错过了你问题的重点,很抱歉
https://stackoverflow.com/questions/74489915
复制相似问题