public static void AddIdentityApiService(this IServiceCollection services, IConfiguration configuration)
 {
     IdentityInjectionHelper.Init(ref services);
     services.TryAddSingleton <IHttpContextAccessor, HttpContextAccessor>();
     services.TryAddScoped <IUsersContext, UsersContext>();
     services.AddJwtToken(configuration);
 }
Esempio n. 2
0
 public static void AddOption(this IServiceCollection services, IConfiguration configuration)
 {
     DependencyInjectionHelper.Init(ref services);
     IdentityInjectionHelper.Init(ref services);
     services.AddOptions();
     services.Configure <ApiServer>(configuration.GetSection("ApiServer"));
 }
Esempio n. 3
0
 public IdentitySSOAuthorizeAttribute()
 {
     _loginActionName            = DEFAULT_ACTION_NAME;
     _authenticationScheme       = DEFAULT_AUTH_SCHEME;
     _loginControllerName        = DEFAULT_CONTROLLER_NAME;
     _signInService              = IdentityInjectionHelper.GetService <ISignInRequestService>();
     _authenticateRequestService = IdentityInjectionHelper.GetService <IAuthenticateRequestService>();
 }
Esempio n. 4
0
 private static void ConfigureServices(IServiceCollection services)
 {
     IdentityInjectionHelper.Init(ref services);
     services.TryAddSingleton <IHttpContextAccessor, HttpContextAccessor>();
     services.TryAddScoped <IUsersContext, UsersContext>();
     services.TryAddScoped <ISignInRequestService, SignInRequestService>();
     services.TryAddScoped <IRolesRequestServices, RolesRequestServices>();
     services.TryAddScoped <IAccountsRequestService, AccountsRequestService>();
     services.TryAddScoped <IAuthenticateRequestService, AuthenticateRequestService>();
 }
 public static void AddIdentityFrontEndService(this IServiceCollection services, IConfiguration configuration, string identityServerUrl = "")
 {
     IdentityInjectionHelper.Init(ref services);
     IdentityInjectionHelper.SetBaseUrl(identityServerUrl);
     services.TryAddSingleton <IHttpContextAccessor, HttpContextAccessor>();
     services.TryAddScoped <IUsersContext, UsersContext>();
     services.TryAddScoped <ISignInRequestService, SignInRequestService>();
     services.TryAddScoped <IRolesRequestServices, RolesRequestServices>();
     services.TryAddScoped <IAccountsRequestService, AccountsRequestService>();
     services.TryAddScoped <IAuthenticateRequestService, AuthenticateRequestService>();
 }
Esempio n. 6
0
 public IdentitySSOAuthorizeAttribute(string controllerName, string actionName, string authenticationScheme, IAuthenticateRequestService authenticateRequestService = null, ISignInRequestService signInService = null)
 {
     _loginActionName      = actionName;
     _loginControllerName  = controllerName;
     _authenticationScheme = string.IsNullOrEmpty(authenticationScheme) ? DEFAULT_AUTH_SCHEME : authenticationScheme;
     _signInService        = signInService != null
         ? signInService
         :IdentityInjectionHelper.GetService <ISignInRequestService>();
     _authenticateRequestService = authenticateRequestService != null
         ? authenticateRequestService
         : IdentityInjectionHelper.GetService <IAuthenticateRequestService>();
 }
Esempio n. 7
0
 public static void AddIdentityBackEndService(this IServiceCollection services, IConfiguration configuration)
 {
     IdentityInjectionHelper.Init(ref services);
     services.TryAddSingleton <IHttpContextAccessor, HttpContextAccessor>();
     services.TryAddScoped <IUsersContext, UsersContext>();
     services.AddOptions();
     services.Configure <JwtTokenOption>(configuration.GetSection("JwtTokenOption"));
     services.AddAuthentication()
     .AddJwtBearer(options =>
     {
         options.TokenValidationParameters = JwtTokenBuilderHelper.DefaultBuilder.GetValidationParameters();
         options.SaveToken            = true;
         options.RequireHttpsMetadata = false;
     });
 }
Esempio n. 8
0
 public static void AddIdentityWebService(this IServiceCollection services, string identityServerUrl = null)
 {
     ConfigureServices(services);
     IdentityInjectionHelper.SetBaseUrl(identityServerUrl);
 }