示例#1
0
 public AboutController(SportWorldContext SportWorldContext, [FromServices] ISecretSettings secrets)
 {
     _storeBl = new StoreBl(SportWorldContext);
     _secrets = secrets;
 }
示例#2
0
 public AuthController(IAuthenticationService authenticationService, ISecretSettings settings)
 {
     _authenticationService = authenticationService;
     _secretSettings        = settings;
 }
        public static void RegisterJwtAuthentication(this IServiceCollection services, ISecretSettings secretSettings)
        {
            if (services is null)
            {
                throw new ArgumentNullException(nameof(services));
            }

            if (secretSettings is null)
            {
                throw new ArgumentNullException(nameof(secretSettings));
            }

            services.AddAuthentication(x =>
            {
                x.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                x.DefaultChallengeScheme    = JwtBearerDefaults.AuthenticationScheme;
            }).AddJwtBearer(options =>
            {
                options.RequireHttpsMetadata = false;
                options.SaveToken            = true;

                options.TokenValidationParameters = new TokenValidationParameters
                {
                    ValidateIssuerSigningKey = true,
                    IssuerSigningKey         = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(secretSettings.JwtSigningKey)),
                    ValidateIssuer           = false,
                    ValidateAudience         = false,
                    ClockSkew = TimeSpan.FromMinutes(5)
                };
            });
        }
示例#4
0
 public AboutController(HydraContext hydraContext, [FromServices] ISecretSettings secrets)
 {
     _storeBl = new StoreBl(hydraContext);
     _secrets = secrets;
 }
示例#5
0
 public AboutController(CCContext ccContext, [FromServices] ISecretSettings secrets)
 {
     _storeBl = new StoreBl(ccContext);
     _secrets = secrets;
 }