protected override void Load(ContainerBuilder builder)
        {
            builder.RegisterType <SingleUserAuthentication>()
            .AsSelf()
            .SingleInstance();

            builder.Register(context =>
                             SingleUserAuthenticationSettings.FromConfiguration(
                                 context.Resolve <IConfiguration>()
                                 )
                             );
        }
Exemplo n.º 2
0
        private static void AddSheepItAuthentication(this IServiceCollection services, SingleUserAuthenticationSettings authorizationSettings)
        {
            services
            .AddAuthentication(options =>
            {
                options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                options.DefaultChallengeScheme    = JwtBearerDefaults.AuthenticationScheme;
            })
            .AddJwtBearer(options =>
            {
                // todo: this should be dependent on whether it's a dev environment
                options.RequireHttpsMetadata = false;

                options.SaveToken = true;

                options.TokenValidationParameters = new TokenValidationParameters
                {
                    ValidateIssuerSigningKey = true,
                    IssuerSigningKey         = authorizationSettings.SecretKey,

                    ValidateLifetime = true,
                    ClockSkew        = TimeSpan.FromMinutes(1),

                    ValidateIssuer   = false,
                    ValidateAudience = false
                };
            });
        }
Exemplo n.º 3
0
        public static void AddSheepItAuthentication(this IServiceCollection services, IConfiguration configuration)
        {
            var authorizationSettings = SingleUserAuthenticationSettings.FromConfiguration(configuration);

            services.AddSheepItAuthentication(authorizationSettings);
        }
Exemplo n.º 4
0
 public SingleUserAuthentication(SingleUserAuthenticationSettings settings)
 {
     _settings = settings;
 }