zoukankan      html  css  js  c++  java
  • 第2章 授权端点(Authorize Endpoint)

    对于大多数情况,OAuth 2.0OpenID Connect授权端点的GET请求需要具有许多查询字符串参数。

    虽然您可以使用任何方法创建带参数的URL来创建正确的字符串,但RequestUrl类是完成此任务的简单帮助程序。

    特别是,您可以使用CreateAuthorizeUrl扩展方法为授权端点创建URL - 它支持最常用的参数:

    /// <summary>
    /// Creates an authorize URL.
    /// </summary>
    /// <param name="request">The request.</param>
    /// <param name="clientId">The client identifier.</param>
    /// <param name="responseType">The response type.</param>
    /// <param name="scope">The scope.</param>
    /// <param name="redirectUri">The redirect URI.</param>
    /// <param name="state">The state.</param>
    /// <param name="nonce">The nonce.</param>
    /// <param name="loginHint">The login hint.</param>
    /// <param name="acrValues">The acr values.</param>
    /// <param name="prompt">The prompt.</param>
    /// <param name="responseMode">The response mode.</param>
    /// <param name="codeChallenge">The code challenge.</param>
    /// <param name="codeChallengeMethod">The code challenge method.</param>
    /// <param name="display">The display option.</param>
    /// <param name="maxAge">The max age.</param>
    /// <param name="uiLocales">The ui locales.</param>
    /// <param name="idTokenHint">The id_token hint.</param>
    /// <param name="extra">Extra parameters.</param>
    /// <returns></returns>
    public static string CreateAuthorizeUrl(this RequestUrl request,
        string clientId,
        string responseType,
        string scope = null,
        string redirectUri = null,
        string state = null,
        string nonce = null,
        string loginHint = null,
        string acrValues = null,
        string prompt = null,
        string responseMode = null,
        string codeChallenge = null,
        string codeChallengeMethod = null,
        string display = null,
        int? maxAge = null,
        string uiLocales = null,
        string idTokenHint = null,
        object extra = null)
    { ... }
    

    例:

    var ru = new RequestUrl("https://demo.identityserver.io/connect/authorize");
    
    var url = ru.CreateAuthorizeUrl(
        clientId: "client",
        responseType: "implicit",
        redirectUri: "https://app.com/callback",
        nonce: "xyz",
        scope: "openid");
    
    

    注意
    extra参数可以是一个串字典或任意其它具有属性的类型。在这两种情况下,值都将序列化为键/值。

    github地址

  • 相关阅读:
    springboot文件上传: 单个文件上传 和 多个文件上传
    Eclipse:很不错的插件-devStyle,将你的eclipse变成idea风格
    springboot项目搭建:结构和入门程序
    POJ 3169 Layout 差分约束系统
    POJ 3723 Conscription 最小生成树
    POJ 3255 Roadblocks 次短路
    UVA 11367 Full Tank? 最短路
    UVA 10269 Adventure of Super Mario 最短路
    UVA 10603 Fill 最短路
    POJ 2431 Expedition 优先队列
  • 原文地址:https://www.cnblogs.com/thinksjay/p/10787621.html
Copyright © 2011-2022 走看看