public AccountController(IFiguresService figuresService,
                          UserManager <AppUser> userManager,
                          IJwtBuilder jwtBuilder, IOptions <JwtIssuerOptions> jwtOptions) : base(figuresService, userManager)
 {
     _jwtBuilder = jwtBuilder;
     _jwtOptions = jwtOptions.Value;
 }
 public JwtUnitTest()
 {
     jwtBuilder = new JwtBuilder(new JwtConfiguration()
     {
         Issuer = "Issuer", Secret = "Secret123456789123456789"
     });
 }
 public OpenIDAccessTokenBuilder(IClaimsJwsPayloadEnricher claimsJwsPayloadEnricher,
                                 IGrantedTokenHelper grantedTokenHelper,
                                 IJwtBuilder jwtBuilder,
                                 IOptions <OAuthHostOptions> options) : base(grantedTokenHelper, jwtBuilder, options)
 {
     _claimsJwsPayloadEnricher = claimsJwsPayloadEnricher;
 }
 public IdentityController(IMongoDatabase db, IEncryptor encryptor, IJwtBuilder jwtBuilder, IEmailSender emailSender)
 {
     _userRepository = new  UserRepository(db);
     _encryptor      = encryptor;
     _jwtBuilder     = jwtBuilder;
     _emailSender    = emailSender;
 }
Esempio n. 5
0
 public CompoLoginUsernamePasswordModelModel(IUserApplication userApplication, IMsgBox msgBox, IJwtBuilder jwtBuilder, ILocalizer localizer)
 {
     _userApplication = userApplication;
     _msgBox          = msgBox;
     _jwtBuilder      = jwtBuilder;
     _localizer       = localizer;
 }
Esempio n. 6
0
 public IdentityServerController(IJwtBuilder jwtBuilder, GloboUsers AircodUsers, IWebHostEnvironment IWebHostEnvironment, IdentityDbContext _db)
 {
     this._jwtBuilder          = jwtBuilder;
     this._AircodUsers         = AircodUsers;
     this._IWebHostEnvironment = IWebHostEnvironment;
     this.db = _db;
 }
Esempio n. 7
0
 public AuthService(ApplicationDbContext context, UserManager <ApplicationUser> userManager,
                    IJwtBuilder jwtBuilder)
 {
     _context     = context;
     _userManager = userManager;
     _jwtBuilder  = jwtBuilder;
 }
Esempio n. 8
0
 public UserController
     (IMongoDatabase db, IJwtBuilder jwtBuilder, IEncryptor encryptor)
 {
     _userRepository = new UserRepository(db);
     _jwtBuilder     = jwtBuilder;
     _encryptor      = encryptor;
 }
        public void RequireAuthentication_configures_mvc_if_delegate_returns_true(IJwtBuilder builder, Func <bool> test)
        {
            Mock.Get(test).Setup(p => p()).Returns(true);

            BuilderExtensions.RequireAuthentication(builder, test);

            Mock.Get(builder.Services).Verify(p => p.Add(It.Is <ServiceDescriptor>(sd => sd.ServiceType == typeof(IConfigureOptions <MvcOptions>))));
        }
Esempio n. 10
0
 public IdTokenBuilder(IJwtBuilder jwtBuilder, IEnumerable <IClaimsSource> claimsSources, IEnumerable <ISubjectTypeBuilder> subjectTypeBuilders, IAmrHelper amrHelper, IOAuthUserQueryRepository oauthUserQueryRepository)
 {
     _jwtBuilder          = jwtBuilder;
     _claimsSources       = claimsSources;
     _subjectTypeBuilders = subjectTypeBuilders;
     _amrHelper           = amrHelper;
     _oauthUserRepository = oauthUserQueryRepository;
 }
Esempio n. 11
0
 public static IJwtBuilder AddUserExtractor <TExtractor>(this IJwtBuilder builder, ServiceLifetime lifetime = ServiceLifetime.Singleton)
     where TExtractor : class, IUserExtractor
 {
     return(builder.AddJwtBuilderAction((services, configuration) =>
     {
         services.Add(new ServiceDescriptor(typeof(IUserExtractor), typeof(TExtractor), lifetime));
     }));
 }
 public OpenBankingApiAccessTokenBuilder(
     IGrantedTokenHelper grantedTokenHelper,
     IJwtBuilder jwtBuilder,
     IOptions <OAuthHostOptions> options,
     IOpenBankingApiAuthRequestEnricher openBankingApiAuthRequestEnricher) : base(grantedTokenHelper, jwtBuilder, options)
 {
     _openBankingApiAuthRequestEnricher = openBankingApiAuthRequestEnricher;
 }
 public CompoLoginPhoneNumberOtpModel(IMsgBox msgBox, IUserApplication userApplication, ILocalizer localizer, IJwtBuilder jwtBuilder, ISmsSender smsSender)
 {
     _msgBox          = msgBox;
     _userApplication = userApplication;
     _localizer       = localizer;
     _jwtBuilder      = jwtBuilder;
     _smsSender       = smsSender;
 }
