zoukankan      html  css  js  c++  java
  • IdentityServer4

    IdentityServer4

       IdentityServer4实现了OpenID Connect 和Oauth 2.0 protocol协议的ASP.NET Core框架。
       Notes:IdentityServer4推出了一个新公司,Duende IdentityServer,IdentityServer4会继续维护到2022年11月。

       • Authentication as a service

       集中管理应用(web,native,mobile,services)的登录和工作流,IdentityServer是官方认证的实现了OpenID Connect。

       • Single Sign-on / Sign-out

        通过多种应用类型进行单点登录(登出)

       • Access Control for APIs

       为多种类型的客户端颁发access token,例如:server to server,web application,SPAs和native/mobile apps。

       • Federation Gateway

        支持像Azure Active Directory,Google, Facebook等外部身份提供商,这对于你的应用程序来说可以不用关心是如何连接到外部身份提供商的。

        • Focus on Customization

        支持自定义。因为IdentityServer4是一个框架不是一个封闭的产品,你可以通过写code来作用于你的应用。

       • Mature Open Source
       • Free and Commercial Support

    现代应用程序工作流(大部分)

     常见的交互方式有以下几种

    • 浏览器和web applications之间交互
    • web application和web APIs(有时代表自己,有时代表一个user)
    • 基于浏览器的应用程序和Web API交互
    • 本地应用程序和Web API交互
    • 基于Server的应用程序和Web API交互
    • Web API和Web API之间的交互,这个在微服务系统中比较常见

       通常项目中都需要实现认证(Authentication)和授权(Authorization)来保护受保护的资源,这些Security function会设计在外围来阻止重复性访问 认证/授权 服务器带来的性能损耗。

       重构上面的application,支持Security token service,结构图如下:

     Authentication(认证)

    认证:应用程序需要知道(当前登录)用户是谁,用户能访问哪些资源,比较常见的就是(web applications),当然本地和JS-based的应用程序也需要认证身份。常见的认证协议(protocol):SAML2p,WS-Federation 和OpenID Connect.

    Authorization(授权)

    授权:授予用户某些权限通过应用程序访问受保护资源。

    OpenID Connect & OAuth 2.0

     OpenID认证

     OAuth授权

    IdentityServer4就是两者的实现,并且优化解决了现在mobile,native和web applications的安全问题。实际上OpenID是OAuth 2.0上的扩展。

    Terminology(术语)

    Identity Token:identity token代表认证返回的结果,包含少量identity信息。

    Endpoint

    • Discovery Endpoint
      discovery endpoint可以返回一些IdentityServer的元数据,像issuer name,key material, supported scope等。
      相对地址:/.well-know/openid-configuration
      e.g.:
       https://demo.identityserver.io/.well-known/openid-configuration
    • 可以使用Identitymodel client library来访问discovery endpoint从NETCOR中。
    • Authorize Endpoint
      authorize endpoint可以获取token或者authorization code通过浏览器,这个操作通常包含对end-user认证和可选择性授权。
      e.g.:
      GET /connect/authorize?
          client_id=client1&
          scope=openid email api1&
          response_type=id_token token&
          redirect_uri=https://myapp/callback&
          state=abc&
          nonce=xyz
    • Token Endpoint
      token endpoint可以用来获取token,支持password,authorization_code, client_credentials, refresh_token的授权方式。
      e.g.:
      POST /connect/token
      CONTENT-TYPE application/x-www-form-urlencoded
      
          client_id=client1&
          client_secret=secret&
          grant_type=authorization_code&
          code=hdh922&
          redirect_uri=https://myapp.com/callback

    • UserInfo Endpoint
      userInfo endpoint可以从user检索出identity 的信息。调用者需要发送一个有效的access token代表user还有授权范围,userInfo endpoint将会放回匹配的claims(至少openId scope是需要的)。
      e.g.:
      GET /connect/userinfo
      Authorization: Bearer <access_token>
      
      HTTP/1.1 200 OK
      Content-Type: application/json
      
      {
          "sub": "248289761001",
          "name": "Bob Smith",
          "given_name": "Bob",
          "family_name": "Smith",
          "role": [
              "user",
              "admin"
          ]
      }

    最后总结下IdentityServer能干什么:

    • Protect your resource
    • Authenticate users using a local account store or via external identity provider
    • Provide session management and single sign-on
    • Manage and authenticate clients
    • Issue identity and access tokens to clients
    • Validate tokens
  • 相关阅读:
    Dell PowerEdge服务器RAID卡驱动下载
    Cent OS yum 安装 Adobe flash player
    如何在安全模式下创建新管理员账户?
    chkdsk 和sfc.exe修复命令
    右下角弹出"Windows-延缓写入失败"或者"xxx-损坏文件 请运行Chkdsk工具"
    VMware NAT模式 Cent OS IP配置
    sublime Text2 2.0.2 build 2221 64位 破解(已测试)
    Windows Server 2008 R2 配置Exchange 2010邮件服务器
    openGL深度缓冲区问题
    glRotatef 转动方向
  • 原文地址:https://www.cnblogs.com/qindy/p/14555398.html
Copyright © 2011-2022 走看看