//-----------------------------------------------------------------------
//
// Copyright (c) Outercurve Foundation. All rights reserved.
//
//-----------------------------------------------------------------------
namespace DotNetOpenAuth.OAuth2 {
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
///
/// A description of a client from an Authorization Server's point of view.
///
[ContractClass(typeof(IClientDescriptionContract))]
public interface IClientDescription {
///
/// Gets the client secret.
///
string Secret { get; }
///
/// Gets the callback to use when an individual authorization request
/// does not include an explicit callback URI.
///
/// An absolute URL; or null if none is registered.
Uri DefaultCallback { get; }
///
/// Determines whether a callback URI included in a client's authorization request
/// is among those allowed callbacks for the registered client.
///
/// The absolute URI the client has requested the authorization result be received at.
///
/// true if the callback URL is allowable for this client; otherwise, false.
///
///
///
/// At the point this method is invoked, the identity of the client has not
/// been confirmed. To avoid open redirector attacks, the alleged client's identity
/// is used to lookup a list of allowable callback URLs to make sure that the callback URL
/// the actual client is requesting is one of the expected ones.
///
///
/// From OAuth 2.0 section 2.1:
/// The authorization server SHOULD require the client to pre-register
/// their redirection URI or at least certain components such as the
/// scheme, host, port and path. If a redirection URI was registered,
/// the authorization server MUST compare any redirection URI received at
/// the authorization endpoint with the registered URI.
///
///
bool IsCallbackAllowed(Uri callback);
}
///
/// Contract class for the interface.
///
[ContractClassFor(typeof(IClientDescription))]
internal abstract class IClientDescriptionContract : IClientDescription {
#region IClientDescription Members
///
/// Gets the client secret.
///
///
string IClientDescription.Secret {
get { throw new NotImplementedException(); }
}
///
/// Gets the callback to use when an individual authorization request
/// does not include an explicit callback URI.
///
///
/// An absolute URL; or null if none is registered.
///
Uri IClientDescription.DefaultCallback {
get {
Contract.Ensures(Contract.Result() == null || Contract.Result().IsAbsoluteUri);
throw new NotImplementedException();
}
}
///
/// Determines whether a callback URI included in a client's authorization request
/// is among those allowed callbacks for the registered client.
///
/// The requested callback URI.
///
/// true if the callback is allowed; otherwise, false.
///
bool IClientDescription.IsCallbackAllowed(Uri callback) {
Requires.NotNull(callback, "callback");
Requires.True(callback.IsAbsoluteUri, "callback");
throw new NotImplementedException();
}
#endregion
}
}