Example #1
0
        /// <summary>
        /// Configures minimal dependencies you need to make your app work. It registers <see cref="IDateTimeProvider"/> by <see cref="DefaultDateTimeProvider"/>
        /// | <see cref="IAppEnvironmentsProvider"/> by <see cref="DefaultAppEnvironmentsProvider"/>
        /// | <see cref="IContentFormatter"/> by <see cref="DefaultJsonContentFormatter"/>
        /// | <see cref="IPathProvider"/> by <see cref="DefaultPathProvider"/>
        /// | <see cref="IScopeStatusManager"/> by <see cref="DefaultScopeStatusManager"/>
        /// </summary>
        public static IDependencyManager RegisterMinimalDependencies(this IDependencyManager dependencyManager)
        {
            if (dependencyManager == null)
            {
                throw new ArgumentNullException(nameof(dependencyManager));
            }

            dependencyManager.RegisterInstance(DefaultAppModulesProvider.Current, overwriteExciting: false)
            .RegisterInstance(DefaultDependencyManager.Current, overwriteExciting: false);

            dependencyManager.RegisterUsing(resolver =>
            {
                IAppEnvironmentsProvider appEnvironmentsProvider = resolver.Resolve <IAppEnvironmentsProvider>();
                return(appEnvironmentsProvider.GetActiveAppEnvironment());
            });

            dependencyManager.Register <IDateTimeProvider, DefaultDateTimeProvider>(lifeCycle: DependencyLifeCycle.SingleInstance, overwriteExciting: false);

            dependencyManager.RegisterInstance(DefaultAppEnvironmentsProvider.Current, overwriteExciting: false);
            dependencyManager.RegisterInstance(DefaultJsonContentFormatter.Current, overwriteExciting: false);
            dependencyManager.RegisterInstance(DefaultPathProvider.Current, overwriteExciting: false);
            dependencyManager.Register <IUrlStateProvider, DefaultUrlStateProvider>(lifeCycle: DependencyLifeCycle.SingleInstance, overwriteExciting: false);

            dependencyManager.Register <IScopeStatusManager, DefaultScopeStatusManager>(overwriteExciting: false);

            return(dependencyManager);
        }
        public override IEnumerable <Client> GetClients()
        {
            AppEnvironment activeAppEnvironment = _appEnvironmentsProvider.GetActiveAppEnvironment();

            return(new[]
            {
                GetImplicitFlowClient(new BitImplicitFlowClient
                {
                    ClientName = "Test",
                    ClientId = "Test",
                    Secret = "secret",
                    RedirectUris = new List <string>
                    {
                        $@"^(http|https):\/\/(\S+\.)?(bit-framework.com|localhost|127.0.0.1|indie-ir001.ngrok.io|indie-ir002.ngrok.io)(:\d+)?\b{activeAppEnvironment.GetHostVirtualPath()}\bSignIn\/?",
                        "Test://oauth2redirect"
                    },
                    PostLogoutRedirectUris = new List <string>
                    {
                        $@"^(http|https):\/\/(\S+\.)?(bit-framework.com|localhost|127.0.0.1)(:\d+)?\b{activeAppEnvironment.GetHostVirtualPath()}\bSignOut\/?",
                        "Test://oauth2redirect"
                    },
                    TokensLifetime = TimeSpan.FromDays(7),
                    Enabled = true
                }),
                GetResourceOwnerFlowClient(new BitResourceOwnerFlowClient
                {
                    ClientName = "TestResOwner",
                    ClientId = "TestResOwner",
                    Secret = "secret",
                    TokensLifetime = TimeSpan.FromDays(7),
                    Enabled = true
                })
            });
        }
Example #3
0
        public virtual AppEnvironment GetActiveAppEnvironment()
        {
            AppEnvironment result = _appEnvironmentsProvider.GetActiveAppEnvironment();

            _appEnvCustomizer?.Invoke(result);

            return(result);
        }
Example #4
0
        public virtual (bool success, string message) TryGetActiveAppEnvironment(out AppEnvironment activeAppEnvironment)
        {
            try
            {
                activeAppEnvironment = _appEnvironmentsProvider.GetActiveAppEnvironment();

                _appEnvCustomizer?.Invoke(activeAppEnvironment);

                return(true, null);
            }
            catch (Exception exp)
            {
                activeAppEnvironment = null;
                return(false, exp.Message);
            }
        }