Defining Clients 定义客户端

客户端表示哪些可以从你的IdentityServer拿到token的应用。

除了一些可能会变化的细节之外,通常情况下你需要为一个客户端定义如下通用的设置:

  • 一个唯一的client id
  • 一个secret(如果需要的话)
  • 被允许与token service的交互(也叫做授权类型,grant type)
  • 一个网络位置,其中标识和/或访问令牌被发送到(称为重定向URI)的地方
  • 客户端被允许访问的范围(即资源)列表

在运行时,定义的clients(客户端列表)通过一个实现了IClientStore的对象来进行访问。允许从任何数据源加载他们(clients)。在这个文档中我们使用的是内存中的实现。你可以在StartUp类中的ConfigureService方法中调用AddInmemoryClients扩展方法来进行注册服务。

Defining a client for server to server communication 定义一个客户端作为服务到服务的通信

这个场景下不存在交互的用户,就是一个服务(也叫客户端)想要访问一个Api(也叫范围)。

public class Clients
{
public static IEnumerable<Client> GetClients()
{
return new List<Client>
{
new Client
{
ClientId = "service.client",
ClientSecrets = { new Secret("secret".Sha256()) }, AllowedGrantTypes = GrantTypes.ClientCredentials,
AllowedScopes = { "api1", "api2.read_only" }
}
};
}
}

Defining browser-based JavaScript client (e.g. SPA) for user authentication and delegated access and API  定义基于浏览器的JavaScript客户端(例如SPA),用于用户身份验证、委托访问和API

这种客户端从javascript利用所谓的implicit flow流程(属于OAuth2.0的范畴,共有四种流程分别是Aothorization code、Implicit、ResourceOwnerPassword、ClientCredential,请参考相应文档)来请求一个id token和access token:

var jsClient = new Client
{
ClientId = "js",
ClientName = "JavaScript Client",
ClientUri = "http://identityserver.io", AllowedGrantTypes = GrantTypes.Implicit,
AllowAccessTokensViaBrowser = true, RedirectUris = { "http://localhost:7017/index.html" },
PostLogoutRedirectUris = { "http://localhost:7017/index.html" },
AllowedCorsOrigins = { "http://localhost:7017" }, AllowedScopes =
{
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile,
IdentityServerConstants.StandardScopes.Email, "api1", "api2.read_only"
}
};

Defining a server-side web application (e.g. MVC) for use authentication and delegated API access  定义一个服务器端web应用程序(例如MVC),用于使用身份验证和委托的API访问

交互式服务器端(或本机桌面/移动)应用程序使用混合流(Authorization code和Implicit混合)。这种流提供了最好的安全性,因为存取令牌仅通过反向通道(back-channel)调用传输(并且允许您访问刷新令牌):

var mvcClient = new Client
{
ClientId = "mvc",
ClientName = "MVC Client",
ClientUri = "http://identityserver.io", AllowedGrantTypes = GrantTypes.Hybrid,
AllowOfflineAccess = true,
ClientSecrets = { new Secret("secret".Sha256()) }, RedirectUris = { "http://localhost:21402/signin-oidc" },
PostLogoutRedirectUris = { "http://localhost:21402/" },
FrontChannelLogoutUri = "http://localhost:21402/signout-oidc", AllowedScopes =
{
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile,
IdentityServerConstants.StandardScopes.Email, "api1", "api2.read_only"
},
};

