Oauth 2.0 OpenID连接授权代码流和带静默刷新的PKCE
我在IdentityServer 4上实现了openID Connect授权代码流和带静默刷新的PKCE。我有一个参考IdentityServer的核心API和一个angular 8 front和oidc-client.js 当我不登录时,oidc客户端将我重定向到IdentityServer登录页面,从那里我可以登录,然后IdentityServer将我重定向到angular应用程序。我有一个传输到API的承载格式的访问令牌和一个经常弹出并联系/connect/authorize上的IdentityServer的iframe。当我注销时,我在IdentityServer上被重定向,然后被重定向到我的角度前端,要求我登录 你可能会问这家伙到底有什么问题。好了: 当我在postman中复制/粘贴承载令牌时,我可以在用户注销后,在截断PersistedGrants表后,在执行“\u signInManager.SignOutAsync”“\u persistedGrantService.RemoveAllGrantsAsync”后,将AccessTokenLifetime(db字段)设置为65的情况下永久使用它 我现在给你一些代码: Startup.cs APIOauth 2.0 OpenID连接授权代码流和带静默刷新的PKCE,oauth-2.0,openid,identityserver4,openid-connect,Oauth 2.0,Openid,Identityserver4,Openid Connect,我在IdentityServer 4上实现了openID Connect授权代码流和带静默刷新的PKCE。我有一个参考IdentityServer的核心API和一个angular 8 front和oidc-client.js 当我不登录时,oidc客户端将我重定向到IdentityServer登录页面,从那里我可以登录,然后IdentityServer将我重定向到angular应用程序。我有一个传输到API的承载格式的访问令牌和一个经常弹出并联系/connect/authorize上的Ident
services.AddAuthentication(IdentityServerAuthenticationDefaults.AuthenticationScheme)
.AddIdentityServerAuthentication(options =>
{
options.Authority = configApp.UrlIdentityServer;
options.RequireHttpsMetadata = false;
options.ApiName = "example.api";
});
控制器方法示例:
[HttpGet("{id:int}")]
[Authorize]
public ActionResult<FormatedResult<Stuff>> GetStuff(int id)
{/*great stuff*/}
角度oidc管理器设置
authority: 'http://example.authserver.loc/',
client_id: 'example.ng.manager',
redirect_uri: 'http://ng.example.loc:5001/callbacksignin/',
post_logout_redirect_uri: 'http://ng.example.manager.loc:5001/',
response_type: 'code',
scope: 'openid profile example.api',
filterProtocolClaims: true,
loadUserInfo: true,
userStore: new WebStorageStateStore({store: window.localStorage}),
automaticSilentRenew: true,
silent_redirect_uri: 'http://ng.example.manager.loc:5001/silent-refresh.html',
revokeAccessTokenOnSignout: true
我认为无声刷新是用来避免持票人代币被盗,以及一个坏男孩在我的API上无限期地做坏事。通过我的实现,坏小子可以永远玩我的API
我的问题是:
- 这会发生吗李>
- 访问令牌是否终身授予
- 如果不是,我做错了什么
- 在通过AccessTokenLifetime后,如何拒绝使用访问令牌?或者在用户注销之后
authority: 'http://example.authserver.loc/',
client_id: 'example.ng.manager',
redirect_uri: 'http://ng.example.loc:5001/callbacksignin/',
post_logout_redirect_uri: 'http://ng.example.manager.loc:5001/',
response_type: 'code',
scope: 'openid profile example.api',
filterProtocolClaims: true,
loadUserInfo: true,
userStore: new WebStorageStateStore({store: window.localStorage}),
automaticSilentRenew: true,
silent_redirect_uri: 'http://ng.example.manager.loc:5001/silent-refresh.html',
revokeAccessTokenOnSignout: true