// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Threading.Tasks;
using Microsoft.AspNet.Http;
using Microsoft.AspNet.Security.Notifications;
///
/// Specifies events which the invokes to enable developer control over the authentication process. />
///
namespace Microsoft.AspNet.Security.OAuthBearer
{
///
/// OAuth bearer token middleware provider
///
public class OAuthBearerAuthenticationNotifications
{
///
/// Initializes a new instance of the class
///
public OAuthBearerAuthenticationNotifications()
{
ApplyChallenge = notification => { notification.HttpContext.Response.Headers.AppendValues("WWW-Authenticate", notification.Options.Challenge); return Task.FromResult(0); };
AuthenticationFailed = notification => Task.FromResult(0);
MessageReceived = notification => Task.FromResult(0);
SecurityTokenReceived = notification => Task.FromResult(0);
SecurityTokenValidated = notification => Task.FromResult(0);
}
///
/// Invoked if exceptions are thrown during request processing. The exceptions will be re-thrown after this event unless suppressed.
///
public Func, Task> AuthenticationFailed { get; set; }
///
/// Invoked when a protocol message is first received.
///
public Func, Task> MessageReceived { get; set; }
///
/// Invoked with the security token that has been extracted from the protocol message.
///
public Func, Task> SecurityTokenReceived { get; set; }
///
/// Invoked after the security token has passed validation and a ClaimsIdentity has been generated.
///
public Func, Task> SecurityTokenValidated { get; set; }
///
/// Invoked to apply a challenge sent back to the caller.
///
public Func, Task> ApplyChallenge { get; set; }
}
}