本文整理汇总了C#中Microsoft.Owin.Security.OAuth.OAuthValidateClientRedirectUriContext类的典型用法代码示例。如果您正苦于以下问题:C# OAuthValidateClientRedirectUriContext类的具体用法?C# OAuthValidateClientRedirectUriContext怎么用?C# OAuthValidateClientRedirectUriContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OAuthValidateClientRedirectUriContext类属于Microsoft.Owin.Security.OAuth命名空间,在下文中一共展示了OAuthValidateClientRedirectUriContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ValidateClientRedirectUri
public override Task ValidateClientRedirectUri(OAuthValidateClientRedirectUriContext context)
{
if (context.ClientId == _publicClientId)
context.Validated();
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
private Task ValidateClientRedirectUri(OAuthValidateClientRedirectUriContext context)
{
if (context.ClientId == ClientId)
{
context.Validated();
}
return Task.FromResult(0);
}
示例4: ValidateClientRedirectUri
public override Task ValidateClientRedirectUri(OAuthValidateClientRedirectUriContext context)
{
if (context.ClientId != _publicClientId) return Task.FromResult<object>(null);
var expectedRootUri = new Uri(context.Request.Uri, "/");
if (expectedRootUri.AbsoluteUri == context.RedirectUri) context.Validated();
return Task.FromResult<object>(null);
}
示例5: ValidateClientRedirectUri
public override Task ValidateClientRedirectUri(OAuthValidateClientRedirectUriContext context)
{
Uri uri;
if (Uri.TryCreate(context.RedirectUri, UriKind.Absolute, out uri))
{
context.Validated();
return Task.FromResult(0);
}
return base.ValidateClientRedirectUri(context);
}
示例6: ValidateClientRedirectUri
public override Task ValidateClientRedirectUri(OAuthValidateClientRedirectUriContext context)
{
if (context.ClientId == _publicClientId) {
Uri expectedRootUri = new Uri(context.Request.Uri, "/externalLogin"); // modified by Stephen
if (expectedRootUri.AbsoluteUri == context.RedirectUri) {
context.Validated();
}
}
return Task.FromResult<object>(null);
}
示例7: ValidateClientRedirectUri
public override Task ValidateClientRedirectUri(OAuthValidateClientRedirectUriContext context)
{
if (context.ClientId != _publicClientId) return null;
var expectedRootUri = new Uri(context.Request.Uri, "/");
if (expectedRootUri.AbsoluteUri == context.RedirectUri)
{
context.Validated();
}
return null;
}
示例8: ValidateClientRedirectUri
public override Task ValidateClientRedirectUri(OAuthValidateClientRedirectUriContext context)
{
if (context.ClientId == _publicClientId)
{
Uri expectedRootUri = FullRootUri(HttpContext.Current);
if (expectedRootUri.AbsoluteUri == context.RedirectUri)
{
context.Validated();
}
}
return Task.FromResult<object>(null);
}
示例9: ValidateClientRedirectUri
public override Task ValidateClientRedirectUri(OAuthValidateClientRedirectUriContext context)
{
if (context.ClientId == _publicClientId)
{
Uri expectedRootUri = new Uri(context.Request.Uri, "/");
if (true /*expectedRootUri.AbsoluteUri == context.RedirectUri*/)
{
context.Validated();
}
}
return Task.FromResult<object>(null);
}
示例10: ValidateClientRedirectUri
public override Task ValidateClientRedirectUri(OAuthValidateClientRedirectUriContext context)
{
if (context.ClientId == "self")
{
var expectedRootUri = new Uri(context.Request.Uri, "/");
if (expectedRootUri.AbsoluteUri == context.RedirectUri)
{
context.Validated();
}
}
return Task.FromResult(0);
}
示例11: ValidateClientRedirectUri
public override Task ValidateClientRedirectUri(OAuthValidateClientRedirectUriContext context)
{
if (context.ClientId == publicClientId)
{
Uri expectedRootUri = new Uri(context.Request.Uri, "/" + this.externalAuthPageUrl);
if (expectedRootUri.AbsoluteUri == context.RedirectUri)
{
context.Validated();
}
}
return Task.FromResult<object>(null);
}
示例12: ValidateClientRedirectUri
public override System.Threading.Tasks.Task ValidateClientRedirectUri(OAuthValidateClientRedirectUriContext context)
{
if (context.ClientId == _publicClientId)
{
Uri expectedRootUri = new Uri(context.Request.Uri, "/");
if (expectedRootUri.AbsoluteUri == context.RedirectUri)
{
context.Validated();
}
}
return System.Threading.Tasks.Task.FromResult<object>(null);
}
示例13: ValidateClientRedirectUri
public override Task ValidateClientRedirectUri(OAuthValidateClientRedirectUriContext context)
{
if (context.ClientId == _publicClientId)
{
Uri expectedRootUri = new Uri(context.Request.Uri, "/");
Uri redirectUri = new Uri(context.RedirectUri);
if (expectedRootUri.Authority == redirectUri.Authority)
{
context.Validated();
}
}
return Task.FromResult<object>(null);
}
示例14: ValidateClientRedirectUri
public override Task ValidateClientRedirectUri(OAuthValidateClientRedirectUriContext context)
{
//if (context.ClientId == _publicClientId)
//{
// Uri expectedRootUri = new Uri(context.Request.Uri, "/");
// if (expectedRootUri.AbsoluteUri == context.RedirectUri)
// {
// context.Validated();
// }
//}
if (context.ClientId == _publicClientId)
{
context.Validated();
}
return Task.FromResult<object>(null);
}
示例15: ValidateClientRedirectUri
public override Task ValidateClientRedirectUri(OAuthValidateClientRedirectUriContext context)
{
if (context.ClientId != _publicClientId)
{
return Task.FromResult(0);
}
Uri expectedRootUri = new Uri(context.Request.Uri, "/");
string windowsStoreRedirectUri = ConfigurationManager.AppSettings["windowsStoreRedirectUri"];
if (expectedRootUri.AbsoluteUri == context.RedirectUri ||
(windowsStoreRedirectUri != null && new Uri(windowsStoreRedirectUri).AbsoluteUri == context.RedirectUri))
{
context.Validated();
}
return Task.FromResult(0);
}