zoukankan      html  css  js  c++  java
  • 一步一步学习IdentityServer3 (15) 授权模式那些事

    总结一句话,其实很简单

    在什么Clients 拿的认证权限Scope 就去 去开什么Scope限制的服务接口门

    在写Clients的时候,会有Scope,看下面的代码

    new Client
                    {
                        ClientName = "手机APP",
                        ClientId = "lym.password",
                        Enabled = true,
                        AccessTokenType = AccessTokenType.Reference,
    
                        Flow = Flows.ResourceOwner,
    
                        ClientSecrets = new List<Secret>
                        {
                            new Secret("21B5F798-BE55-42BC-8AA8-0025B903DC3B".Sha256(),"WebAPI客户端")
                        },
                        AllowedScopes = new List<string>
                        {
                        Constants.StandardScopes.OpenId,
                        Constants.StandardScopes.Profile,
                        Constants.StandardScopes.OfflineAccess,
                        "cloudservices"
                        }
                    },

    这里是 密码模式,通过这个客户端拿到具有 

    cloudservices Scope的钥匙,那么我们就去开门
    这里我有设置了一个WebAPI
     app.UseIdentityServerBearerTokenAuthentication(new IdentityServerBearerTokenAuthenticationOptions
                {
    
                    Authority = LYM.Unity.AppSetting.AppSettingsHelper.GetString("Authority"),
                    ValidationMode = ValidationMode.ValidationEndpoint,
                    RequiredScopes = new[] {
                        //"openid",
                        //"profile",
                        //"offline_access",
                        "cloudservices"
                    }
                });

    这个就是相当于门上的锁,我设置了需要什么样的钥匙来开

    其次是所谓的客户端模式 也是一样的道理~~~

  • 相关阅读:
    jquery自调用匿名函数解析
    C# 分页
    C#一般处理程序获取Session
    Python全栈开发,Day12
    Python全栈开发,Day11
    Python全栈开发,Day10
    Python全栈开发,Day9
    Python全栈开发,Day8
    Python全栈开发,Day7
    Python全栈开发,Day6
  • 原文地址:https://www.cnblogs.com/liyouming/p/7943501.html
Copyright © 2011-2022 走看看