diff --git a/samples/SocialSample/SocialSample.kproj b/samples/SocialSample/SocialSample.kproj
index 982c0c8f5f..2d3d1caf5f 100644
--- a/samples/SocialSample/SocialSample.kproj
+++ b/samples/SocialSample/SocialSample.kproj
@@ -21,7 +21,7 @@
2.0
- 50113
+ 12345
\ No newline at end of file
diff --git a/samples/SocialSample/Startup.cs b/samples/SocialSample/Startup.cs
index 35480c1cc3..18f17ac0f7 100644
--- a/samples/SocialSample/Startup.cs
+++ b/samples/SocialSample/Startup.cs
@@ -28,7 +28,6 @@ namespace CookieSample
{
services.ConfigureOptions(options =>
{
-
options.SignInAsAuthenticationType = CookieAuthenticationDefaults.AuthenticationType;
});
});
diff --git a/samples/SocialSample/project.json b/samples/SocialSample/project.json
index 84bb6d1c95..40f05e17c5 100644
--- a/samples/SocialSample/project.json
+++ b/samples/SocialSample/project.json
@@ -7,6 +7,7 @@
"Microsoft.AspNet.Security.Google": "1.0.0-*",
"Microsoft.AspNet.Security.MicrosoftAccount": "1.0.0-*",
"Microsoft.AspNet.Security.Twitter": "1.0.0-*",
+ "Microsoft.AspNet.Server.IIS": "1.0.0-*",
"Microsoft.AspNet.Server.WebListener": "1.0.0-*",
"Microsoft.Framework.DependencyInjection": "1.0.0-*",
"Microsoft.Framework.OptionsModel": "1.0.0-*"
diff --git a/src/Microsoft.AspNet.Security.OAuth/Notifications/BaseValidatingContext.cs b/src/Microsoft.AspNet.Security.OAuth/Notifications/BaseValidatingContext.cs
new file mode 100644
index 0000000000..0957d9fd61
--- /dev/null
+++ b/src/Microsoft.AspNet.Security.OAuth/Notifications/BaseValidatingContext.cs
@@ -0,0 +1,114 @@
+// 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 Microsoft.AspNet.Http;
+using Microsoft.AspNet.Security.Notifications;
+
+namespace Microsoft.AspNet.Security.OAuth
+{
+ ///
+ /// Base class used for certain event contexts
+ ///
+ public abstract class BaseValidatingContext : BaseContext
+ {
+ ///
+ /// Initializes base class used for certain event contexts
+ ///
+ protected BaseValidatingContext(
+ HttpContext context,
+ TOptions options)
+ : base(context, options)
+ {
+ }
+
+ ///
+ /// True if application code has called any of the Validate methods on this context.
+ ///
+ public bool IsValidated { get; private set; }
+
+ ///
+ /// True if application code has called any of the SetError methods on this context.
+ ///
+ public bool HasError { get; private set; }
+
+ ///
+ /// The error argument provided when SetError was called on this context. This is eventually
+ /// returned to the client app as the OAuth "error" parameter.
+ ///
+ public string Error { get; private set; }
+
+ ///
+ /// The optional errorDescription argument provided when SetError was called on this context. This is eventually
+ /// returned to the client app as the OAuth "error_description" parameter.
+ ///
+ public string ErrorDescription { get; private set; }
+
+ ///
+ /// The optional errorUri argument provided when SetError was called on this context. This is eventually
+ /// returned to the client app as the OAuth "error_uri" parameter.
+ ///
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings", Justification = "error_uri is a string value in the protocol")]
+ public string ErrorUri { get; private set; }
+
+ ///
+ /// Marks this context as validated by the application. IsValidated becomes true and HasError becomes false as a result of calling.
+ ///
+ /// True if the validation has taken effect.
+ public virtual bool Validated()
+ {
+ IsValidated = true;
+ HasError = false;
+ return true;
+ }
+
+ ///
+ /// Marks this context as not validated by the application. IsValidated and HasError become false as a result of calling.
+ ///
+ public virtual void Rejected()
+ {
+ IsValidated = false;
+ HasError = false;
+ }
+
+ ///
+ /// Marks this context as not validated by the application and assigns various error information properties.
+ /// HasError becomes true and IsValidated becomes false as a result of calling.
+ ///
+ /// Assigned to the Error property
+ public void SetError(string error)
+ {
+ SetError(error, null);
+ }
+
+ ///
+ /// Marks this context as not validated by the application and assigns various error information properties.
+ /// HasError becomes true and IsValidated becomes false as a result of calling.
+ ///
+ /// Assigned to the Error property
+ /// Assigned to the ErrorDescription property
+ public void SetError(string error,
+ string errorDescription)
+ {
+ SetError(error, errorDescription, null);
+ }
+
+ ///
+ /// Marks this context as not validated by the application and assigns various error information properties.
+ /// HasError becomes true and IsValidated becomes false as a result of calling.
+ ///
+ /// Assigned to the Error property
+ /// Assigned to the ErrorDescription property
+ /// Assigned to the ErrorUri property
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "2#", Justification = "error_uri is a string value in the protocol")]
+ public void SetError(string error,
+ string errorDescription,
+ string errorUri)
+ {
+ Error = error;
+ ErrorDescription = errorDescription;
+ ErrorUri = errorUri;
+ Rejected();
+ HasError = true;
+ }
+ }
+}
diff --git a/src/Microsoft.AspNet.Security.OAuth/Notifications/BaseValidatingTicketContext.cs b/src/Microsoft.AspNet.Security.OAuth/Notifications/BaseValidatingTicketContext.cs
new file mode 100644
index 0000000000..c6528619bc
--- /dev/null
+++ b/src/Microsoft.AspNet.Security.OAuth/Notifications/BaseValidatingTicketContext.cs
@@ -0,0 +1,58 @@
+// 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.Security.Claims;
+using Microsoft.AspNet.Http;
+using Microsoft.AspNet.Http.Security;
+
+namespace Microsoft.AspNet.Security.OAuth
+{
+ ///
+ /// Base class used for certain event contexts
+ ///
+ public abstract class BaseValidatingTicketContext : BaseValidatingContext
+ {
+ ///
+ /// Initializes base class used for certain event contexts
+ ///
+ protected BaseValidatingTicketContext(
+ HttpContext context,
+ TOptions options,
+ AuthenticationTicket ticket)
+ : base(context, options)
+ {
+ Ticket = ticket;
+ }
+
+ ///
+ /// Contains the identity and properties for the application to authenticate. If the Validated method
+ /// is invoked with an AuthenticationTicket or ClaimsIdentity argument, that new value is assigned to
+ /// this property in addition to changing IsValidated to true.
+ ///
+ public AuthenticationTicket Ticket { get; private set; }
+
+ ///
+ /// Replaces the ticket information on this context and marks it as as validated by the application.
+ /// IsValidated becomes true and HasError becomes false as a result of calling.
+ ///
+ /// Assigned to the Ticket property
+ /// True if the validation has taken effect.
+ public bool Validated(AuthenticationTicket ticket)
+ {
+ Ticket = ticket;
+ return Validated();
+ }
+
+ ///
+ /// Alters the ticket information on this context and marks it as as validated by the application.
+ /// IsValidated becomes true and HasError becomes false as a result of calling.
+ ///
+ /// Assigned to the Ticket.Identity property
+ /// True if the validation has taken effect.
+ public bool Validated(ClaimsIdentity identity)
+ {
+ AuthenticationProperties properties = Ticket != null ? Ticket.Properties : new AuthenticationProperties();
+ return Validated(new AuthenticationTicket(identity, properties));
+ }
+ }
+}
diff --git a/src/Microsoft.AspNet.Security.OAuth/Notifications/IOAuthBearerAuthenticationNotifications.cs b/src/Microsoft.AspNet.Security.OAuth/Notifications/IOAuthBearerAuthenticationNotifications.cs
new file mode 100644
index 0000000000..048d8f2927
--- /dev/null
+++ b/src/Microsoft.AspNet.Security.OAuth/Notifications/IOAuthBearerAuthenticationNotifications.cs
@@ -0,0 +1,37 @@
+// 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.Threading.Tasks;
+
+namespace Microsoft.AspNet.Security.OAuth
+{
+ ///
+ /// Specifies callback methods which the invokes to enable developer control over the authentication process. />
+ ///
+ public interface IOAuthBearerAuthenticationNotifications
+ {
+ ///
+ /// Invoked before the is created. Gives the application an
+ /// opportunity to find the identity from a different location, adjust, or reject the token.
+ ///
+ /// Contains the token string.
+ /// A representing the completed operation.
+ Task RequestToken(OAuthRequestTokenContext context);
+
+ ///
+ /// Called each time a request identity has been validated by the middleware. By implementing this method the
+ /// application may alter or reject the identity which has arrived with the request.
+ ///
+ /// Contains information about the login session as well as the user .
+ /// A representing the completed operation.
+ Task ValidateIdentity(OAuthValidateIdentityContext context);
+
+ ///
+ /// Called each time a challenge is being sent to the client. By implementing this method the application
+ /// may modify the challenge as needed.
+ ///
+ /// Contains the default challenge.
+ /// A representing the completed operation.
+ Task ApplyChallenge(OAuthChallengeContext context);
+ }
+}
diff --git a/src/Microsoft.AspNet.Security.OAuth/Notifications/OAuthAuthenticatedContext.cs b/src/Microsoft.AspNet.Security.OAuth/Notifications/OAuthAuthenticatedContext.cs
index a651767e8e..5817071536 100644
--- a/src/Microsoft.AspNet.Security.OAuth/Notifications/OAuthAuthenticatedContext.cs
+++ b/src/Microsoft.AspNet.Security.OAuth/Notifications/OAuthAuthenticatedContext.cs
@@ -3,7 +3,6 @@
using System;
using System.Globalization;
-using System.Net.Http;
using System.Security.Claims;
using Microsoft.AspNet.Http;
using Microsoft.AspNet.Http.Security;
diff --git a/src/Microsoft.AspNet.Security.OAuth/Notifications/OAuthBearerAuthenticationNotifications.cs b/src/Microsoft.AspNet.Security.OAuth/Notifications/OAuthBearerAuthenticationNotifications.cs
new file mode 100644
index 0000000000..2c24f3ff1f
--- /dev/null
+++ b/src/Microsoft.AspNet.Security.OAuth/Notifications/OAuthBearerAuthenticationNotifications.cs
@@ -0,0 +1,73 @@
+// 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;
+
+namespace Microsoft.AspNet.Security.OAuth
+{
+ ///
+ /// OAuth bearer token middleware provider
+ ///
+ public class OAuthBearerAuthenticationNotifications : IOAuthBearerAuthenticationNotifications
+ {
+ ///
+ /// Initializes a new instance of the class
+ ///
+ public OAuthBearerAuthenticationNotifications()
+ {
+ OnRequestToken = context => Task.FromResult