IdentityServer4。基本概念。OpenID Connect,OAuth 2.0和JWT

在这篇文章中,我想打开一个专门用于IdentityServer4的文章线程。我们从基本概念开始。


目前最有希望的身份验证协议是OpenID Connect,而身份验证协议(允许访问)是OAuth 2.0IdentityServer4实现这两个协议。针对常见的安全问题进行了优化


OpenID Connect是一种协议和身份验证标准,它不提供对资源(Web API)的访问,但是由于 它是在OAuth 2.0授权协议的基础上开发的,它使您可以像访问UserInfo资源一样获取用户配置文件参数

JWT(JSON Web令牌)是一种Web标准,它定义了一种以JSON格式以加密形式传输用户数据的方法。

OAuth 2.0(RF​​C 6749)是协议和授权标准。它允许应用程序访问安全资源,例如Web API。

看一下访问受保护资源的图,并处理主要步骤和公认的术语:


is4


  1. . — . Web API.


  2. User , , . . User ( ) — , , , (username) (password);


  3. IdentityServer4 (client_id, client_secret), (username, password) grant_type scope. ( ).


    OAuth 2.0 , , . client_id client_secret.
    lient_id — , IdentityServer4 .
    client_secret IdentityServer4. API. IdentityServer4 .

  4. , IdentiryServer4 access- ( ) (refresh-). . , .


  5. Web API, . 401, 403 498, , , .


  6. , Web API .




IdentityServer4 IdentityServer4 identity-, access- refresh-.


  • identity- ( ) — . , . .
  • access- ( ) — API ( ) .
  • refresh- ( ) — , .

:


Authenticatation Server Url — . URL-.


Resource Url — URL- , , , .



POST IdentityServer4


'Content-Type': 'application/x-www-form-urlencoded',
'Accept': 'application/json',
'Expect': '100-continue'

:


'grant_type' : 'password',
'username' : login,
'password' : password,
'scope' : 'scope',
'client_id' : 'client_id',
'client_secret' : '{client_secret}'

username, password, client_id client_secret . :


grant_type — . , , API. password, OAuth 2.0 ( ).


OAuth 2.0 :


  • (authorization code). , .. (server-side applications), ;
  • (implicit). -, ;

, :


  • (resource owner). , . , . , OAuth 2.0.
  • . API. , , URI , , , API .

scope — . . , , , . .. scope scope . scope (, )


All Articles