using System;
using System.Collections.Generic;
using System.Net.Http;
using Microsoft.Owin;
using Microsoft.Owin.Security;
namespace Owin.Security.Providers.Salesforce
{
public class SalesforceAuthenticationOptions : AuthenticationOptions
{
public class SalesforceAuthenticationEndpoints
{
///
/// Endpoint which is used to redirect users to request Salesforce access
///
public string AuthorizationEndpoint { get; set; }
///
/// Endpoint which is used to exchange code for access token
///
public string TokenEndpoint { get; set; }
///
/// Production or Sandbox. Use Constants.ProductionEnvironment or Constants.SandboxEnvironment
///
public string Environment { get; set; }
}
///
/// Options for Display Mode
/// Changes the login and authorization pages’ display type. Salesforce supports these values.
/// page—Full-page authorization screen(default)
/// popup—Compact dialog optimized for modern web browser popup windows
/// touch—Mobile-optimized dialog designed for modern smartphones, such as Android and iPhone
/// mobile—Mobile-optimized dialog designed for less capable smartphones, such as BlackBerry OS 5
///
public enum Display{
page,
popup,
touch,
mobile
}
///
/// Gets or sets the a pinned certificate validator to use to validate the endpoints used
/// in back channel communications belong to Salesforce.
///
///
/// The pinned certificate validator.
///
///
/// If this property is null then the default certificate checks are performed,
/// validating the subject name and if the signing chain is a trusted party.
///
public ICertificateValidator BackchannelCertificateValidator { get; set; }
///
/// The HttpMessageHandler used to communicate with Salesforce.
/// This cannot be set at the same time as BackchannelCertificateValidator unless the value
/// can be downcast to a WebRequestHandler.
///
public HttpMessageHandler BackchannelHttpHandler { get; set; }
///
/// Gets or sets timeout value in milliseconds for back channel communications with Salesforce.
///
///
/// The back channel timeout in milliseconds.
///
public TimeSpan BackchannelTimeout { get; set; }
///
/// The request path within the application's base path where the user-agent will be returned.
/// The middleware will process this request when it arrives.
/// Default value is "/signin-Salesforce".
///
public PathString CallbackPath { get; set; }
///
/// Get or sets the text that the user can display on a sign in user interface.
///
public string Caption
{
get { return Description.Caption; }
set { Description.Caption = value; }
}
///
/// Gets or sets the Salesforce supplied Client ID
///
public string ClientId { get; set; }
///
/// Gets or sets the Salesforce supplied Client Secret
///
public string ClientSecret { get; set; }
///
/// Gets the sets of OAuth endpoints used to authenticate against Salesforce.
/// Overriding these endpoints allows you to use Salesforce Enterprise for authentication.
///
public SalesforceAuthenticationEndpoints Endpoints { get; set; }
///
/// Gets or sets the used in the authentication events
///
public ISalesforceAuthenticationProvider Provider { get; set; }
///
/// A list of permissions to request.
///
public IList Scope { get; private set; }
///
/// Specifies how the authorization server prompts the user for reauthentication and reapproval. This parameter is optional.
/// The only values Salesforce supports are:
/// login—The authorization server must prompt the user for reauthentication, forcing the user to log in again.
/// consent—The authorization server must prompt the user for reapproval before returning information to the client.
/// It is valid to pass both values, separated by a space, to require the user to both log in and reauthorize.
///
public string Prompt { get; set; }
///
/// Gets or sets the name of another authentication middleware which will be responsible for actually issuing a user
/// .
///
public string SignInAsAuthenticationType { get; set; }
///
/// Gets or sets the display—(Optional)
///
public Display DisplayMode { get; set; }
///
/// Gets or sets the type used to secure data handled by the middleware.
///
public ISecureDataFormat StateDataFormat { get; set; }
///
/// Initializes a new
///
public SalesforceAuthenticationOptions()
: base("Salesforce")
{
Caption = Constants.DefaultAuthenticationType;
CallbackPath = new PathString("/signin-salesforce");
AuthenticationMode = AuthenticationMode.Passive;
Scope = new List { "id" };
BackchannelTimeout = TimeSpan.FromSeconds(60);
Endpoints = new SalesforceAuthenticationEndpoints
{
AuthorizationEndpoint = null,
TokenEndpoint = null
};
}
}
}