Esempio n. 14
0
 public AuthService(IJwtBuilder jwtBuilder, IEmailPublisher emailPublisher, ICodeRepository codeRepository,
                    IIdentityRepository identityRepository)
 {
     _jwtBuilder         = jwtBuilder;
     _emailPublisher     = emailPublisher;
     _codeRepository     = codeRepository;
     _identityRepository = identityRepository;
 }
 public UserInfoController(IJwtParser jwtParser, IJwtBuilder jwtBuilder, IOAuthScopeQueryRepository oauthScopeRepository, IOAuthUserQueryRepository oauthUserRepository, IOAuthClientQueryRepository oauthClientRepository, IEnumerable <IClaimsSource> claimsSources)
 {
     _jwtParser             = jwtParser;
     _jwtBuilder            = jwtBuilder;
     _oauthScopeRepository  = oauthScopeRepository;
     _oauthUserRepository   = oauthUserRepository;
     _oauthClientRepository = oauthClientRepository;
     _claimsSources         = claimsSources;
 }
 public LoginController(
     DataContext dataContext,
     UserManager <ApplicationIdentityUser> userManager,
     SignInManager <ApplicationIdentityUser> signInManager,
     IJwtBuilder jwt)
     : base(dataContext)
 {
     _userManager   = userManager ?? throw new ArgumentNullException(nameof(userManager));
     _signInManager = signInManager ?? throw new ArgumentNullException(nameof(signInManager));
     _jwt           = jwt ?? throw new ArgumentNullException(nameof(jwt));
 }
Esempio n. 17
0
 public OpenBankingApiIdTokenBuilder(IJwtBuilder jwtBuilder,
                                     IOptions <OpenBankingApiOptions> options,
                                     IEnumerable <IClaimsSource> claimsSources,
                                     IEnumerable <ISubjectTypeBuilder> subjectTypeBuilders,
                                     IAmrHelper amrHelper,
                                     IOAuthUserQueryRepository oauthUserQueryRepository,
                                     IClaimsJwsPayloadEnricher claimsJwsPayloadEnricher) : base(jwtBuilder, claimsSources, subjectTypeBuilders, amrHelper, oauthUserQueryRepository, claimsJwsPayloadEnricher)
 {
     _jwtBuilder = jwtBuilder;
     _options    = options.Value;
 }
Esempio n. 18
0
 public AuthService(UserManager <ApplicationUser> userManager,
                    SignInManager <ApplicationUser> signInManager,
                    IOptions <JwtSettings> options,
                    IScopeControl scopeControl)
 {
     _userManager   = userManager;
     _signInManager = signInManager;
     _jwtBuilder    = JwtBuilder.CreateBuilder();
     _jwtSettings   = options.Value;
     _scopeControl  = scopeControl;
 }
Esempio n. 19
0
        public static IJwtBuilder RequireAuthentication(this IJwtBuilder builder, Func <bool> predicate = null)
        {
            if (predicate?.Invoke() ?? true)
            {
                builder.Services.Configure <MvcOptions>(options =>
                {
                    var policy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build();
                    options.Filters.Add(new AuthorizeFilter(policy));
                });
            }

            return(builder);
        }
Esempio n. 20
0
        public static IJwtBuilder AddBasicUserAuthenticator(this IJwtBuilder builder, string sectionKey = "JWT:Client")
        {
            return(builder.AddJwtBuilderAction((services, configuration) =>
            {
                var credentials = configuration.GetSection(sectionKey).Get <BasicCredentials>();

                Validator.ValidateObject(credentials, new ValidationContext(credentials));

                services.AddSingleton(credentials);

                services.AddSingleton <IUserAuthenticator, BasicUserAuthenticator>();
            }));
        }
        public static async Task <string> GenerateJwt(ClaimsIdentity identity,
                                                      IJwtBuilder jwtBuilder,
                                                      string userName,
                                                      JwtIssuerOptions jwtOptions,
                                                      JsonSerializerSettings serializerSettings)
        {
            var response = new
            {
                auth_token = await jwtBuilder.GenerateEncodedToken(userName, identity),
                expires_in = (int)jwtOptions.ValidFor.TotalSeconds
            };

            return(JsonConvert.SerializeObject(response, serializerSettings));
        }
