Exemplo n.º 1
0
        public static HttpSelfHostConfiguration GetConfiguration(string url, bool requiresSSL)
        {
            var config = new HyperHttpSelfHostConfiguration(url, requiresSSL);

            if (requiresSSL)
            {
                config.ClientCredentialType = HttpClientCredentialType.Certificate;
            }

            // NOTE : Do not use username / password validation on the transport binding
            //        This is done at the server level
            config.AuthenticationCookieName        = "hyper-auth";
            config.WebApiUserNamePasswordValidator = new HyperUserNamePasswordValidator();

            // Routes
            config.Routes.MapHttpRouteLowercase(
                name: "DefaultApi",
                routeTemplate: "{controller}/{id}",
                defaults: new { id = RouteParameter.Optional, controller = "Root" });

            config.Formatters.Remove(config.Formatters.JsonFormatter);
            config.Formatters.AddRange(GetHyperMediaTypeFormatters());
            config.MessageHandlers.Add(new RestQueryParameterHandler());
            config.MessageHandlers.Add(new AuthenticationHandler(config));
            config.Filters.Add(new BasicAuthenticationAttribute(config));
            config.Services.Replace(typeof(ITraceWriter), new SimpleTracer());
            return(config);
        }
Exemplo n.º 2
0
        private HttpSelfHostServer GetServer(string url)
        {
            var config = new HyperHttpSelfHostConfiguration(url, false);

            // NOTE : Do not use username / password validation on the transport binding
            //        This is done at the server level
            config.AuthenticationCookieName        = "hyper-auth";
            config.WebApiUserNamePasswordValidator = new HyperUserNamePasswordValidator();

            // Routes
            config.Routes.MapHttpRouteLowercase(
                name: "DefaultApi",
                routeTemplate: "{controller}/{id}",
                defaults: new { id = RouteParameter.Optional, controller = "Root" });

            config.Formatters.Remove(config.Formatters.JsonFormatter);
            config.Formatters.Add(GetHyperMediaTypeFormatter(Application.GetTypes()));
            config.MessageHandlers.Add(new RestQueryParameterHandler());
            config.MessageHandlers.Add(new AuthenticationHandler(config));
            config.Filters.Add(new BasicAuthenticationAttribute(config));
            config.Services.Replace(typeof(ITraceWriter), new SimpleTracer());

            return(new HttpSelfHostServer(config));
        }
Exemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AuthenticationHandler" /> class.
 /// </summary>
 /// <param name="configuration">The configuration.</param>
 public AuthenticationHandler(HyperHttpSelfHostConfiguration configuration)
 {
     Configuration = configuration;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BasicAuthenticationAttribute" /> class.
 /// </summary>
 /// <param name="configuration">The configuration.</param>
 public BasicAuthenticationAttribute(HyperHttpSelfHostConfiguration configuration)
 {
     Configuration = configuration;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SimpleHyperApiControllerActionSelector" /> class.
 /// </summary>
 /// <param name="configuration">The configuration.</param>
 public SimpleHyperApiControllerActionSelector(HyperHttpSelfHostConfiguration configuration)
     : base(new ApiControllerActionSelector())
 {
     _configuration = configuration;
 }