diff --git a/Owin.Security.Providers/Owin.Security.Providers.csproj b/Owin.Security.Providers/Owin.Security.Providers.csproj
index 34714d3..e43b426 100644
--- a/Owin.Security.Providers/Owin.Security.Providers.csproj
+++ b/Owin.Security.Providers/Owin.Security.Providers.csproj
@@ -68,6 +68,19 @@
True
Resources.resx
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Owin.Security.Providers/Yahoo/Constants.cs b/Owin.Security.Providers/Yahoo/Constants.cs
new file mode 100644
index 0000000..327c544
--- /dev/null
+++ b/Owin.Security.Providers/Yahoo/Constants.cs
@@ -0,0 +1,9 @@
+// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
+
+namespace Owin.Security.Providers.Yahoo
+{
+ internal static class Constants
+ {
+ public const string DefaultAuthenticationType = "Yahoo";
+ }
+}
diff --git a/Owin.Security.Providers/Yahoo/Messages/AccessToken.cs b/Owin.Security.Providers/Yahoo/Messages/AccessToken.cs
new file mode 100644
index 0000000..468866f
--- /dev/null
+++ b/Owin.Security.Providers/Yahoo/Messages/AccessToken.cs
@@ -0,0 +1,15 @@
+// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
+
+namespace Owin.Security.Providers.Yahoo.Messages
+{
+ ///
+ /// Yahoo access token
+ ///
+ public class AccessToken : RequestToken
+ {
+ ///
+ /// Gets or sets the Yahoo User ID
+ ///
+ public string UserId { get; set; }
+ }
+}
diff --git a/Owin.Security.Providers/Yahoo/Messages/RequestToken.cs b/Owin.Security.Providers/Yahoo/Messages/RequestToken.cs
new file mode 100644
index 0000000..a0e9d8c
--- /dev/null
+++ b/Owin.Security.Providers/Yahoo/Messages/RequestToken.cs
@@ -0,0 +1,29 @@
+// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
+
+using Microsoft.Owin.Security;
+
+namespace Owin.Security.Providers.Yahoo.Messages
+{
+ ///
+ /// Yahoo request token
+ ///
+ public class RequestToken
+ {
+ ///
+ /// Gets or sets the Yahoo token
+ ///
+ public string Token { get; set; }
+
+ ///
+ /// Gets or sets the Yahoo token secret
+ ///
+ public string TokenSecret { get; set; }
+
+ public bool CallbackConfirmed { get; set; }
+
+ ///
+ /// Gets or sets a property bag for common authentication properties
+ ///
+ public AuthenticationProperties Properties { get; set; }
+ }
+}
diff --git a/Owin.Security.Providers/Yahoo/Messages/RequestTokenSerializer.cs b/Owin.Security.Providers/Yahoo/Messages/RequestTokenSerializer.cs
new file mode 100644
index 0000000..1aa9325
--- /dev/null
+++ b/Owin.Security.Providers/Yahoo/Messages/RequestTokenSerializer.cs
@@ -0,0 +1,106 @@
+// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
+
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.IO;
+using Microsoft.Owin.Security;
+using Microsoft.Owin.Security.DataHandler.Serializer;
+
+namespace Owin.Security.Providers.Yahoo.Messages
+{
+ ///
+ /// Serializes and deserializes Yahoo request and access tokens so that they can be used by other application components.
+ ///
+ public class RequestTokenSerializer : IDataSerializer
+ {
+ private const int FormatVersion = 1;
+
+ ///
+ /// Serialize a request token
+ ///
+ /// The token to serialize
+ /// A byte array containing the serialized token
+ [SuppressMessage("Microsoft.Usage", "CA2202:Do not dispose objects multiple times", Justification = "Dispose is idempotent")]
+ public virtual byte[] Serialize(RequestToken model)
+ {
+ using (var memory = new MemoryStream())
+ {
+ using (var writer = new BinaryWriter(memory))
+ {
+ Write(writer, model);
+ writer.Flush();
+ return memory.ToArray();
+ }
+ }
+ }
+
+ ///
+ /// Deserializes a request token
+ ///
+ /// A byte array containing the serialized token
+ /// The Yahoo request token
+ [SuppressMessage("Microsoft.Usage", "CA2202:Do not dispose objects multiple times", Justification = "Dispose is idempotent")]
+ public virtual RequestToken Deserialize(byte[] data)
+ {
+ using (var memory = new MemoryStream(data))
+ {
+ using (var reader = new BinaryReader(memory))
+ {
+ return Read(reader);
+ }
+ }
+ }
+
+ ///
+ /// Writes a Yahoo request token as a series of bytes. Used by the method.
+ ///
+ /// The writer to use in writing the token
+ /// The token to write
+ public static void Write(BinaryWriter writer, RequestToken token)
+ {
+ if (writer == null)
+ {
+ throw new ArgumentNullException("writer");
+ }
+ if (token == null)
+ {
+ throw new ArgumentNullException("token");
+ }
+
+ writer.Write(FormatVersion);
+ writer.Write(token.Token);
+ writer.Write(token.TokenSecret);
+ writer.Write(token.CallbackConfirmed);
+ PropertiesSerializer.Write(writer, token.Properties);
+ }
+
+ ///
+ /// Reads a Yahoo request token from a series of bytes. Used by the method.
+ ///
+ /// The reader to use in reading the token bytes
+ /// The token
+ public static RequestToken Read(BinaryReader reader)
+ {
+ if (reader == null)
+ {
+ throw new ArgumentNullException("reader");
+ }
+
+ if (reader.ReadInt32() != FormatVersion)
+ {
+ return null;
+ }
+
+ string token = reader.ReadString();
+ string tokenSecret = reader.ReadString();
+ bool callbackConfirmed = reader.ReadBoolean();
+ AuthenticationProperties properties = PropertiesSerializer.Read(reader);
+ if (properties == null)
+ {
+ return null;
+ }
+
+ return new RequestToken { Token = token, TokenSecret = tokenSecret, CallbackConfirmed = callbackConfirmed, Properties = properties };
+ }
+ }
+}
diff --git a/Owin.Security.Providers/Yahoo/Messages/Serializers.cs b/Owin.Security.Providers/Yahoo/Messages/Serializers.cs
new file mode 100644
index 0000000..7e48160
--- /dev/null
+++ b/Owin.Security.Providers/Yahoo/Messages/Serializers.cs
@@ -0,0 +1,22 @@
+// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
+
+using Microsoft.Owin.Security.DataHandler.Serializer;
+
+namespace Owin.Security.Providers.Yahoo.Messages
+{
+ ///
+ /// Provides access to a request token serializer
+ ///
+ public static class Serializers
+ {
+ static Serializers()
+ {
+ RequestToken = new RequestTokenSerializer();
+ }
+
+ ///
+ /// Gets or sets a statically-avaliable serializer object. The value for this property will be by default.
+ ///
+ public static IDataSerializer RequestToken { get; set; }
+ }
+}
diff --git a/Owin.Security.Providers/Yahoo/Provider/IYahooAuthenticationProvider.cs b/Owin.Security.Providers/Yahoo/Provider/IYahooAuthenticationProvider.cs
new file mode 100644
index 0000000..8a8594f
--- /dev/null
+++ b/Owin.Security.Providers/Yahoo/Provider/IYahooAuthenticationProvider.cs
@@ -0,0 +1,26 @@
+// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
+
+using System.Threading.Tasks;
+
+namespace Owin.Security.Providers.Yahoo
+{
+ ///
+ /// Specifies callback methods which the invokes to enable developer control over the authentication process. />
+ ///
+ public interface IYahooAuthenticationProvider
+ {
+ ///
+ /// Invoked whenever Yahoo succesfully authenticates a user
+ ///
+ /// Contains information about the login session as well as the user .
+ /// A representing the completed operation.
+ Task Authenticated(YahooAuthenticatedContext context);
+
+ ///
+ /// Invoked prior to the being saved in a local cookie and the browser being redirected to the originally requested URL.
+ ///
+ ///
+ /// A representing the completed operation.
+ Task ReturnEndpoint(YahooReturnEndpointContext context);
+ }
+}
diff --git a/Owin.Security.Providers/Yahoo/Provider/YahooAuthenticatedContext.cs b/Owin.Security.Providers/Yahoo/Provider/YahooAuthenticatedContext.cs
new file mode 100644
index 0000000..1836ab8
--- /dev/null
+++ b/Owin.Security.Providers/Yahoo/Provider/YahooAuthenticatedContext.cs
@@ -0,0 +1,83 @@
+// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
+
+using System.Security.Claims;
+using Microsoft.Owin;
+using Microsoft.Owin.Security;
+using Microsoft.Owin.Security.Provider;
+using Newtonsoft.Json.Linq;
+
+namespace Owin.Security.Providers.Yahoo
+{
+ ///
+ /// Contains information about the login session as well as the user .
+ ///
+ public class YahooAuthenticatedContext : BaseContext
+ {
+ ///
+ /// Initializes a
+ ///
+ /// The OWIN environment
+ /// The JSON serialized user
+ /// Yahoo user ID
+ /// Yahoo access token
+ /// Yahoo access token secret
+ public YahooAuthenticatedContext(
+ IOwinContext context,
+ JObject user,
+ string userId,
+ string accessToken,
+ string accessTokenSecret)
+ : base(context)
+ {
+ User = user;
+ UserId = userId;
+ NickName = TryGetValue(user, "nickname");
+ AccessToken = accessToken;
+ AccessTokenSecret = accessTokenSecret;
+ }
+
+ ///
+ /// Gets the JSON-serialized user
+ ///
+ ///
+ /// Contains the LinkedIn user obtained from the endpoint http://social.yahooapis.com/v1/user/{guid}/profile/usercard
+ ///
+ public JObject User { get; private set; }
+
+ ///
+ /// Gets the Yahoo user ID
+ ///
+ public string UserId { get; private set; }
+
+ ///
+ /// Gets the Yaho0 nickname
+ ///
+ public string NickName { get; private set; }
+
+ ///
+ /// Gets the Yahoo access token
+ ///
+ public string AccessToken { get; private set; }
+
+ ///
+ /// Gets the Yahoo access token secret
+ ///
+ public string AccessTokenSecret { get; private set; }
+
+ ///
+ /// Gets the representing the user
+ ///
+ public ClaimsIdentity Identity { get; set; }
+
+ ///
+ /// Gets or sets a property bag for common authentication properties
+ ///
+ public AuthenticationProperties Properties { get; set; }
+
+ private static string TryGetValue(JObject user, string propertyName)
+ {
+ JToken value;
+ return user.TryGetValue(propertyName, out value) ? value.ToString() : null;
+ }
+ }
+}
diff --git a/Owin.Security.Providers/Yahoo/Provider/YahooAuthenticationProvider.cs b/Owin.Security.Providers/Yahoo/Provider/YahooAuthenticationProvider.cs
new file mode 100644
index 0000000..9e66d2a
--- /dev/null
+++ b/Owin.Security.Providers/Yahoo/Provider/YahooAuthenticationProvider.cs
@@ -0,0 +1,52 @@
+// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
+
+using System;
+using System.Threading.Tasks;
+
+namespace Owin.Security.Providers.Yahoo
+{
+ ///
+ /// Default implementation.
+ ///
+ public class YahooAuthenticationProvider : IYahooAuthenticationProvider
+ {
+ ///
+ /// Initializes a
+ ///
+ public YahooAuthenticationProvider()
+ {
+ OnAuthenticated = context => Task.FromResult