本文整理汇总了C#中Microsoft.Owin.Security.OAuth.OAuthValidateClientRedirectUriContext.Rejected方法的典型用法代码示例。如果您正苦于以下问题:C# OAuthValidateClientRedirectUriContext.Rejected方法的具体用法?C# OAuthValidateClientRedirectUriContext.Rejected怎么用?C# OAuthValidateClientRedirectUriContext.Rejected使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Owin.Security.OAuth.OAuthValidateClientRedirectUriContext
的用法示例。
在下文中一共展示了OAuthValidateClientRedirectUriContext.Rejected方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ValidateClientRedirectUri
public override Task ValidateClientRedirectUri(OAuthValidateClientRedirectUriContext context)
{
var authCookie = context.Request.Cookies[FormsAuthentication.FormsCookieName];
var authTicket = FormsAuthentication.Decrypt(authCookie);
if (authTicket.Expired)
context.Rejected();
else
context.Validated();
//We validated that Client Id and Reditect Uri are indeed what we expect
//if (context.ClientId == "123456" && context.RedirectUri.Contains("localhost"))
// context.Validated();
//else
// context.Rejected();
return Task.FromResult<object>(null);
}
示例2: ValidateClientRedirectUri
/// <summary>
/// Called to validate that the context.ClientId is a registered "client_id", and that the context.RedirectUri a "redirect_uri"
/// registered for that client. This only occurs when processing the Authorize endpoint. The application MUST implement this
/// call, and it MUST validate both of those factors before calling context.Validated. If the context.Validated method is called
/// with a given redirectUri parameter, then IsValidated will only become true if the incoming redirect URI matches the given redirect URI.
/// If context.Validated is not called the request will not proceed further.
/// </summary>
/// <param name="context">The context of the event carries information in and results out.</param>
/// <returns>Task to enable asynchronous execution</returns>
public override async Task ValidateClientRedirectUri(OAuthValidateClientRedirectUriContext context)
{
this.options.Logger.DebugFormat("Validating client id and redirect uri");
// Only proceed if client id and redirect uri is provided
if (string.IsNullOrEmpty(context.ClientId) || string.IsNullOrEmpty(context.RedirectUri))
{
this.options.Logger.WarnFormat("Client id ({0}) or client secret ({1}) is invalid", context.ClientId, context.RedirectUri);
return;
}
this.options.Logger.DebugFormat("Authenticating client '{0}' and redirect uri '{1}'", context.ClientId, context.RedirectUri);
var client = await this.options.ClientManager.AuthenticateClientAsync(context.ClientId, context.RedirectUri);
if (!client.Identity.IsAuthenticated)
{
context.Rejected();
this.options.Logger.WarnFormat("Client '{0}' and redirect uri '{1}' was not authenticated", context.ClientId, context.RedirectUri);
return;
}
this.options.Logger.DebugFormat("Client '{0}' and redirect uri '{1}' was successfully authenticated", context.ClientId, context.RedirectUri);
context.OwinContext.GetOAuthContext().ClientId = context.ClientId;
context.OwinContext.GetOAuthContext().RedirectUri = context.RedirectUri;
context.Validated(context.RedirectUri);
}
示例3: ValidateClientRedirectUri
public override async Task ValidateClientRedirectUri(OAuthValidateClientRedirectUriContext context)
{
var app =
await new ApplicationDbContext().Apps.FirstOrDefaultAsync(c => c.ClientId == context.ClientId);
if (app != null)
{
context.Validated(app.RedirectUrl);
}
else
{
context.Rejected();
}
}