Beispiel #1
0
        public static FusionAuthenticationBuilder AddClient(this FusionAuthenticationBuilder fusionAuth)
        {
            var fusionClient = fusionAuth.Fusion.AddRestEaseClient();

            fusionClient.AddReplicaService <IAuthService, IAuthClient>();
            return(fusionAuth);
        }
Beispiel #2
0
 public static FusionAuthenticationBuilder AddServerSideBlazor(
     this FusionAuthenticationBuilder fusionAuth,
     Action <AuthorizationOptions>?configure = null)
 {
     fusionAuth.Services.RemoveAll(typeof(AuthenticationStateProvider));
     return(fusionAuth.AddBlazor());
 }
        public static FusionAuthenticationBuilder AddServer(this FusionAuthenticationBuilder fusionAuth,
                                                            Action <IServiceProvider, SessionMiddleware.Options>?sessionMiddlewareOptionsBuilder = null,
                                                            Action <IServiceProvider, ServerAuthHelper.Options>?authHelperOptionsBuilder         = null,
                                                            Action <IServiceProvider, SignInController.Options>?signInControllerOptionsBuilder   = null)
        {
            var fusion   = fusionAuth.Fusion;
            var services = fusionAuth.Services;

            fusionAuth.AddServerSideAuthService();

            services.TryAddSingleton(c => {
                var options = new SessionMiddleware.Options();
                sessionMiddlewareOptionsBuilder?.Invoke(c, options);
                return(options);
            });
            services.TryAddScoped <SessionMiddleware>();
            services.TryAddSingleton(c => {
                var options = new ServerAuthHelper.Options();
                authHelperOptionsBuilder?.Invoke(c, options);
                return(options);
            });
            services.TryAddSingleton <AuthSchemasCache>();
            services.TryAddScoped <ServerAuthHelper>();

            services.AddRouting();
            fusion.AddWebServer().AddControllers(signInControllerOptionsBuilder);

            return(fusionAuth);
        }
Beispiel #4
0
        public static FusionAuthenticationBuilder AddBlazor(
            this FusionAuthenticationBuilder fusionAuth,
            Action <AuthorizationOptions>?configure = null)
        {
            var services = fusionAuth.Services;

            services.AddAuthorizationCore(configure);
            services.RemoveAll(typeof(AuthenticationStateProvider));
            services.TryAddScoped <AuthenticationStateProvider, AuthStateProvider>();
            services.TryAddTransient(c => (AuthStateProvider)c.GetRequiredService <AuthenticationStateProvider>());
            return(fusionAuth);
        }
        public static FusionAuthenticationBuilder AddBlazor(
            this FusionAuthenticationBuilder fusionAuth,
            Action <AuthorizationOptions>?configure = null)
        {
            configure ??= _ => {}; // .NET 5.0 doesn't allow to pass null to AddAuthorizationCore
            var services = fusionAuth.Services;

            services.AddAuthorizationCore(configure);
            services.RemoveAll(typeof(AuthenticationStateProvider));
            services.TryAddSingleton <AuthStateProvider.Options>();
            services.TryAddScoped <AuthenticationStateProvider, AuthStateProvider>();
            services.TryAddTransient(c => (AuthStateProvider)c.GetRequiredService <AuthenticationStateProvider>());
            return(fusionAuth);
        }
        public static FusionAuthenticationBuilder AddServer(this FusionAuthenticationBuilder fusionAuth,
                                                            Action <IServiceProvider, SessionMiddleware.Options>?sessionMiddlewareOptionsBuilder = null,
                                                            Type?authServiceImplementationType = null)
        {
            fusionAuth.AddServerSideAuthService(authServiceImplementationType);

            var services = fusionAuth.Services;

            services.TryAddSingleton(c => {
                var options = new SessionMiddleware.Options();
                sessionMiddlewareOptionsBuilder?.Invoke(c, options);
                return(options);
            });
            services.TryAddScoped <SessionMiddleware>();
            services.AddRouting();
            services.AddControllers().AddApplicationPart(typeof(AuthController).Assembly);

            return(fusionAuth);
        }
Beispiel #7
0
    public static FusionAuthenticationBuilder AddServer(this FusionAuthenticationBuilder fusionAuth,
                                                        Func <IServiceProvider, SessionMiddleware.Options>?sessionMiddlewareOptionsFactory = null,
                                                        Func <IServiceProvider, ServerAuthHelper.Options>?serverAuthHelperSettingsFactory  = null,
                                                        Func <IServiceProvider, SignInController.Options>?signInControllerSettingsFactory  = null)
    {
        var fusion   = fusionAuth.Fusion;
        var services = fusionAuth.Services;

        fusionAuth.AddAuthBackend();

        services.TryAddSingleton(c => sessionMiddlewareOptionsFactory?.Invoke(c) ?? SessionMiddleware.DefaultSettings);
        services.TryAddScoped <SessionMiddleware>();
        services.TryAddSingleton(c => serverAuthHelperSettingsFactory?.Invoke(c) ?? ServerAuthHelper.DefaultSettings);
        services.TryAddScoped <ServerAuthHelper>();
        services.TryAddSingleton <AuthSchemasCache>();

        services.AddRouting();
        fusion.AddWebServer().AddControllers(signInControllerSettingsFactory);

        return(fusionAuth);
    }