IdentityServer4. مفاهيم أساسية. OpenID Connect و OAuth 2.0 و JWT

من خلال هذا المنشور ، أريد فتح سلسلة مقالات مخصصة لـ IdentityServer4. نبدأ بالمفاهيم الأساسية.


بروتوكول المصادقة الواعد حاليًا هو OpenID Connect ، و OAuth 2.0 هو بروتوكول المصادقة (المنح) . ينفذ IdentityServer4 هذين البروتوكولين. تم تحسينه لمشاكل الأمان الشائعة .


OpenID Connect هو معيار بروتوكول ومصادقة ، ولا يمنح الوصول إلى الموارد (Web API) ، ولكن منذ ذلك الحين تم تطويره أعلى بروتوكول تفويض OAuth 2.0 ، ويسمح لك بالحصول على معلمات ملف تعريف المستخدم كما لو كان لديك حق الوصول إلى مورد UserInfo .

JWT (JSON Web Token) هو معيار ويب يحدد طريقة لنقل بيانات المستخدم بتنسيق JSON في شكل مشفر.

OAuth 2.0 (RFC 6749) هو معيار بروتوكول وتفويض. يسمح للتطبيقات بالوصول إلى الموارد الآمنة ، مثل Web API.

ألق نظرة على الرسم البياني للوصول إلى مورد محمي والتعامل مع الخطوات الرئيسية والمصطلحات المقبولة:


هو 4


  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