Esempio n. 22
0
 public CheckSessionController(
     IOptions <OpenIDHostOptions> options,
     IJwtParser jwtParser,
     IOAuthUserRepository oAuthUserRepository,
     IOAuthClientRepository oAuthClientRepository,
     IJwtBuilder jwtBuilder,
     IHttpClientFactory httpClientFactory)
 {
     _options               = options.Value;
     _jwtParser             = jwtParser;
     _oauthUserRepository   = oAuthUserRepository;
     _oauthClientRepository = oAuthClientRepository;
     _jwtBuilder            = jwtBuilder;
     _httpClientFactory     = httpClientFactory;
 }
Esempio n. 23
0
        //private readonly ILogger logger;

        public AuthorizationService(IDatabase database, IOptions <AuthorizationOptions> options, IDistributedCache distributedCache,
                                    ISignInTokenBiz signInTokenBiz, IIdentityService identityManager, IJwtBuilder jwtBuilder, ICredentialBiz credentialManager /*, ILogger<AuthorizationService> logger*/)
        {
            _database      = database;
            _options       = options.Value;
            _signInOptions = _options.SignInOptions;

            //this.logger = logger;
            _frequencyChecker = new DistributedCacheFrequencyChecker(distributedCache);

            _signInTokenBiz  = signInTokenBiz;
            _identityService = identityManager;
            _jwtBuilder      = jwtBuilder;
            _credentialBiz   = credentialManager;
        }
Esempio n. 24
0
        public static IJwtBuilder AddJwtBuilderAction(this IJwtBuilder builder, Action <IServiceCollection, IConfiguration> action)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            if (action == null)
            {
                throw new ArgumentNullException(nameof(action));
            }

            action(builder.Services, builder.Configuration);

            return(builder);
        }
        public void AddBasicUserAuthenticator_registers_BasicUserAuthenticator(IJwtBuilder builder, BasicCredentials credentials)
        {
            var values = new Dictionary <string, string>
            {
                ["JWT:Client:Username"] = credentials.Username,
                ["JWT:Client:Password"] = credentials.Password
            };

            var configurationBuilder = new ConfigurationBuilder().AddInMemoryCollection(values);
            var configuration        = configurationBuilder.Build();

            Mock.Get(builder).SetupGet(p => p.Configuration).Returns(configuration);

            BuilderExtensions.AddBasicUserAuthenticator(builder);

            Mock.Get(builder.Services).Verify(p => p.Add(It.Is <ServiceDescriptor>(sd => sd.ServiceType == typeof(IUserAuthenticator) && sd.ImplementationType == typeof(BasicUserAuthenticator))));
        }
 public UserInfoController(
     IJwtParser jwtParser,
     IJwtBuilder jwtBuilder,
     IOAuthScopeQueryRepository oauthScopeRepository,
     IOAuthUserQueryRepository oauthUserRepository,
     IOAuthClientQueryRepository oauthClientRepository,
     IEnumerable <IClaimsSource> claimsSources,
     ITokenQueryRepository tokenQueryRepository,
     IClaimsJwsPayloadEnricher claimsJwsPayloadEnricher,
     ILogger <UserInfoController> logger)
 {
     _jwtParser                = jwtParser;
     _jwtBuilder               = jwtBuilder;
     _oauthScopeRepository     = oauthScopeRepository;
     _oauthUserRepository      = oauthUserRepository;
     _oauthClientRepository    = oauthClientRepository;
     _claimsSources            = claimsSources;
     _tokenQueryRepository     = tokenQueryRepository;
     _claimsJwsPayloadEnricher = claimsJwsPayloadEnricher;
     _logger = logger;
 }
Esempio n. 27
0
 public AggregateHttpClaimsSource(AggregateHttpClaimsSourceOptions httpClaimsSourceOptions, IJwtBuilder jwtBuilder, IJwtParser jwtParser)
 {
     _httpClaimsSourceOptions = httpClaimsSourceOptions;
     _jwtBuilder = jwtBuilder;
     _jwtParser  = jwtParser;
 }
Esempio n. 28
0
 public GolemNetHubAuthApiController(INetHubProcessor netHubProcessor, IJwtBuilder jwtBuilder, IConfigProvider config)
 {
     this.NetHubProcessor = netHubProcessor;
     this.JwtBuilder      = jwtBuilder;
     this.ConfigProvider  = config;
 }
Esempio n. 29
0
 public static IJwtBuilder AddUserValidation <T>(this IJwtBuilder builder) where T : class, IUserValidatorService
 {
     builder.Services.AddTransient <IUserValidatorService, T>();
     return(builder);
 }
Esempio n. 30
0
 public AccessTokenBuilder(IGrantedTokenHelper grantedTokenHelper, IJwtBuilder jwtBuilder)
 {
     _grantedTokenHelper = grantedTokenHelper;
     _jwtBuilder         = jwtBuilder;
 }