本文整理汇总了C#中OwinContext.ReadRequestFormAsync方法的典型用法代码示例。如果您正苦于以下问题:C# OwinContext.ReadRequestFormAsync方法的具体用法?C# OwinContext.ReadRequestFormAsync怎么用?C# OwinContext.ReadRequestFormAsync使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OwinContext
的用法示例。
在下文中一共展示了OwinContext.ReadRequestFormAsync方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseAsync
/// <summary>
/// Tries to find a secret on the environment that can be used for authentication
/// </summary>
/// <param name="environment">The environment.</param>
/// <returns>
/// A parsed secret
/// </returns>
public async Task<ParsedSecret> ParseAsync(IDictionary<string, object> environment)
{
Logger.Debug("Start parsing for secret in post body");
var context = new OwinContext(environment);
var body = await context.ReadRequestFormAsync();
if (body != null)
{
var id = body.Get("client_id");
var secret = body.Get("client_secret");
if (id.IsPresent() && secret.IsPresent())
{
var parsedSecret = new ParsedSecret
{
Id = id,
Credential = secret,
Type = Constants.ParsedSecretTypes.SharedSecret
};
return parsedSecret;
}
}
Logger.Debug("No secet in post body found");
return null;
}
示例2: ParseAsync
/// <summary>
/// Tries to find a secret on the environment that can be used for authentication
/// </summary>
/// <param name="environment">The environment.</param>
/// <returns>
/// A parsed secret
/// </returns>
public async Task<ParsedSecret> ParseAsync(IDictionary<string, object> environment)
{
Logger.Debug("Start parsing for X.509 certificate");
var context = new OwinContext(environment);
var body = await context.ReadRequestFormAsync();
if (body == null)
{
return null;
}
var id = body.Get("client_id");
if (id.IsMissing())
{
Logger.Debug("client_id is not found in post body");
return null;
}
var cert = context.Get<X509Certificate2>("ssl.ClientCertificate");
if (cert != null)
{
return new ParsedSecret
{
Id = id,
Credential = cert,
Type = Constants.ParsedSecretTypes.X509Certificate
};
}
Logger.Debug("X.509 certificate not found.");
return null;
}
示例3: ParseAsync
/// <summary>
/// Tries to find a JWT client assertion token on the environment that can be used for authentication
/// Used for "private_key_jwt" client authentication method as defined in http://openid.net/specs/openid-connect-core-1_0.html#ClientAuthentication
/// </summary>
/// <param name="environment">The environment.</param>
/// <returns>
/// A parsed secret
/// </returns>
public async Task<ParsedSecret> ParseAsync(IDictionary<string, object> environment)
{
Logger.Debug("Start parsing for JWT client assertion in post body");
var context = new OwinContext(environment);
var body = await context.ReadRequestFormAsync();
if (body != null)
{
var clientId = body.Get(Constants.TokenRequest.ClientId);
var clientAssertionType = body.Get(Constants.TokenRequest.ClientAssertionType);
var clientAssertion = body.Get(Constants.TokenRequest.ClientAssertion);
if (clientAssertion.IsPresent()
&& clientAssertionType == Constants.ClientAssertionTypes.JwtBearer)
{
if (!clientId.IsPresent())
{
// at least some clients (i.e. java com.nimbusds/oauth2-oidc-sdk) do not send client_id, but assume that token is enough (and it actually is)
clientId = GetClientIdFromToken(clientAssertion);
if (!clientId.IsPresent())
{
return null;
}
}
var parsedSecret = new ParsedSecret
{
Id = clientId,
Credential = clientAssertion,
Type = Constants.ParsedSecretTypes.JwtBearer
};
return parsedSecret;
}
}
Logger.Debug("No JWT client assertion found in post body");
return null;
}