2016-10-25 44 views
0

我在寻找如何使用angular2在asp.net-core 1.0中实现JWT承载的授权。 我问你们样品或类似的东西?asp.net core + angular2 JWT承载器

+3

https://github.com/openiddict/openiddict-samples见here有使用OpenIddict的示例。 https://github.com/IdentityServer/IdentityServer4拥有IdentityServer4。一旦你了解了领土,请回到问一个可回答的问题。 –

+0

mhmm,我想在aps.net MVC 4中更简单地作为cookie授权。 – wroe12

回答

0

asp.net core 1.1 has lib。可以很容易做到JWT承载,请点击这里:

https://code.msdn.microsoft.com/How-to-achieve-a-bearer-9448db57

而对角作为客户端,请参阅本:

https://code.msdn.microsoft.com/How-to-authorization-914d126b

由于MS $提供中间件UseJwtBearerAuthentication,智威汤逊承载令牌将会更加简单在后端使用它;为前端保存令牌的sessionStorage登录后,说话的后端,设置HTTP请求头时为:

let headers = new Headers({ 'Content-Type': 'application/json' }); 
headers.append("Authorization", "Bearer " + sessionStorage.getItem(this.tokenKey);); 

的全部细节