IdentityServer4【Topic】之定义客户端的更多相关文章

  1. IdentityServer4[3]:使用客户端认证控制API访问(客户端授权模式)

    使用客户端认证控制API访问(客户端授权模式) 场景描述 使用IdentityServer保护API的最基本场景. 我们定义一个API和要访问API的客户端.客户端从IdentityServer请求A ...

  2. 第20章 定义客户端 - Identity Server 4 中文文档(v1.0.0)

    客户端表示可以从您的身份服务器请求令牌的应用程序. 详细信息各不相同,但您通常会为客户端定义以下常用设置: 唯一的客户ID 如果需要的秘密 允许与令牌服务的交互(称为授权类型) 身份和/或访问令牌发送 ...

  3. SAP 定义客户端

    SCC4  定义客户端 点击新建条目按钮  Client(客户端) R 200 Client Name(客户端名称) O   City(城市) R   Logical system(逻辑系统) R   ...

  4. asp.net core IdentityServer4 实现 Client credentials(客户端凭证)

    前言 OAuth 2.0默认四种授权模式(GrantType) 授权码模式(authorization_code) 简化模式(implicit) 密码模式(resource owner passwor ...

  5. IdentityServer Topics(3)- 定义客户端

    客户端代表可以从您的身份服务器请求令牌的应用程序. 细节有所不同,但您通常为客户端定义以下常用设置: 一个唯一的客户端ID 一个密钥,如果需要 允许与令牌服务的交互(称为授权类型) 身份或访问令牌被发 ...

  6. IdentityServer4 学习笔记[1]-客户端授权

    前言 本文内容来自IdentityServer4官网,官网有详细的介绍,并且有源码Demo 官网源码例子传送门 建立授权服务端 我们暂时不配置Https,选择空模板建立项目,项目建立后, 为了查看de ...

  7. Windows8安装Oracle11.2.0.1-0624,附带 DBCA建库、netca创建监听、配置PLSQL、定义客户端的环境变量 NLS_LANG、定义客户端的环境变量 TNS_ADMIN01

    Windows8安装Oracle11.2.0.1                                         操作系统:Windows 8 企业版 64bit Oracle:11. ...

  8. 011 Socket定义客户端

    引入命名空间: using System.Net; using System.Net.Sockets; using System.Threading;

  9. ASP.NET Core的身份认证框架IdentityServer4(7)- 使用客户端证书控制API访问

    前言 今天(2017-9-8,写于9.8,今天才发布)一口气连续把最后几篇IdentityServer4相关理论全部翻译完了,终于可以进入写代码的过程了,比较累.目前官方的文档和Demo以及一些相关组 ...

随机推荐

  1. 【车】汽车X40保养

    参考文档: [养车成本]小保养331元,奔腾X40养车成本调查

  2. SpringCloudStream实战

    Spring Cloud Stream是一个用于构建消息驱动的微服务应用程序的框架.Spring Cloud Stream构建于Spring Boot之上,用于创建独立的生产级Spring应用程序,并 ...

  3. UVA10817-Headmaster's Headache(动态规划基础)

    Problem UVA10817-Headmaster's Headache Time Limit: 4500 mSec Problem Description Input The input con ...

  4. 吴恩达课后作业学习2-week1-1 初始化

    参考:https://blog.csdn.net/u013733326/article/details/79847918 希望大家直接到上面的网址去查看代码,下面是本人的笔记 初始化.正则化.梯度校验 ...

  5. appium遇到click事件,提示"w3cStatus":400

    1.小米手机被开发借用后归还,使用该手机再进行自动化,发现appium遇到click事件,返回400 2.当时未想到是要在手机侧进行开发者选项-调试权限的设置 3.一直以为是appium的问题,app ...

  6. Spring Security(二十一):6.3 Advanced Web Features

    6.3.1 Remember-Me Authentication (记住我的身份验证) See the separate Remember-Me chapter for information on ...

  7. WPF Binding学习(三)

    转自;http://blog.csdn.net/lisenyang/article/details/18312199 1.控件与控件间的双向绑定 WPF还支持控件作为数据源, <TextBox ...

  8. java将秒转换为时分秒工具类

    需要一个接收时分秒的对象,如下: package com.dq.schoolcontract.utils; import com.sun.media.jfxmedia.control.VideoRen ...

  9. odoo常用widget

      widget=”statusbar” 头部状态条标签widget=”email” 电子邮件地址标签widget=”selection” 下拉选择标签widget=”mail_followers” ...

  10. Asp.net MVC 利用(aspose+pdfobject.js) 实现在线预览word、excel、ppt、pdf文件

    在线预览word.excel.ppt利用aspose动态生成html 主要代码 private bool OfficeDocumentToHtml(string sourceDoc, string s ...