diff options
26 files changed, 251 insertions, 267 deletions
diff --git a/nuget/content/OAuth2.AuthorizationServer/web.config.transform b/nuget/content/OAuth2.AuthorizationServer/web.config.transform new file mode 100644 index 0000000..c53fb7c --- /dev/null +++ b/nuget/content/OAuth2.AuthorizationServer/web.config.transform @@ -0,0 +1,9 @@ +<configuration> + <configSections> + <sectionGroup name="dotNetOpenAuth" type="DotNetOpenAuth.Configuration.DotNetOpenAuthSection, DotNetOpenAuth.Core"> + <sectionGroup name="oauth2" type="DotNetOpenAuth.Configuration.OAuth2SectionGroup, DotNetOpenAuth.OAuth2"> + <section name="authorizationServer" type="DotNetOpenAuth.Configuration.OAuth2AuthorizationServerSection, DotNetOpenAuth.OAuth2.AuthorizationServer" requirePermission="false" allowLocation="true" /> + </sectionGroup> + </sectionGroup> + </configSections> +</configuration>
\ No newline at end of file diff --git a/nuget/content/OAuth2.Client/web.config.transform b/nuget/content/OAuth2.Client/web.config.transform new file mode 100644 index 0000000..b1f4429 --- /dev/null +++ b/nuget/content/OAuth2.Client/web.config.transform @@ -0,0 +1,9 @@ +<configuration> + <configSections> + <sectionGroup name="dotNetOpenAuth" type="DotNetOpenAuth.Configuration.DotNetOpenAuthSection, DotNetOpenAuth.Core"> + <sectionGroup name="oauth2" type="DotNetOpenAuth.Configuration.OAuth2SectionGroup, DotNetOpenAuth.OAuth2"> + <section name="client" type="DotNetOpenAuth.Configuration.OAuth2ClientSection, DotNetOpenAuth.OAuth2.Client" requirePermission="false" allowLocation="true" /> + </sectionGroup> + </sectionGroup> + </configSections> +</configuration>
\ No newline at end of file diff --git a/nuget/content/OAuth2.Core/web.config.transform b/nuget/content/OAuth2.Core/web.config.transform index cbb42e1..2c47af1 100644 --- a/nuget/content/OAuth2.Core/web.config.transform +++ b/nuget/content/OAuth2.Core/web.config.transform @@ -1,7 +1,7 @@ <configuration> <configSections> <sectionGroup name="dotNetOpenAuth" type="DotNetOpenAuth.Configuration.DotNetOpenAuthSection, DotNetOpenAuth.Core"> - <section name="oauth2" type="DotNetOpenAuth.Configuration.OAuth2Element, DotNetOpenAuth.OAuth2" requirePermission="false" allowLocation="true" /> + <sectionGroup name="oauth2" type="DotNetOpenAuth.Configuration.OAuth2SectionGroup, DotNetOpenAuth.OAuth2" /> </sectionGroup> </configSections> </configuration>
\ No newline at end of file diff --git a/nuget/content/OAuth2.ResourceServer/web.config.transform b/nuget/content/OAuth2.ResourceServer/web.config.transform new file mode 100644 index 0000000..a92ff7d --- /dev/null +++ b/nuget/content/OAuth2.ResourceServer/web.config.transform @@ -0,0 +1,9 @@ +<configuration> + <configSections> + <sectionGroup name="dotNetOpenAuth" type="DotNetOpenAuth.Configuration.DotNetOpenAuthSection, DotNetOpenAuth.Core"> + <sectionGroup name="oauth2" type="DotNetOpenAuth.Configuration.OAuth2SectionGroup, DotNetOpenAuth.OAuth2"> + <section name="resourceServer" type="DotNetOpenAuth.Configuration.OAuth2ResourceServerSection, DotNetOpenAuth.OAuth2.ResourceServer" requirePermission="false" allowLocation="true" /> + </sectionGroup> + </sectionGroup> + </configSections> +</configuration>
\ No newline at end of file diff --git a/samples/OAuthAuthorizationServer/Web.config b/samples/OAuthAuthorizationServer/Web.config index e98d63b..37157fd 100644 --- a/samples/OAuthAuthorizationServer/Web.config +++ b/samples/OAuthAuthorizationServer/Web.config @@ -11,6 +11,9 @@ <sectionGroup name="dotNetOpenAuth" type="DotNetOpenAuth.Configuration.DotNetOpenAuthSection, DotNetOpenAuth.Core"> <section name="openid" type="DotNetOpenAuth.Configuration.OpenIdElement, DotNetOpenAuth.OpenId" requirePermission="false" allowLocation="true" /> <section name="oauth" type="DotNetOpenAuth.Configuration.OAuthElement, DotNetOpenAuth.OAuth" requirePermission="false" allowLocation="true" /> + <sectionGroup name="oauth2" type="DotNetOpenAuth.Configuration.OAuth2SectionGroup, DotNetOpenAuth.OAuth2"> + <section name="authorizationServer" type="DotNetOpenAuth.Configuration.OAuth2AuthorizationServerSection, DotNetOpenAuth.OAuth2.AuthorizationServer" requirePermission="false" allowLocation="true" /> + </sectionGroup> <section name="messaging" type="DotNetOpenAuth.Configuration.MessagingElement, DotNetOpenAuth.Core" requirePermission="false" allowLocation="true" /> <section name="reporting" type="DotNetOpenAuth.Configuration.ReportingElement, DotNetOpenAuth.Core" requirePermission="false" allowLocation="true" /> </sectionGroup> @@ -40,8 +43,6 @@ <reporting enabled="true" /> <oauth2> <authorizationServer> - <clientAuthenticationModules> - </clientAuthenticationModules> </authorizationServer> </oauth2> @@ -70,7 +71,7 @@ </log4net> <connectionStrings> - <add name="DatabaseConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database2.mdf;Integrated Security=True;User Instance=True" + <add name="DatabaseConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database4.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient" /> </connectionStrings> diff --git a/src/DotNetOpenAuth.Core/Configuration/DotNetOpenAuth.xsd b/src/DotNetOpenAuth.Core/Configuration/DotNetOpenAuth.xsd index 3caadde..74d4db4 100644 --- a/src/DotNetOpenAuth.Core/Configuration/DotNetOpenAuth.xsd +++ b/src/DotNetOpenAuth.Core/Configuration/DotNetOpenAuth.xsd @@ -479,12 +479,19 @@ <xs:choice minOccurs="0" maxOccurs="unbounded"> <xs:element name="add"> <xs:complexType> - <xs:attribute name="name" type="xs:string" use="required" /> + <xs:attribute name="type" type="xs:string" use="optional"> + <xs:annotation> + <xs:documentation> + The fully-qualified name of the type that implements the IIdentifierDiscoveryService interface. + </xs:documentation> + </xs:annotation> + </xs:attribute> + <xs:attribute name="xaml" type="xs:string" use="optional" /> </xs:complexType> </xs:element> <xs:element name="remove"> <xs:complexType> - <xs:attribute name="name" type="xs:string" use="required" /> + <xs:attribute name="type" type="xs:string" use="required" /> </xs:complexType> </xs:element> <xs:element name="clear"> @@ -930,12 +937,25 @@ <xs:choice minOccurs="0" maxOccurs="unbounded"> <xs:element name="add"> <xs:complexType> - <xs:attribute name="name" type="xs:string" use="required" /> + <xs:attribute name="type" type="xs:string" use="optional"> + <xs:annotation> + <xs:documentation> + The fully-qualified name of the ClientAuthenticationModule-derived type. + </xs:documentation> + </xs:annotation> + </xs:attribute> + <xs:attribute name="xaml" type="xs:string" use="optional" /> </xs:complexType> </xs:element> <xs:element name="remove"> <xs:complexType> - <xs:attribute name="name" type="xs:string" use="required" /> + <xs:attribute name="type" type="xs:string" use="required"> + <xs:annotation> + <xs:documentation> + The fully-qualified name of the ClientAuthenticationModule-derived type. + </xs:documentation> + </xs:annotation> + </xs:attribute> </xs:complexType> </xs:element> <xs:element name="clear"> diff --git a/src/DotNetOpenAuth.OAuth2.AuthorizationServer/Configuration/OAuth2AuthorizationServerSection.cs b/src/DotNetOpenAuth.OAuth2.AuthorizationServer/Configuration/OAuth2AuthorizationServerSection.cs new file mode 100644 index 0000000..6511a11 --- /dev/null +++ b/src/DotNetOpenAuth.OAuth2.AuthorizationServer/Configuration/OAuth2AuthorizationServerSection.cs @@ -0,0 +1,70 @@ +//----------------------------------------------------------------------- +// <copyright file="OAuth2AuthorizationServerSection.cs" company="Outercurve Foundation"> +// Copyright (c) Outercurve Foundation. All rights reserved. +// </copyright> +//----------------------------------------------------------------------- + +namespace DotNetOpenAuth.Configuration { + using System; + using System.Configuration; + using System.Diagnostics.Contracts; + using DotNetOpenAuth.Messaging.Bindings; + using DotNetOpenAuth.OAuth2.ChannelElements; + + /// <summary> + /// Represents the <oauth2/authorizationServer> section in the host's .config file. + /// </summary> + internal class OAuth2AuthorizationServerSection : ConfigurationSection { + /// <summary> + /// The name of the oauth2/authorizationServer section. + /// </summary> + private const string SectionName = OAuth2SectionGroup.SectionName + "/authorizationServer"; + + /// <summary> + /// The name of the <clientAuthenticationModules> sub-element. + /// </summary> + private const string ClientAuthenticationModulesElementName = "clientAuthenticationModules"; + + /// <summary> + /// The built-in set of client authentication modules. + /// </summary> + private static readonly TypeConfigurationCollection<ClientAuthenticationModule> defaultClientAuthenticationModules = + new TypeConfigurationCollection<ClientAuthenticationModule>(new Type[] { typeof(ClientCredentialHttpBasicReader), typeof(ClientCredentialMessagePartReader) }); + + /// <summary> + /// Initializes a new instance of the <see cref="OAuth2AuthorizationServerSection"/> class. + /// </summary> + internal OAuth2AuthorizationServerSection() { + } + + /// <summary> + /// Gets the configuration section from the .config file. + /// </summary> + internal static OAuth2AuthorizationServerSection Configuration { + get { + Contract.Ensures(Contract.Result<OAuth2AuthorizationServerSection>() != null); + return (OAuth2AuthorizationServerSection)ConfigurationManager.GetSection(SectionName) ?? new OAuth2AuthorizationServerSection(); + } + } + + /// <summary> + /// Gets or sets the services to use for discovering service endpoints for identifiers. + /// </summary> + /// <remarks> + /// If no discovery services are defined in the (web) application's .config file, + /// the default set of discovery services built into the library are used. + /// </remarks> + [ConfigurationProperty(ClientAuthenticationModulesElementName, IsDefaultCollection = false)] + [ConfigurationCollection(typeof(TypeConfigurationCollection<ClientAuthenticationModule>))] + internal TypeConfigurationCollection<ClientAuthenticationModule> ClientAuthenticationModules { + get { + var configResult = (TypeConfigurationCollection<ClientAuthenticationModule>)this[ClientAuthenticationModulesElementName]; + return configResult != null && configResult.Count > 0 ? configResult : defaultClientAuthenticationModules; + } + + set { + this[ClientAuthenticationModulesElementName] = value; + } + } + } +} diff --git a/src/DotNetOpenAuth.OAuth2.AuthorizationServer/DotNetOpenAuth.OAuth2.AuthorizationServer.csproj b/src/DotNetOpenAuth.OAuth2.AuthorizationServer/DotNetOpenAuth.OAuth2.AuthorizationServer.csproj index a65afdf..628db32 100644 --- a/src/DotNetOpenAuth.OAuth2.AuthorizationServer/DotNetOpenAuth.OAuth2.AuthorizationServer.csproj +++ b/src/DotNetOpenAuth.OAuth2.AuthorizationServer/DotNetOpenAuth.OAuth2.AuthorizationServer.csproj @@ -18,6 +18,7 @@ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> </PropertyGroup> <ItemGroup> + <Compile Include="Configuration\OAuth2AuthorizationServerSection.cs" /> <Compile Include="OAuth2\AuthorizationServer.cs" /> <Compile Include="OAuth2\AuthServerStrings.Designer.cs"> <AutoGen>True</AutoGen> diff --git a/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/AuthorizationServer.cs b/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/AuthorizationServer.cs index fdcab8b..fecc6be 100644 --- a/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/AuthorizationServer.cs +++ b/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/AuthorizationServer.cs @@ -23,20 +23,14 @@ namespace DotNetOpenAuth.OAuth2 { /// </summary> public class AuthorizationServer { /// <summary> - /// The built-in set of client authentication modules. - /// </summary> - private static readonly TypeConfigurationCollection<IClientAuthenticationModule> defaultClientAuthenticationModules = - new TypeConfigurationCollection<IClientAuthenticationModule>(new Type[] { typeof(ClientCredentialHttpBasicReader), typeof(ClientCredentialMessagePartReader) }); - - /// <summary> /// The list of modules that verify client authentication data. /// </summary> - private readonly List<IClientAuthenticationModule> clientAuthenticationModules = new List<IClientAuthenticationModule>(); + private readonly List<ClientAuthenticationModule> clientAuthenticationModules = new List<ClientAuthenticationModule>(); /// <summary> /// The lone aggregate client authentication module that uses the <see cref="clientAuthenticationModules"/> and applies aggregating policy. /// </summary> - private readonly ClientAuthenticationModuleBase aggregatingClientAuthenticationModule; + private readonly ClientAuthenticationModule aggregatingClientAuthenticationModule; /// <summary> /// Initializes a new instance of the <see cref="AuthorizationServer"/> class. @@ -46,16 +40,7 @@ namespace DotNetOpenAuth.OAuth2 { Requires.NotNull(authorizationServer, "authorizationServer"); this.aggregatingClientAuthenticationModule = new AggregatingClientCredentialReader(this.clientAuthenticationModules); this.Channel = new OAuth2AuthorizationServerChannel(authorizationServer, this.aggregatingClientAuthenticationModule); - - var modules = OAuth2Element.Configuration.AuthorizationServer.ClientAuthenticationModules; - if (modules.Count == 0) { - modules = defaultClientAuthenticationModules; - } - - // TODO: work this out once we move configurations into the oauth2 authorization server. - ////this.clientAuthenticationModules.AddRange(modules.CreateInstances(true)); - this.clientAuthenticationModules.Add(new ClientCredentialMessagePartReader(authorizationServer)); - this.clientAuthenticationModules.Add(new ClientCredentialHttpBasicReader(authorizationServer)); + this.clientAuthenticationModules.AddRange(OAuth2AuthorizationServerSection.Configuration.ClientAuthenticationModules.CreateInstances(true)); } /// <summary> @@ -75,7 +60,7 @@ namespace DotNetOpenAuth.OAuth2 { /// <summary> /// Gets the extension modules that can read client authentication data from incoming messages. /// </summary> - public IList<IClientAuthenticationModule> ClientAuthenticationModules { + public IList<ClientAuthenticationModule> ClientAuthenticationModules { get { return this.clientAuthenticationModules; } } diff --git a/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/ChannelElements/AggregatingClientCredentialReader.cs b/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/ChannelElements/AggregatingClientCredentialReader.cs index 6eff5f5..4f60303 100644 --- a/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/ChannelElements/AggregatingClientCredentialReader.cs +++ b/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/ChannelElements/AggregatingClientCredentialReader.cs @@ -17,17 +17,17 @@ namespace DotNetOpenAuth.OAuth2.ChannelElements { /// <summary> /// Applies OAuth 2 spec policy for supporting multiple methods of client authentication. /// </summary> - internal class AggregatingClientCredentialReader : ClientAuthenticationModuleBase { + internal class AggregatingClientCredentialReader : ClientAuthenticationModule { /// <summary> /// The set of authenticators to apply to an incoming request. /// </summary> - private readonly IEnumerable<IClientAuthenticationModule> authenticators; + private readonly IEnumerable<ClientAuthenticationModule> authenticators; /// <summary> /// Initializes a new instance of the <see cref="AggregatingClientCredentialReader"/> class. /// </summary> /// <param name="authenticators">The set of authentication modules to apply.</param> - internal AggregatingClientCredentialReader(IEnumerable<IClientAuthenticationModule> authenticators) { + internal AggregatingClientCredentialReader(IEnumerable<ClientAuthenticationModule> authenticators) { Requires.NotNull(authenticators, "readers"); this.authenticators = authenticators; } @@ -35,19 +35,21 @@ namespace DotNetOpenAuth.OAuth2.ChannelElements { /// <summary> /// Attempts to extract client identification/authentication information from a message. /// </summary> + /// <param name="authorizationServerHost">The authorization server host.</param> /// <param name="requestMessage">The incoming message.</param> /// <param name="clientIdentifier">Receives the client identifier, if one was found.</param> /// <returns>The level of the extracted client information.</returns> - public override ClientAuthenticationResult TryAuthenticateClient(AuthenticatedClientRequestBase requestMessage, out string clientIdentifier) { + public override ClientAuthenticationResult TryAuthenticateClient(IAuthorizationServerHost authorizationServerHost, AuthenticatedClientRequestBase requestMessage, out string clientIdentifier) { + Requires.NotNull(authorizationServerHost, "authorizationServerHost"); Requires.NotNull(requestMessage, "requestMessage"); - IClientAuthenticationModule authenticator = null; + ClientAuthenticationModule authenticator = null; ClientAuthenticationResult result = ClientAuthenticationResult.NoAuthenticationRecognized; clientIdentifier = null; foreach (var candidateAuthenticator in this.authenticators) { string candidateClientIdentifier; - var resultCandidate = candidateAuthenticator.TryAuthenticateClient(requestMessage, out candidateClientIdentifier); + var resultCandidate = candidateAuthenticator.TryAuthenticateClient(authorizationServerHost, requestMessage, out candidateClientIdentifier); ErrorUtilities.VerifyProtocol( result == ClientAuthenticationResult.NoAuthenticationRecognized || resultCandidate == ClientAuthenticationResult.NoAuthenticationRecognized, diff --git a/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/ChannelElements/ClientAuthenticationModuleBase.cs b/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/ChannelElements/ClientAuthenticationModuleBase.cs index 262116d..e835e1e 100644 --- a/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/ChannelElements/ClientAuthenticationModuleBase.cs +++ b/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/ChannelElements/ClientAuthenticationModuleBase.cs @@ -15,32 +15,24 @@ namespace DotNetOpenAuth.OAuth2.ChannelElements { using DotNetOpenAuth.OAuth2.Messages; /// <summary> - /// A convenient base class for imlementations of the <see cref="IClientAuthenticationModule"/> interface. + /// A base class for extensions that can read incoming messages and extract the client identifier and + /// possibly authentication information (like a shared secret, signed nonce, etc.) /// </summary> - public abstract class ClientAuthenticationModuleBase : IClientAuthenticationModule { + public abstract class ClientAuthenticationModule { /// <summary> - /// Initializes a new instance of the <see cref="ClientAuthenticationModuleBase"/> class. + /// Initializes a new instance of the <see cref="ClientAuthenticationModule"/> class. /// </summary> - protected ClientAuthenticationModuleBase() { + protected ClientAuthenticationModule() { } /// <summary> /// Attempts to extract client identification/authentication information from a message. /// </summary> + /// <param name="authorizationServerHost">The authorization server host.</param> /// <param name="requestMessage">The incoming message.</param> /// <param name="clientIdentifier">Receives the client identifier, if one was found.</param> /// <returns>The level of the extracted client information.</returns> - public abstract ClientAuthenticationResult TryAuthenticateClient(AuthenticatedClientRequestBase requestMessage, out string clientIdentifier); - - /// <summary> - /// Attempts to extract client identification/authentication information from a message. - /// </summary> - /// <param name="requestMessage">The incoming message. Always an instance of <see cref="AuthenticatedClientRequestBase"/></param> - /// <param name="clientIdentifier">Receives the client identifier, if one was found.</param> - /// <returns>The level of the extracted client information.</returns> - public ClientAuthenticationResult TryAuthenticateClient(IDirectedProtocolMessage requestMessage, out string clientIdentifier) { - return this.TryAuthenticateClient((AuthenticatedClientRequestBase)requestMessage, out clientIdentifier); - } + public abstract ClientAuthenticationResult TryAuthenticateClient(IAuthorizationServerHost authorizationServerHost, AuthenticatedClientRequestBase requestMessage, out string clientIdentifier); /// <summary> /// Validates a client identifier and shared secret against the authoriation server's database. diff --git a/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/ChannelElements/ClientCredentialHttpBasicReader.cs b/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/ChannelElements/ClientCredentialHttpBasicReader.cs index b375d29..44af332 100644 --- a/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/ChannelElements/ClientCredentialHttpBasicReader.cs +++ b/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/ChannelElements/ClientCredentialHttpBasicReader.cs @@ -16,34 +16,22 @@ namespace DotNetOpenAuth.OAuth2.ChannelElements { /// <summary> /// Reads client authentication information from the HTTP Authorization header via Basic authentication. /// </summary> - public class ClientCredentialHttpBasicReader : ClientAuthenticationModuleBase { - /// <summary> - /// The authorization server host. - /// </summary> - private readonly IAuthorizationServerHost authorizationServerHost; - - /// <summary> - /// Initializes a new instance of the <see cref="ClientCredentialHttpBasicReader"/> class. - /// </summary> - /// <param name="authorizationServerHost">The authorization server host.</param> - public ClientCredentialHttpBasicReader(IAuthorizationServerHost authorizationServerHost) { - Requires.NotNull(authorizationServerHost, "authorizationServerHost"); - this.authorizationServerHost = authorizationServerHost; - } - + public class ClientCredentialHttpBasicReader : ClientAuthenticationModule { /// <summary> /// Attempts to extract client identification/authentication information from a message. /// </summary> + /// <param name="authorizationServerHost">The authorization server host.</param> /// <param name="requestMessage">The incoming message.</param> /// <param name="clientIdentifier">Receives the client identifier, if one was found.</param> /// <returns>The level of the extracted client information.</returns> - public override ClientAuthenticationResult TryAuthenticateClient(AuthenticatedClientRequestBase requestMessage, out string clientIdentifier) { + public override ClientAuthenticationResult TryAuthenticateClient(IAuthorizationServerHost authorizationServerHost, AuthenticatedClientRequestBase requestMessage, out string clientIdentifier) { + Requires.NotNull(authorizationServerHost, "authorizationServerHost"); Requires.NotNull(requestMessage, "requestMessage"); var credential = OAuthUtilities.ParseHttpBasicAuth(requestMessage.Headers); if (credential != null) { clientIdentifier = credential.UserName; - return TryAuthenticateClient(this.authorizationServerHost, credential.UserName, credential.Password); + return TryAuthenticateClient(authorizationServerHost, credential.UserName, credential.Password); } clientIdentifier = null; diff --git a/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/ChannelElements/ClientCredentialMessagePartReader.cs b/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/ChannelElements/ClientCredentialMessagePartReader.cs index 2df68a6..6579df2 100644 --- a/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/ChannelElements/ClientCredentialMessagePartReader.cs +++ b/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/ChannelElements/ClientCredentialMessagePartReader.cs @@ -15,31 +15,20 @@ namespace DotNetOpenAuth.OAuth2.ChannelElements { /// <summary> /// Reads client authentication information from the message payload itself (POST entity as a URI-encoded parameter). /// </summary> - public class ClientCredentialMessagePartReader : ClientAuthenticationModuleBase { - /// <summary> - /// The authorization server host. - /// </summary> - private readonly IAuthorizationServerHost authorizationServerHost; - - /// <summary> - /// Initializes a new instance of the <see cref="ClientCredentialMessagePartReader"/> class. - /// </summary> - /// <param name="authorizationServerHost">The authorization server host.</param> - public ClientCredentialMessagePartReader(IAuthorizationServerHost authorizationServerHost) { - Requires.NotNull(authorizationServerHost, "authorizationServerHost"); - this.authorizationServerHost = authorizationServerHost; - } - + public class ClientCredentialMessagePartReader : ClientAuthenticationModule { /// <summary> /// Attempts to extract client identification/authentication information from a message. /// </summary> + /// <param name="authorizationServerHost">The authorization server host.</param> /// <param name="requestMessage">The incoming message.</param> /// <param name="clientIdentifier">Receives the client identifier, if one was found.</param> /// <returns>The level of the extracted client information.</returns> - public override ClientAuthenticationResult TryAuthenticateClient(AuthenticatedClientRequestBase requestMessage, out string clientIdentifier) { + public override ClientAuthenticationResult TryAuthenticateClient(IAuthorizationServerHost authorizationServerHost, AuthenticatedClientRequestBase requestMessage, out string clientIdentifier) { + Requires.NotNull(authorizationServerHost, "authorizationServerHost"); Requires.NotNull(requestMessage, "requestMessage"); + clientIdentifier = requestMessage.ClientIdentifier; - return TryAuthenticateClient(this.authorizationServerHost, requestMessage.ClientIdentifier, requestMessage.ClientSecret); + return TryAuthenticateClient(authorizationServerHost, requestMessage.ClientIdentifier, requestMessage.ClientSecret); } } } diff --git a/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/ChannelElements/MessageValidationBindingElement.cs b/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/ChannelElements/MessageValidationBindingElement.cs index 40f3df8..e114208 100644 --- a/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/ChannelElements/MessageValidationBindingElement.cs +++ b/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/ChannelElements/MessageValidationBindingElement.cs @@ -26,15 +26,23 @@ namespace DotNetOpenAuth.OAuth2.ChannelElements { /// <summary> /// The aggregating client authentication module. /// </summary> - private readonly IClientAuthenticationModule clientAuthenticationModule; + private readonly ClientAuthenticationModule clientAuthenticationModule; + + /// <summary> + /// The authorization server host that applies. + /// </summary> + private readonly IAuthorizationServerHost authorizationServer; /// <summary> /// Initializes a new instance of the <see cref="MessageValidationBindingElement"/> class. /// </summary> /// <param name="clientAuthenticationModule">The aggregating client authentication module.</param> - internal MessageValidationBindingElement(IClientAuthenticationModule clientAuthenticationModule) { + internal MessageValidationBindingElement(ClientAuthenticationModule clientAuthenticationModule, IAuthorizationServerHost authorizationServer) { Requires.NotNull(clientAuthenticationModule, "clientAuthenticationModule"); + Requires.NotNull(authorizationServer, "authorizationServer"); + this.clientAuthenticationModule = clientAuthenticationModule; + this.authorizationServer = authorizationServer; } /// <summary> @@ -95,7 +103,7 @@ namespace DotNetOpenAuth.OAuth2.ChannelElements { var authenticatedClientRequest = message as AuthenticatedClientRequestBase; if (authenticatedClientRequest != null) { string clientIdentifier; - var result = this.clientAuthenticationModule.TryAuthenticateClient(authenticatedClientRequest, out clientIdentifier); + var result = this.clientAuthenticationModule.TryAuthenticateClient(this.authorizationServer, authenticatedClientRequest, out clientIdentifier); AuthServerUtilities.TokenEndpointVerify(result != ClientAuthenticationResult.ClientIdNotAuthenticated, Protocol.AccessTokenRequestErrorCodes.UnauthorizedClient); // an empty secret is not allowed for client authenticated calls. AuthServerUtilities.TokenEndpointVerify(result == ClientAuthenticationResult.ClientAuthenticated, Protocol.AccessTokenRequestErrorCodes.InvalidClient, AuthServerStrings.ClientSecretMismatch); authenticatedClientRequest.ClientIdentifier = clientIdentifier; diff --git a/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/ChannelElements/OAuth2AuthorizationServerChannel.cs b/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/ChannelElements/OAuth2AuthorizationServerChannel.cs index 8c3ed4a..53dfb54 100644 --- a/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/ChannelElements/OAuth2AuthorizationServerChannel.cs +++ b/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/ChannelElements/OAuth2AuthorizationServerChannel.cs @@ -36,7 +36,7 @@ namespace DotNetOpenAuth.OAuth2.ChannelElements { /// </summary> /// <param name="authorizationServer">The authorization server.</param> /// <param name="clientAuthenticationModule">The aggregating client authentication module.</param> - protected internal OAuth2AuthorizationServerChannel(IAuthorizationServerHost authorizationServer, IClientAuthenticationModule clientAuthenticationModule) + protected internal OAuth2AuthorizationServerChannel(IAuthorizationServerHost authorizationServer, ClientAuthenticationModule clientAuthenticationModule) : base(MessageTypes, InitializeBindingElements(authorizationServer, clientAuthenticationModule)) { Requires.NotNull(authorizationServer, "authorizationServer"); this.AuthorizationServer = authorizationServer; @@ -111,14 +111,14 @@ namespace DotNetOpenAuth.OAuth2.ChannelElements { /// <returns> /// An array of binding elements used to initialize the channel. /// </returns> - private static IChannelBindingElement[] InitializeBindingElements(IAuthorizationServerHost authorizationServer, IClientAuthenticationModule clientAuthenticationModule) { + private static IChannelBindingElement[] InitializeBindingElements(IAuthorizationServerHost authorizationServer, ClientAuthenticationModule clientAuthenticationModule) { Requires.NotNull(authorizationServer, "authorizationServer"); Requires.NotNull(clientAuthenticationModule, "clientAuthenticationModule"); var bindingElements = new List<IChannelBindingElement>(); // The order they are provided is used for outgoing messgaes, and reversed for incoming messages. - bindingElements.Add(new MessageValidationBindingElement(clientAuthenticationModule)); + bindingElements.Add(new MessageValidationBindingElement(clientAuthenticationModule, authorizationServer)); bindingElements.Add(new TokenCodeSerializationBindingElement()); return bindingElements.ToArray(); diff --git a/src/DotNetOpenAuth.OAuth2.Client/Configuration/OAuth2ClientSection.cs b/src/DotNetOpenAuth.OAuth2.Client/Configuration/OAuth2ClientSection.cs new file mode 100644 index 0000000..1ee5aa5 --- /dev/null +++ b/src/DotNetOpenAuth.OAuth2.Client/Configuration/OAuth2ClientSection.cs @@ -0,0 +1,36 @@ +//----------------------------------------------------------------------- +// <copyright file="OAuth2ClientSection.cs" company="Outercurve Foundation"> +// Copyright (c) Outercurve Foundation. All rights reserved. +// </copyright> +//----------------------------------------------------------------------- + +namespace DotNetOpenAuth.Configuration { + using System.Configuration; + using System.Diagnostics.Contracts; + + /// <summary> + /// Represents the <oauth2/client> section in the host's .config file. + /// </summary> + internal class OAuth2ClientSection : ConfigurationSection { + /// <summary> + /// The name of the oauth2/client section. + /// </summary> + private const string SectionName = OAuth2SectionGroup.SectionName + "/client"; + + /// <summary> + /// Initializes a new instance of the <see cref="OAuth2ClientSection"/> class. + /// </summary> + internal OAuth2ClientSection() { + } + + /// <summary> + /// Gets the configuration section from the .config file. + /// </summary> + internal static OAuth2ClientSection Configuration { + get { + Contract.Ensures(Contract.Result<OAuth2ClientSection>() != null); + return (OAuth2ClientSection)ConfigurationManager.GetSection(SectionName) ?? new OAuth2ClientSection(); + } + } + } +} diff --git a/src/DotNetOpenAuth.OAuth2.Client/DotNetOpenAuth.OAuth2.Client.csproj b/src/DotNetOpenAuth.OAuth2.Client/DotNetOpenAuth.OAuth2.Client.csproj index 6b84c72..da76ecb 100644 --- a/src/DotNetOpenAuth.OAuth2.Client/DotNetOpenAuth.OAuth2.Client.csproj +++ b/src/DotNetOpenAuth.OAuth2.Client/DotNetOpenAuth.OAuth2.Client.csproj @@ -18,6 +18,7 @@ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> </PropertyGroup> <ItemGroup> + <Compile Include="Configuration\OAuth2ClientSection.cs" /> <Compile Include="OAuth2\AuthorizationServerDescription.cs" /> <Compile Include="OAuth2\AuthorizationState.cs" /> <Compile Include="OAuth2\ChannelElements\OAuth2ClientChannel.cs" /> diff --git a/src/DotNetOpenAuth.OAuth2.ResourceServer/Configuration/OAuth2ResourceServerSection.cs b/src/DotNetOpenAuth.OAuth2.ResourceServer/Configuration/OAuth2ResourceServerSection.cs new file mode 100644 index 0000000..3e37018 --- /dev/null +++ b/src/DotNetOpenAuth.OAuth2.ResourceServer/Configuration/OAuth2ResourceServerSection.cs @@ -0,0 +1,36 @@ +//----------------------------------------------------------------------- +// <copyright file="OAuth2ResourceServerSection.cs" company="Outercurve Foundation"> +// Copyright (c) Outercurve Foundation. All rights reserved. +// </copyright> +//----------------------------------------------------------------------- + +namespace DotNetOpenAuth.Configuration { + using System.Configuration; + using System.Diagnostics.Contracts; + + /// <summary> + /// Represents the <oauth2/resourceServer> section in the host's .config file. + /// </summary> + internal class OAuth2ResourceServerSection : ConfigurationElement { + /// <summary> + /// The name of the oauth2/client section. + /// </summary> + private const string SectionName = OAuth2SectionGroup.SectionName + "/resourceServer"; + + /// <summary> + /// Initializes a new instance of the <see cref="OAuth2ResourceServerSection"/> class. + /// </summary> + internal OAuth2ResourceServerSection() { + } + + /// <summary> + /// Gets the configuration section from the .config file. + /// </summary> + internal static OAuth2ResourceServerSection Configuration { + get { + Contract.Ensures(Contract.Result<OAuth2ResourceServerSection>() != null); + return (OAuth2ResourceServerSection)ConfigurationManager.GetSection(SectionName) ?? new OAuth2ResourceServerSection(); + } + } + } +} diff --git a/src/DotNetOpenAuth.OAuth2.ResourceServer/DotNetOpenAuth.OAuth2.ResourceServer.csproj b/src/DotNetOpenAuth.OAuth2.ResourceServer/DotNetOpenAuth.OAuth2.ResourceServer.csproj index 3aa92f7..eb54fee 100644 --- a/src/DotNetOpenAuth.OAuth2.ResourceServer/DotNetOpenAuth.OAuth2.ResourceServer.csproj +++ b/src/DotNetOpenAuth.OAuth2.ResourceServer/DotNetOpenAuth.OAuth2.ResourceServer.csproj @@ -18,6 +18,7 @@ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> </PropertyGroup> <ItemGroup> + <Compile Include="Configuration\OAuth2ResourceServerSection.cs" /> <Compile Include="OAuth2\ChannelElements\OAuth2ResourceServerChannel.cs" /> <Compile Include="OAuth2\IAccessTokenAnalyzer.cs" /> <Compile Include="OAuth2\ResourceServerStrings.Designer.cs"> @@ -52,4 +53,4 @@ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(ProjectRoot)tools\DotNetOpenAuth.targets" /> <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))\EnlistmentInfo.targets" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))' != '' " /> -</Project> +</Project>
\ No newline at end of file diff --git a/src/DotNetOpenAuth.OAuth2/Configuration/OAuth2AuthorizationServerElement.cs b/src/DotNetOpenAuth.OAuth2/Configuration/OAuth2AuthorizationServerElement.cs deleted file mode 100644 index 1329ce2..0000000 --- a/src/DotNetOpenAuth.OAuth2/Configuration/OAuth2AuthorizationServerElement.cs +++ /dev/null @@ -1,54 +0,0 @@ -//----------------------------------------------------------------------- -// <copyright file="OAuth2AuthorizationServerElement.cs" company="Outercurve Foundation"> -// Copyright (c) Outercurve Foundation. All rights reserved. -// </copyright> -//----------------------------------------------------------------------- - -namespace DotNetOpenAuth.Configuration { - using System; - using System.Configuration; - using DotNetOpenAuth.Messaging.Bindings; - using DotNetOpenAuth.OAuth2.ChannelElements; - - /// <summary> - /// Represents the <oauth2/authorizationServer> element in the host's .config file. - /// </summary> - internal class OAuth2AuthorizationServerElement : ConfigurationElement { - /// <summary> - /// The name of the <clientAuthenticationModules> sub-element. - /// </summary> - private const string ClientAuthenticationModulesElementName = "clientAuthenticationModules"; - - /// <summary> - /// The built-in set of identifier discovery services. - /// </summary> - private static readonly TypeConfigurationCollection<IClientAuthenticationModule> defaultClientAuthenticationModules = - new TypeConfigurationCollection<IClientAuthenticationModule>(); - - /// <summary> - /// Initializes a new instance of the <see cref="OAuth2AuthorizationServerElement"/> class. - /// </summary> - internal OAuth2AuthorizationServerElement() { - } - - /// <summary> - /// Gets or sets the services to use for discovering service endpoints for identifiers. - /// </summary> - /// <remarks> - /// If no discovery services are defined in the (web) application's .config file, - /// the default set of discovery services built into the library are used. - /// </remarks> - [ConfigurationProperty(ClientAuthenticationModulesElementName, IsDefaultCollection = false)] - [ConfigurationCollection(typeof(TypeConfigurationCollection<IClientAuthenticationModule>))] - internal TypeConfigurationCollection<IClientAuthenticationModule> ClientAuthenticationModules { - get { - var configResult = (TypeConfigurationCollection<IClientAuthenticationModule>)this[ClientAuthenticationModulesElementName]; - return configResult != null && configResult.Count > 0 ? configResult : defaultClientAuthenticationModules; - } - - set { - this[ClientAuthenticationModulesElementName] = value; - } - } - } -} diff --git a/src/DotNetOpenAuth.OAuth2/Configuration/OAuth2ClientElement.cs b/src/DotNetOpenAuth.OAuth2/Configuration/OAuth2ClientElement.cs deleted file mode 100644 index 95a7a36..0000000 --- a/src/DotNetOpenAuth.OAuth2/Configuration/OAuth2ClientElement.cs +++ /dev/null @@ -1,20 +0,0 @@ -//----------------------------------------------------------------------- -// <copyright file="OAuth2ClientElement.cs" company="Outercurve Foundation"> -// Copyright (c) Outercurve Foundation. All rights reserved. -// </copyright> -//----------------------------------------------------------------------- - -namespace DotNetOpenAuth.Configuration { - using System.Configuration; - - /// <summary> - /// Represents the <oauth2/client> element in the host's .config file. - /// </summary> - internal class OAuth2ClientElement : ConfigurationElement { - /// <summary> - /// Initializes a new instance of the <see cref="OAuth2ClientElement"/> class. - /// </summary> - internal OAuth2ClientElement() { - } - } -} diff --git a/src/DotNetOpenAuth.OAuth2/Configuration/OAuth2Element.cs b/src/DotNetOpenAuth.OAuth2/Configuration/OAuth2Element.cs index 6ba7e23..858d27b 100644 --- a/src/DotNetOpenAuth.OAuth2/Configuration/OAuth2Element.cs +++ b/src/DotNetOpenAuth.OAuth2/Configuration/OAuth2Element.cs @@ -11,68 +11,16 @@ namespace DotNetOpenAuth.Configuration { /// <summary> /// Represents the <oauth> element in the host's .config file. /// </summary> - internal class OAuth2Element : ConfigurationSection { + internal class OAuth2SectionGroup : ConfigurationSectionGroup { /// <summary> /// The name of the oauth section. /// </summary> - private const string SectionName = DotNetOpenAuthSection.SectionName + "/oauth2"; + internal const string SectionName = DotNetOpenAuthSection.SectionName + "/oauth2"; /// <summary> - /// The name of the <client> sub-element. + /// Initializes a new instance of the <see cref="OAuth2SectionGroup"/> class. /// </summary> - private const string ClientElementName = "client"; - - /// <summary> - /// The name of the <authorizationServer> sub-element. - /// </summary> - private const string AuthorizationServerElementName = "authorizationServer"; - - /// <summary> - /// The name of the <resourceServer> sub-element. - /// </summary> - private const string ResourceServerElementName = "resourceServer"; - - /// <summary> - /// Initializes a new instance of the <see cref="OAuth2Element"/> class. - /// </summary> - internal OAuth2Element() { - } - - /// <summary> - /// Gets the configuration section from the .config file. - /// </summary> - public static OAuth2Element Configuration { - get { - Contract.Ensures(Contract.Result<OAuth2Element>() != null); - return (OAuth2Element)ConfigurationManager.GetSection(SectionName) ?? new OAuth2Element(); - } - } - - /// <summary> - /// Gets or sets the configuration specific for Clients. - /// </summary> - [ConfigurationProperty(ClientElementName)] - internal OAuth2ClientElement Client { - get { return (OAuth2ClientElement)this[ClientElementName] ?? new OAuth2ClientElement(); } - set { this[ClientElementName] = value; } - } - - /// <summary> - /// Gets or sets the configuration specific for Authorization Servers. - /// </summary> - [ConfigurationProperty(AuthorizationServerElementName)] - internal OAuth2AuthorizationServerElement AuthorizationServer { - get { return (OAuth2AuthorizationServerElement)this[AuthorizationServerElementName] ?? new OAuth2AuthorizationServerElement(); } - set { this[AuthorizationServerElementName] = value; } - } - - /// <summary> - /// Gets or sets the configuration specific for Resource Servers. - /// </summary> - [ConfigurationProperty(ResourceServerElementName)] - internal OAuth2ResourceServerElement ResourceServer { - get { return (OAuth2ResourceServerElement)this[ResourceServerElementName] ?? new OAuth2ResourceServerElement(); } - set { this[ResourceServerElementName] = value; } + internal OAuth2SectionGroup() { } } } diff --git a/src/DotNetOpenAuth.OAuth2/Configuration/OAuth2ResourceServerElement.cs b/src/DotNetOpenAuth.OAuth2/Configuration/OAuth2ResourceServerElement.cs deleted file mode 100644 index a07e973..0000000 --- a/src/DotNetOpenAuth.OAuth2/Configuration/OAuth2ResourceServerElement.cs +++ /dev/null @@ -1,20 +0,0 @@ -//----------------------------------------------------------------------- -// <copyright file="OAuth2ResourceServerElement.cs" company="Outercurve Foundation"> -// Copyright (c) Outercurve Foundation. All rights reserved. -// </copyright> -//----------------------------------------------------------------------- - -namespace DotNetOpenAuth.Configuration { - using System.Configuration; - - /// <summary> - /// Represents the <oauth2/resourceServer> element in the host's .config file. - /// </summary> - internal class OAuth2ResourceServerElement : ConfigurationElement { - /// <summary> - /// Initializes a new instance of the <see cref="OAuth2ResourceServerElement"/> class. - /// </summary> - internal OAuth2ResourceServerElement() { - } - } -} diff --git a/src/DotNetOpenAuth.OAuth2/DotNetOpenAuth.OAuth2.csproj b/src/DotNetOpenAuth.OAuth2/DotNetOpenAuth.OAuth2.csproj index 74dd1b6..4b1d534 100644 --- a/src/DotNetOpenAuth.OAuth2/DotNetOpenAuth.OAuth2.csproj +++ b/src/DotNetOpenAuth.OAuth2/DotNetOpenAuth.OAuth2.csproj @@ -18,16 +18,12 @@ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> </PropertyGroup> <ItemGroup> - <Compile Include="Configuration\OAuth2ResourceServerElement.cs" /> <Compile Include="Configuration\OAuth2Element.cs" /> - <Compile Include="Configuration\OAuth2ClientElement.cs" /> - <Compile Include="Configuration\OAuth2AuthorizationServerElement.cs" /> <Compile Include="GlobalSuppressions.cs" /> <Compile Include="OAuth2\AccessToken.cs" /> <Compile Include="OAuth2\ChannelElements\AuthorizationDataBag.cs" /> <Compile Include="OAuth2\ChannelElements\ClientAuthenticationResult.cs" /> <Compile Include="OAuth2\ChannelElements\IAccessTokenCarryingRequest.cs" /> - <Compile Include="OAuth2\ChannelElements\IClientAuthenticationModule.cs" /> <Compile Include="OAuth2\ChannelElements\ScopeEncoder.cs" /> <Compile Include="OAuth2\ChannelElements\IAuthorizationDescription.cs" /> <Compile Include="OAuth2\ChannelElements\IAuthorizationCarryingRequest.cs" /> diff --git a/src/DotNetOpenAuth.OAuth2/OAuth2/ChannelElements/IClientAuthenticationModule.cs b/src/DotNetOpenAuth.OAuth2/OAuth2/ChannelElements/IClientAuthenticationModule.cs deleted file mode 100644 index 470e533..0000000 --- a/src/DotNetOpenAuth.OAuth2/OAuth2/ChannelElements/IClientAuthenticationModule.cs +++ /dev/null @@ -1,23 +0,0 @@ -//----------------------------------------------------------------------- -// <copyright file="IClientAuthenticationModule.cs" company="Andrew Arnott"> -// Copyright (c) Andrew Arnott. All rights reserved. -// </copyright> -//----------------------------------------------------------------------- - -namespace DotNetOpenAuth.OAuth2.ChannelElements { - using DotNetOpenAuth.Messaging; - - /// <summary> - /// An interface implemented by extension that can read incoming messages and extract the client identifier and - /// possibly authentication information (like a shared secret, signed nonce, etc.) - /// </summary> - public interface IClientAuthenticationModule { - /// <summary> - /// Attempts to extract client identification/authentication information from a message. - /// </summary> - /// <param name="requestMessage">The incoming message. Always an instance of <see cref="AuthenticatedClientRequestBase"/></param> - /// <param name="clientIdentifier">Receives the client identifier, if one was found.</param> - /// <returns>The level of the extracted client information.</returns> - ClientAuthenticationResult TryAuthenticateClient(IDirectedProtocolMessage requestMessage, out string clientIdentifier); - } -} diff --git a/src/DotNetOpenAuth.Test/OAuth2/MessageFactoryTests.cs b/src/DotNetOpenAuth.Test/OAuth2/MessageFactoryTests.cs index dff831b..52b5371 100644 --- a/src/DotNetOpenAuth.Test/OAuth2/MessageFactoryTests.cs +++ b/src/DotNetOpenAuth.Test/OAuth2/MessageFactoryTests.cs @@ -28,7 +28,7 @@ namespace DotNetOpenAuth.Test.OAuth2 { public override void SetUp() { base.SetUp(); - var authServerChannel = new OAuth2AuthorizationServerChannel(new Mock<IAuthorizationServerHost>().Object, new Mock<IClientAuthenticationModule>().Object); + var authServerChannel = new OAuth2AuthorizationServerChannel(new Mock<IAuthorizationServerHost>().Object, new Mock<ClientAuthenticationModule>().Object); this.authServerMessageFactory = authServerChannel.MessageFactoryTestHook; var clientChannel = new OAuth2ClientChannel(); |