Ejemplo n.º 1
0
        protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
        {
            base.ApplicationStartup(container, pipelines);

            var authSources = config.GetSection("authSources").Get <IDictionary <string, string> >();
            var publicKeys  = new List <RSA>();

            foreach (var authSource in authSources)
            {
                var publicKey =
                    (RsaKeyParameters)PublicKeyFactory.CreateKey(Convert.FromBase64String(authSource.Key));
                publicKeys.Add(DotNetUtilities.ToRSA(publicKey));
            }

            AuthenticationHook.install(pipelines, publicKeys.Select(x => new RS384Algorithm(x)));
        }
Ejemplo n.º 2
0
        protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
        {
            base.ApplicationStartup(container, pipelines);

            // Authorization token support
            AuthenticationHook.install(pipelines, new[] {
                new RS384Algorithm(serverContext.configuration.crypto)
            });

            // Enable CORS
            pipelines.AfterRequest.AddItemToEndOfPipeline(ctx => {
                foreach (var origin in serverContext.configuration.corsOrigins)
                {
                    ctx.Response.WithHeader("Access-Control-Allow-Origin", origin);
                }

                ctx.Response
                .WithHeader("Access-Control-Allow-Methods", "GET,POST,PUT,DELETE")
                .WithHeader("Access-Control-Allow-Headers", "Accept, Origin, Content-type, Authorization");
            });

            // Set configuration...
        }