public static void AddIdentityApiService(this IServiceCollection services, IConfiguration configuration)
 {
     IdentityInjectionHelper.Init(ref services);
     services.TryAddSingleton <IHttpContextAccessor, HttpContextAccessor>();
     services.TryAddScoped <IUsersContext, UsersContext>();
     services.AddJwtToken(configuration);
 }
Ejemplo 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"));
 }
Ejemplo 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>();
 }
Ejemplo 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>();
 }
Ejemplo 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>();
 }
Ejemplo 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;
     });
 }
Ejemplo n.º 8
0
 public static void AddIdentityWebService(this IServiceCollection services, string identityServerUrl = null)
 {
     ConfigureServices(services);
     IdentityInjectionHelper.SetBaseUrl(identityServerUrl);
 }