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

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

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

 

转载于:https://www.cnblogs.com/liyouming/p/7943501.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值