简体   繁体   English

OpenID Connect隐式流-资源服务器

[英]OpenID Connect Implicit Flow - Resource Server

I've begun an implementation using the OpenID Connect Implicit Flow - I've retrieved my access token and ID token in my browser based javascript app, and now I need to protect the resource on my ASP.NET Core Web API so it can only be accessed via a valid access token from a user with a specific claim. 我已经开始使用OpenID Connect隐式流程进行实施-我已经在基于浏览器的javascript应用程序中检索了访问令牌和ID令牌,现在我需要保护ASP.NET Core Web API上的资源,以便仅可以通过具有特定声明的用户通过有效的访问令牌进行访问。

What middleware do I use to validate the token(s) and determine the user and their claims so I can then allow or deny them access to the resource they are requesting? 我使用哪种中间件来验证令牌并确定用户及其声明,以便随后允许或拒绝他们访问其请求的资源?

I've looked at OpenIdConnectAuthentication middleware, however the only implementation examples I've seen use a SignInScheme of "Cookies", not the Bearer token that my js app is providing. 我看过OpenIdConnectAuthentication中间件,但是我看到的唯一实现示例使用的是“ Cookies”的SignInScheme,而不是我的js应用程序提供的Bearer令牌。

Thanks 谢谢

What middleware do I use to validate the token(s) and determine the user and their claims so I can then allow or deny them access to the resource they are requesting? 我使用哪种中间件来验证令牌并确定用户及其声明,以便随后允许或拒绝他们访问其请求的资源?

If your authorization server issues JWT tokens, you can use the JWT bearer middleware developed by the ASP.NET team: https://github.com/aspnet/Security/tree/dev/src/Microsoft.AspNetCore.Authentication.JwtBearer . 如果授权服务器发布JWT令牌,则可以使用由ASP.NET团队开发的JWT承载中间件: https : //github.com/aspnet/Security/tree/dev/src/Microsoft.AspNetCore.Authentication.JwtBearer

app.UseJwtBearerAuthentication(new JwtBearerOptions {
    Authority = Configuration["jwt:authority"],
    Audience = Configuration["jwt:audience"]
});

You can find a sample here: https://github.com/aspnet/Security/tree/dev/samples/JwtBearerSample . 您可以在此处找到示例: https : //github.com/aspnet/Security/tree/dev/samples/JwtBearerSample

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何配置 ASP.NET WebApi 以针对 OpenID Connect 服务器验证承载令牌? - How do I configure ASP.NET WebApi to validate bearer tokens against an OpenID Connect server? 将IdentityServer3 OpenID Connect Provider和OAuth 2.0 Authorization Server与Web表单asp.net 4.6应用程序集成 - Integrating IdentityServer3 OpenID Connect Provider and OAuth 2.0 Authorization Server with a web forms asp.net 4.6 application 隐式流中的Identityserver authenticated_client错误 - Identityserver unauthorized_client error in implicit flow PayPal OpenId Connect沙盒元数据地址 - PayPal OpenId Connect Sandbox Metadata Address Azure 具有 MSAL 和 openID 连接的 Active Directory SSO - Azure Active Directory SSO with MSAL and openID Connect 为什么我无法在 openId 流后解码我的 cookies? - Why I cant decode my cookies after openId flow? 如何从 OWIN 中的 ./well-known/openid-connect URL 获取 OpenId Connect 配置? - How to get OpenId Connect Configuration from ./well-known/openid-connect URL in OWIN? WebForm 用授权码替换 OAUTH2 隐式流 - WebForm replace OAUTH2 implicit flow with Authorization Code Google OpenId Connect迁移:在ASP.NET应用中获取openid_id - Google OpenId Connect migration: getting the openid_id in ASP.NET app Microsoft Owin 不想使用隐式流 - Microsoft Owin Don't want to use implicit flow
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM