summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.OAuth
diff options
context:
space:
mode:
Diffstat (limited to 'src/DotNetOpenAuth.OAuth')
-rw-r--r--src/DotNetOpenAuth.OAuth/DotNetOpenAuth.OAuth.csproj4
-rw-r--r--src/DotNetOpenAuth.OAuth/OAuth/Messages/MessageBaseSimple.cs10
-rw-r--r--src/DotNetOpenAuth.OAuth/OAuth/Protocol.cs25
-rw-r--r--src/DotNetOpenAuth.OAuth/OAuth/ServiceProviderDescription.cs105
-rw-r--r--src/DotNetOpenAuth.OAuth/OAuthReporting.cs56
5 files changed, 81 insertions, 119 deletions
diff --git a/src/DotNetOpenAuth.OAuth/DotNetOpenAuth.OAuth.csproj b/src/DotNetOpenAuth.OAuth/DotNetOpenAuth.OAuth.csproj
index 58e09b0..8524a78 100644
--- a/src/DotNetOpenAuth.OAuth/DotNetOpenAuth.OAuth.csproj
+++ b/src/DotNetOpenAuth.OAuth/DotNetOpenAuth.OAuth.csproj
@@ -25,7 +25,6 @@
<Compile Include="Configuration\OAuthServiceProviderElement.cs" />
<Compile Include="Configuration\OAuthServiceProviderSecuritySettingsElement.cs" />
<Compile Include="Messaging\ITamperProtectionChannelBindingElement.cs" />
- <Compile Include="OAuthReporting.cs" />
<Compile Include="OAuth\ChannelElements\ITokenManager.cs" />
<Compile Include="OAuth\ChannelElements\OAuthHttpMethodBindingElement.cs" />
<Compile Include="OAuth\ChannelElements\PlaintextSigningBindingElement.cs" />
@@ -35,16 +34,17 @@
<Compile Include="OAuth\ChannelElements\UriOrOobEncoding.cs" />
<Compile Include="OAuth\ConsumerSecuritySettings.cs" />
<Compile Include="OAuth\Messages\ITokenSecretContainingMessage.cs" />
+ <Compile Include="OAuth\Messages\MessageBaseSimple.cs" />
<Compile Include="OAuth\OAuthStrings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>OAuthStrings.resx</DependentUpon>
</Compile>
<Compile Include="OAuth\SecuritySettings.cs" />
- <Compile Include="OAuth\ServiceProviderDescription.cs" />
<Compile Include="OAuth\Messages\ITokenContainingMessage.cs" />
<Compile Include="OAuth\Messages\SignedMessageBase.cs" />
<Compile Include="OAuth\ChannelElements\SigningBindingElementBase.cs" />
+ <Compile Include="OAuth\ServiceProviderDescription.cs" />
<Compile Include="OAuth\ServiceProviderSecuritySettings.cs" />
<Compile Include="OAuth\ChannelElements\ITamperResistantOAuthMessage.cs" />
<Compile Include="OAuth\Messages\MessageBase.cs" />
diff --git a/src/DotNetOpenAuth.OAuth/OAuth/Messages/MessageBaseSimple.cs b/src/DotNetOpenAuth.OAuth/OAuth/Messages/MessageBaseSimple.cs
new file mode 100644
index 0000000..23822d3
--- /dev/null
+++ b/src/DotNetOpenAuth.OAuth/OAuth/Messages/MessageBaseSimple.cs
@@ -0,0 +1,10 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DotNetOpenAuth.OAuth.Messages {
+ class MessageBaseSimple {
+ }
+}
diff --git a/src/DotNetOpenAuth.OAuth/OAuth/Protocol.cs b/src/DotNetOpenAuth.OAuth/OAuth/Protocol.cs
index 72f0ff4..049fd58 100644
--- a/src/DotNetOpenAuth.OAuth/OAuth/Protocol.cs
+++ b/src/DotNetOpenAuth.OAuth/OAuth/Protocol.cs
@@ -60,6 +60,31 @@ namespace DotNetOpenAuth.OAuth {
internal const string AuthorizationHeaderScheme = "OAuth";
/// <summary>
+ /// The name of the 'oauth_callback' parameter.
+ /// </summary>
+ internal const string CallbackParameter = "oauth_callback";
+
+ /// <summary>
+ /// The name of the 'oauth_callback_confirmed' parameter.
+ /// </summary>
+ internal const string CallbackConfirmedParameter = "oauth_callback_confirmed";
+
+ /// <summary>
+ /// The name of the 'oauth_token' parameter.
+ /// </summary>
+ internal const string TokenParameter = "oauth_token";
+
+ /// <summary>
+ /// The name of the 'oauth_token_secret' parameter.
+ /// </summary>
+ internal const string TokenSecretParameter = "oauth_token_secret";
+
+ /// <summary>
+ /// The name of the 'oauth_verifier' parameter.
+ /// </summary>
+ internal const string VerifierParameter = "oauth_verifier";
+
+ /// <summary>
/// Gets the <see cref="Protocol"/> instance with values initialized for V1.0 of the protocol.
/// </summary>
internal static readonly Protocol V10 = new Protocol {
diff --git a/src/DotNetOpenAuth.OAuth/OAuth/ServiceProviderDescription.cs b/src/DotNetOpenAuth.OAuth/OAuth/ServiceProviderDescription.cs
index 6dbe6ea..e6a2b32 100644
--- a/src/DotNetOpenAuth.OAuth/OAuth/ServiceProviderDescription.cs
+++ b/src/DotNetOpenAuth.OAuth/OAuth/ServiceProviderDescription.cs
@@ -1,101 +1,84 @@
//-----------------------------------------------------------------------
-// <copyright file="ServiceProviderDescription.cs" company="Outercurve Foundation">
-// Copyright (c) Outercurve Foundation. All rights reserved.
+// <copyright file="ServiceProviderDescription.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace DotNetOpenAuth.OAuth {
using System;
- using System.Diagnostics;
- using System.Diagnostics.CodeAnalysis;
+ using System.Collections.Generic;
using System.Linq;
- using DotNetOpenAuth.Messaging;
- using DotNetOpenAuth.OAuth.ChannelElements;
+ using System.Net.Http;
+ using System.Text;
+ using System.Threading.Tasks;
+ using Validation;
/// <summary>
- /// A description of the endpoints on a Service Provider.
+ /// Describes an OAuth 1.0 service provider.
/// </summary>
public class ServiceProviderDescription {
/// <summary>
- /// The field used to store the value of the <see cref="RequestTokenEndpoint"/> property.
- /// </summary>
- [DebuggerBrowsable(DebuggerBrowsableState.Never)]
- private MessageReceivingEndpoint requestTokenEndpoint;
-
- /// <summary>
- /// Initializes a new instance of the <see cref="ServiceProviderDescription"/> class.
+ /// Initializes a new instance of the <see cref="ServiceProviderDescription" /> class.
/// </summary>
public ServiceProviderDescription() {
- this.ProtocolVersion = Protocol.Default.ProtocolVersion;
+ this.TemporaryCredentialsRequestEndpointMethod = HttpMethod.Post;
+ this.TokenRequestEndpointMethod = HttpMethod.Post;
}
/// <summary>
- /// Gets or sets the OAuth version supported by the Service Provider.
- /// </summary>
- public ProtocolVersion ProtocolVersion { get; set; }
-
- /// <summary>
- /// Gets or sets the URL used to obtain an unauthorized Request Token,
- /// described in Section 6.1 (Obtaining an Unauthorized Request Token).
+ /// Initializes a new instance of the <see cref="ServiceProviderDescription"/> class.
/// </summary>
- /// <remarks>
- /// The request URL query MUST NOT contain any OAuth Protocol Parameters.
- /// This is the URL that <see cref="OAuth.Messages.UnauthorizedTokenRequest"/> messages are directed to.
- /// </remarks>
- /// <exception cref="ArgumentException">Thrown if this property is set to a URI with OAuth protocol parameters.</exception>
- public MessageReceivingEndpoint RequestTokenEndpoint {
- get {
- return this.requestTokenEndpoint;
+ /// <param name="temporaryCredentialsRequestEndpoint">The temporary credentials request endpoint.</param>
+ /// <param name="resourceOwnerAuthorizationEndpoint">The resource owner authorization endpoint.</param>
+ /// <param name="tokenRequestEndpoint">The token request endpoint.</param>
+ public ServiceProviderDescription(
+ string temporaryCredentialsRequestEndpoint, string resourceOwnerAuthorizationEndpoint, string tokenRequestEndpoint) {
+ if (temporaryCredentialsRequestEndpoint != null) {
+ this.TemporaryCredentialsRequestEndpoint = new Uri(temporaryCredentialsRequestEndpoint, UriKind.Absolute);
}
- set {
- if (value != null && UriUtil.QueryStringContainPrefixedParameters(value.Location, OAuth.Protocol.ParameterPrefix)) {
- throw new ArgumentException(OAuthStrings.RequestUrlMustNotHaveOAuthParameters);
- }
+ if (resourceOwnerAuthorizationEndpoint != null) {
+ this.ResourceOwnerAuthorizationEndpoint = new Uri(resourceOwnerAuthorizationEndpoint, UriKind.Absolute);
+ }
- this.requestTokenEndpoint = value;
+ if (tokenRequestEndpoint != null) {
+ this.TokenRequestEndpoint = new Uri(tokenRequestEndpoint, UriKind.Absolute);
}
}
/// <summary>
- /// Gets or sets the URL used to obtain User authorization for Consumer access,
- /// described in Section 6.2 (Obtaining User Authorization).
+ /// Gets or sets the temporary credentials request endpoint.
/// </summary>
- /// <remarks>
- /// This is the URL that <see cref="OAuth.Messages.UserAuthorizationRequest"/> messages are
- /// indirectly (via the user agent) sent to.
- /// </remarks>
- public MessageReceivingEndpoint UserAuthorizationEndpoint { get; set; }
+ /// <value>
+ /// The temporary credentials request endpoint.
+ /// </value>
+ public Uri TemporaryCredentialsRequestEndpoint { get; set; }
/// <summary>
- /// Gets or sets the URL used to exchange the User-authorized Request Token
- /// for an Access Token, described in Section 6.3 (Obtaining an Access Token).
+ /// Gets or sets the HTTP method to use with the temporary credentials request endpoint.
/// </summary>
- /// <remarks>
- /// This is the URL that <see cref="OAuth.Messages.AuthorizedTokenRequest"/> messages are directed to.
- /// </remarks>
- public MessageReceivingEndpoint AccessTokenEndpoint { get; set; }
+ public HttpMethod TemporaryCredentialsRequestEndpointMethod { get; set; }
/// <summary>
- /// Gets or sets the signing policies that apply to this Service Provider.
+ /// Gets the resource owner authorization endpoint.
/// </summary>
- [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays", Justification = "Type initializers require this format.")]
- public ITamperProtectionChannelBindingElement[] TamperProtectionElements { get; set; }
+ /// <value>
+ /// The resource owner authorization endpoint.
+ /// May be <c>null</c> for 2-legged OAuth.
+ /// </value>
+ public Uri ResourceOwnerAuthorizationEndpoint { get; set; }
/// <summary>
- /// Gets the OAuth version supported by the Service Provider.
+ /// Gets the token request endpoint.
/// </summary>
- internal Version Version {
- get { return Protocol.Lookup(this.ProtocolVersion).Version; }
- }
+ /// <value>
+ /// The token request endpoint.
+ /// </value>
+ public Uri TokenRequestEndpoint { get; set; }
/// <summary>
- /// Creates a signing element that includes all the signing elements this service provider supports.
+ /// Gets or sets the HTTP method to use with the token request endpoint.
/// </summary>
- /// <returns>The created signing element.</returns>
- internal ITamperProtectionChannelBindingElement CreateTamperProtectionElement() {
- RequiresEx.ValidState(this.TamperProtectionElements != null);
- return new SigningBindingElementChain(this.TamperProtectionElements.Select(el => (ITamperProtectionChannelBindingElement)el.Clone()).ToArray());
- }
+ public HttpMethod TokenRequestEndpointMethod { get; set; }
}
}
diff --git a/src/DotNetOpenAuth.OAuth/OAuthReporting.cs b/src/DotNetOpenAuth.OAuth/OAuthReporting.cs
deleted file mode 100644
index e2c0aab..0000000
--- a/src/DotNetOpenAuth.OAuth/OAuthReporting.cs
+++ /dev/null
@@ -1,56 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="OAuthReporting.cs" company="Outercurve Foundation">
-// Copyright (c) Outercurve Foundation. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-namespace DotNetOpenAuth {
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using DotNetOpenAuth.Messaging.Bindings;
- using DotNetOpenAuth.OAuth;
- using DotNetOpenAuth.OAuth.ChannelElements;
- using Validation;
-
- /// <summary>
- /// Utility methods specific to OAuth feature reporting.
- /// </summary>
- internal class OAuthReporting : Reporting {
- /// <summary>
- /// Records the feature and dependency use.
- /// </summary>
- /// <param name="value">The consumer or service provider.</param>
- /// <param name="service">The service.</param>
- /// <param name="tokenManager">The token manager.</param>
- /// <param name="nonceStore">The nonce store.</param>
- internal static void RecordFeatureAndDependencyUse(object value, ServiceProviderDescription service, ITokenManager tokenManager, INonceStore nonceStore) {
- Requires.NotNull(value, "value");
- Requires.NotNull(service, "service");
- Requires.NotNull(tokenManager, "tokenManager");
-
- // In release builds, just quietly return.
- if (value == null || service == null || tokenManager == null) {
- return;
- }
-
- if (Reporting.Enabled && Reporting.Configuration.IncludeFeatureUsage) {
- StringBuilder builder = new StringBuilder();
- builder.Append(value.GetType().Name);
- builder.Append(" ");
- builder.Append(tokenManager.GetType().Name);
- if (nonceStore != null) {
- builder.Append(" ");
- builder.Append(nonceStore.GetType().Name);
- }
- builder.Append(" ");
- builder.Append(service.Version);
- builder.Append(" ");
- builder.Append(service.UserAuthorizationEndpoint);
- Reporting.ObservedFeatures.Add(builder.ToString());
- Reporting.Touch();
- }
- }
- }
-}