• 一步一步学习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"
                    }
                });

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

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

  • 相关阅读:
    渗透脚本快速生成工具Intersect
    Visual Studio 2017创建XAML文件
    Windows命令远程执行工具Winexe
    解决Visual Studio 2017隐藏“高级保存选项”命令
    Web应用扫描测试工具Vega
    网易轮播图
    Dom
    通过克隆实现无缝滚动轮播图
    函数
    boostrap
  • 原文地址:https://www.cnblogs.com/liyouming/p/7943501.html
Copyright © 2020-2023  润新知