我正在Identity Server 3中实现AuthorizationCode流程.
当我登录时,我得到一个invalid_scope例外.
这是我的客户:
new Client
{
Enabled = true,
ClientName = "Web Application",
ClientId = "webapplication",
Flow = Flows.AuthorizationCode,
ClientSecrets = new List<Secret>
{
new Secret("webappsecret".Sha256())
},
RedirectUris = new List<string>
{
UrlManager.WebApplication
},
PostLogoutRedirectUris = new List<string>
{
UrlManager.WebApplication
},
AllowedScopes = new List<string>
{
Constants.StandardScopes.OpenId,
Constants.StandardScopes.Profile,
Constants.StandardScopes.Email,
Constants.StandardScopes.Roles,
Constants.StandardScopes.OfflineAccess
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的创业公司:
app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
{
Authority = UrlManager.AuthenticationService + "identity",
ClientId = "webapplication",
Scope = "openid profile offline_access",
ResponseType = "code",
RedirectUri = UrlManager.WebApplication, …Run Code Online (Sandbox Code Playgroud) 我想问一个问题,以确认我对如何使用范围和声明(角色)的理解.假设我有一个用户(具有只读权限的用户A,即适合的只读角色),Windows服务(具有只读访问权限的客户端A),MVC站点(具有完全访问权限的客户端B)和Web API.我希望具有完全访问权限和只读访问权限的用户和客户端访问Web API.
当客户端A连接到Web API时,它会传递一个包含Scope"sampleApi.read_only"的访问令牌,我可以使用[ScopeAuthorize("sampleApi.full)]或ScopeAuthorize("sampleApi.full,sampleApi.read_only")]用于微调可访问性的类和方法.没问题.
但是,当用户A登录时,他/她"继承"客户端B的范围.因此,访问令牌包含"sampleApi.full","sampleApi.read_only"和角色"read_only".
现在我在WebApi遇到了一个问题,我需要在被用户调用时采取不同的行动.在这种情况下,我忽略了范围并使用他/她的角色,用户获得"read_only"访问权限,这就是我想要的.
这是正确的,使用ScopeAuthorize属性不再有意义,我需要一个自定义混合属性来执行某些操作:
如果调用者是用户 - 然后使用角色来确定可访问性,则使用范围来确定可访问性
还是我完全被误解了?
我已经实现了Identity Server4,它看起来很棒.现在,我需要将原生移动应用程序(xamarin)连接到它.大多数博客和讨论建议使用"授权代码"或"混合"流程,github中的xamarin示例使用"隐式"流程.
我已经阅读了有关授权流程的文档,并且没有谈论用户名或密码. https://identityserver4.readthedocs.io/en/release/endpoints/authorize.html
我需要的是允许用户将他/她的用户名和密码提供给认证服务器,服务器最终应该返回访问代码.
我正在尝试验证从 OneLogin OpenID Connect 收到的 id_token。我在网上查了一下,每个人都说我需要使用 .pem 文件,但如何生成该文件?我可以使用 OpenSSL 生成它,但是在生成 .pem 证书时使用哪个密钥?我已经尝试过使用 client_id、client_secret。这些都不起作用。
有人可以帮忙吗?
我正在开发一个使用OIDC与Azure AD应用程序对话的JS应用程序.以下是身份验证和验证的流程 -
https://login.microsoftonline.com/common/discovery/keysuserinfo网址获取用户信息-https://login.microsoftonline.com/common/openid/userinfoAzure AD的问题是,我们无法完成步骤3和4.两个URL都不支持CORS.我们无法验证我们获得的令牌,也无法检索用户信息.
有没有更好的方法来获取Microsoft的OpenID for Azure AD实现中的userinfo?
在我工作的一个应用程序中,我们正在考虑将id_token用于所有用例,包括身份验证和授权.该解决方案正在从头开始.目前没有任何资源的消费者,我们可以修改资源以使用id_token.我对openid_connect和oauth 2.0的概念有点新意.是否只有使用id_token具有所有访问细节的问题?
我正在进行Idp定制。我需要让它处理通过OIDC登录的SP的“单一注销”请求。我目前具有SAML的“单一注销”功能,但是我客户端也要求OIDC。有发送单次注销请求的标准行业方法吗?典型的SP发送到Single Logout端点什么?
我们将Identity Server 4与自定义登录页面一起使用。我们一直在测试Cookie过期或手动修改令牌(强化的一部分)时会发生什么。
该应用程序希望将我们重定向到https:// localhost:44349 / signin-oidc,并返回302重定向,但/ signin-oidc不存在。我们想抛出一个401并将其重定向到/ home。
我找到了可以捕捉事件的地方
options.Events = new OpenIdConnectEvents
{
OnRedirectToIdentityProvider = context => {
var newRedirect = context.ProtocolMessage.RedirectUri.ToString().Replace("signin-oidc", "home");
var builder = new UriBuilder(newRedirect);
builder.Scheme = "https";
context.ProtocolMessage.RedirectUri = builder.ToString();
context.Response.StatusCode = (int)HttpStatusCode.Unauthorized;
return Task.FromResult(0);
}
};
Run Code Online (Sandbox Code Playgroud)
但这似乎不起作用,我们只是抛出302错误而没有任何方式向用户报告发生的情况。
我正在尝试向login_hintAzure AD身份验证的OpenID登录请求中添加。
添加login_hint为属性对我来说不起作用:
var properties = new AuthenticationProperties();
properties.RedirectUri = "someCallbackUrl";
properties.Dictionary.Add("login_hint ", "SomeUsername");
AuthenticationManager.Challenge(properties, OpenIdConnectAuthenticationDefaults.AuthenticationType);
Run Code Online (Sandbox Code Playgroud)
手动向查询字符串...&login_hint=SomeUsername中添加login_hint 至少向我证明了这种功能的存在:-)
我知道,如果要使用GoogleOAuth2AuthenticationProvider它,就必须像这样覆盖自身。我尝试采用的方法是否需要类似的东西?
我仍在学习Identity Framework,并且在尝试在.Net Core 2 MVC应用程序中设置身份验证时非常迷失。感谢我提供任何建议,因为我什至不确定自己在做什么。
我需要集成OpenID Connect身份提供程序进行身份验证,并使用辅助数据源进行授权。除名称声明外,我不方便使用OIDC IdP的任何声明。其余的用户声明必须来自辅助数据源(该辅助数据源通过定制UserStore和User实体连接到Identity Framework )。
我正在使用OpenId Connect提供程序来处理身份验证。这工作正常,并为我提供了第一个身份(我只能使用一个索赔)。当我需要获取用户的第二个Identity并将其添加到主体,并将其设置为default时,我的困惑就开始了Identity。该秒Identity提供了所有用户声明,包括角色。
我对身份框架的理解是,我应该拥有一个ClaimsPrincipal带有两个身份的单一身份,以便可以插入身份框架的其余部分。但是,对于两个身份,默认值ClaimsPrincipal将自动选择第一个身份(这是我不能使用的身份),因此,似乎我应该创建一个自定义ClaimsPrincipal并将其设置为PrimaryIdentitySelector第二个身份为主要身份。
public class MyClaimsPrincipal : ClaimsPrincipal
{
private static readonly Func<IEnumerable<ClaimsIdentity>, ClaimsIdentity> IdentitySelector = SelectPrimaryIdentity;
/// <summary>
/// This method iterates through the collection of ClaimsIdentities and chooses an identity as the primary.
/// </summary>
private static ClaimsIdentity SelectPrimaryIdentity(IEnumerable<ClaimsIdentity> identities)
{
// Find and return the …Run Code Online (Sandbox Code Playgroud) openid-connect ×10
c# ×2
oauth ×2
oauth-2.0 ×2
openid ×2
asp.net-core ×1
asp.net-mvc ×1
azure ×1
jwt ×1
oauth2 ×1
onelogin ×1