2016-10-25 46 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);); 

的全部細節