zoukankan      html  css  js  c++  java
  • identityServer4 中的概念(Scope,claim)

    在IdentityServer中好多地方出现这几个词,这单词的解释也有好多大神解释过:

    chaim:

    ASP.NET Core 之 Identity 入门(一),这个是asp.net identity中chaim的解释,虽然不是identityServer,但解释相当精准。

    IdentityServer4实战 - 基于角色的权限控制及Claim详解 ,这是是Claim 在identityServer中的解释。

    首先查看identityServer中chaim出现的地方:

    Clientclaims、Identityclaims、apiclaims和APIScopeclaims,说明claim与这些东东都有关系,按照上面第一篇博客的说明,这个claim是 “证件单元”,这个apiclaims就解释为api的需要的证件单元,也不是太合适;按照第二篇博客说的claim是“用户信息单元”,只有解释用户的时候可以这么说。

    查看identityServer源码,claim包含type和value两个property,在identity、apiresource和apiscope中都有(UserClaims)这个属性,官方解释:List of associated user claim types that should be included in the access token.就是需要在access token中应该包含的一系列相关claim 类型,如果access token中含有这个claim可以访问这个resource,另外APIScopeclaims中的claim也会附加到这个api资源上。

    Scopes:

    英文翻译:范围

    Scope出现在两个地方:clientScope和apiscope。

    Scope 在ids3中的解释:IdentityServer.Core.Models.Scope 类是对 OpenID Connect 或 OAuth2 scope 的建模。这个解释很合理;

    在token中scope是一个claim,这个很重要:scope也是一个claim;

    apiscope,一个api至少有一个scope,下面的两个定义是一个意思:

     1 new ApiResource("api1", "Some API 1")
     2 //与下面的意思相同 3 
     4 new ApiResource
     5 {
     6     Name = "api1",
     7     DisplayName = "Some API 1", 8 
     9     Scopes =
    10     {
    11         new Scope()
    12         {
    13             Name = "api1",
    14             DisplayName = "Some API 1"
    15         }
    16     }
    17 }

    一个api也可以有多个scope,例如:

     1 new ApiResource
     2 {
     3     Name = "api2",
     4 
     5     Scopes =
     6     {
     7         new Scope()
     8         {
     9             Name = "api2.full_access",
    10             DisplayName = "Full access to API 2"
    11         },
    12         new Scope
    13         {
    14             Name = "api2.read_only",
    15             DisplayName = "Read only access to API 2"
    16         }
    17     }
    18 }

     

     

     

     

     

     

     

     

     

     

     

  • 相关阅读:
    python主流框架简介和Django框架的使用
    如何确定计算上已安装的.NET framework版本
    访问另一台主机时报错0x80004005
    sql server自动备份数据库
    sql server创建维护计划报错“不是有效的win32”
    sql server agent代理备份数据库报错‘用户 'sa' 登录失败’
    sql server日志查错
    windows10安装64位Orcale 19c
    触发器基本知识
    MediaElement 的两种模式
  • 原文地址:https://www.cnblogs.com/indexlang/p/10118136.html
Copyright © 2011-2022 走看看