zoukankan      html  css  js  c++  java
  • 1、IdentityServer4

    使用IdentityServer的起点!

    安装 IdentityServer4 模板

    dotnet new -i IdentityServer4.Template

    1、IdentityServer4

    创建IdentityServer4项目:   dotnet new is4empty -n 项目名                   运行:https://localhost:5001/.well-known/openid-configuration

    定义及配置要保护的API

    public static class Config
    {
        public static IEnumerable<ApiScope> ApiScopes =>
            new List<ApiScope>
            {
                new ApiScope("api1", "My API")
            };
    }
    View Code

    定义客户端  (ClientId,ClientSecret 可以视为用户名密码)

    public static IEnumerable<Client> Clients =>
        new List<Client>
        {
            new Client
            {
                ClientId = "client",  
                // no interactive user, use the clientid/secret for authentication
                AllowedGrantTypes = GrantTypes.ClientCredentials,
                // secret for authentication
                ClientSecrets =  { new Secret("secret".Sha256()) },
                // scopes that client has access to
                AllowedScopes = { "api1" }
            }
        };
    View Code

    首次启动时,IdentityServer将为您创建一个开发人员签名密钥,该文件名为tempkey.jwk。您不必将该文件签入源代码管理中,如果不存在该文件将被重新创建

    配置IdentityServer

     





  • 相关阅读:
    java 求 1!+2!+3!+....+10!的和为
    Java 循环控制语句
    java for 循环 九九乘法表
    Java for 循环
    Java while 和 do...while
    Java if语句
    Java switch 语句
    java a++ 和 ++a 理解
    Java 自动转换和强制转换
    二叉树遍历
  • 原文地址:https://www.cnblogs.com/mingjing/p/14028798.html
Copyright © 2011-2022 走看看