예제 #1
1
        private static void UseSmtpEmailer(Container container)
        {
            var appSettings = new AppSettings();

            //Use 'SmtpConfig' appSetting in Web.config if it exists otherwise use default config below:
            container.Register(appSettings.Get("SmtpConfig",
                new SmtpConfig {
                    Host = "smtphost",
                    Port = 587,
                    UserName = "******",
                    Password = "******"
                }));

            container.RegisterAs<SmtpEmailer, IEmailer>().ReusedWithin(ReuseScope.Request);
        }
예제 #2
0
        public override void Configure(Container container)
        {
            Plugins.Add(new RazorFormat());

            container.Register(new DataSource());

            container.Register<IDbConnectionFactory>(
                new OrmLiteConnectionFactory(":memory:", SqliteDialect.Provider) {
                    ConnectionFilter = x => new ProfiledDbConnection(x, Profiler.Current)
                });

            using (var db = container.Resolve<IDbConnectionFactory>().Open())
            {
                db.CreateTableIfNotExists<Rockstar>();
                db.Insert(Rockstar.SeedData);
            }

            JsConfig.EmitCamelCaseNames = true;

            //Register Typed Config some services might need to access
            var appSettings = new AppSettings();

            //Register a external dependency-free 
            container.Register<ICacheClient>(new MemoryCacheClient());
            //Configure an alt. distributed persistent cache that survives AppDomain restarts. e.g Redis
            //container.Register<IRedisClientsManager>(c => new PooledRedisClientManager("localhost:6379"));

            //Enable Authentication an Registration
            ConfigureAuth(container);

            //Create your own custom User table
            using (var db = container.Resolve<IDbConnectionFactory>().Open())
                db.DropAndCreateTable<UserTable>();
        }
예제 #3
0
        /* Example ServiceStack Authentication and CustomUserSession */
        private void ConfigureAuth(Funq.Container container)
        {
            var appSettings = new AppSettings();

            //Default route: /auth/{provider}
            Plugins.Add(new AuthFeature(() => new CustomUserSession(),
                new IAuthProvider[] {
                    new CredentialsAuthProvider(appSettings),
                    new FacebookAuthProvider(appSettings),
                    new TwitterAuthProvider(appSettings),
                    new BasicAuthProvider(appSettings),
                }));

            //Default route: /register
            Plugins.Add(new RegistrationFeature());

            //Requires ConnectionString configured in Web.Config
            var connectionString = ConfigurationManager.ConnectionStrings["AppDb"].ConnectionString;
            container.Register<IDbConnectionFactory>(c =>
                new OrmLiteConnectionFactory(connectionString, SqlServerDialect.Provider));

            container.Register<IUserAuthRepository>(c =>
                new OrmLiteAuthRepository(c.Resolve<IDbConnectionFactory>()));

            container.Resolve<IUserAuthRepository>().InitSchema();
        }
예제 #4
0
		/* Uncomment to enable ServiceStack Authentication and CustomUserSession */
		private void ConfigureAuth(Funq.Container container)
		{
			var appSettings = new AppSettings();

			//Default route: /auth/{provider}
			Plugins.Add(new AuthFeature(() => new CustomUserSession(),
				new IAuthProvider[] {
					new AcmeCredentialsAuthProvider(appSettings), 
				})); 

			//Default route: /register
			Plugins.Add(new RegistrationFeature()); 

			//Requires ConnectionString configured in Web.Config
			var connectionString = ConfigurationManager.ConnectionStrings["SSHelloWorldAuth"].ConnectionString;
			container.Register<IDbConnectionFactory>(c =>
				new OrmLiteConnectionFactory(connectionString, SqlServerDialect.Provider));

			container.Register<IUserAuthRepository>(c =>
				new OrmLiteAuthRepository(c.Resolve<IDbConnectionFactory>()));

			var authRepo = (OrmLiteAuthRepository)container.Resolve<IUserAuthRepository>();
			authRepo.CreateMissingTables();

            // CreateUser(authRepo, 1, "testuser", null, "Test2#4%");
		}
예제 #5
0
 public override IUserAuthRepository CreateAuthRepo()
 {
     var appSettings = new AppSettings();
     var redisRepo = new RedisAuthRepository(new BasicRedisClientManager(new string[] { appSettings.GetString("Redis.Host") ?? "localhost" }));
     InitTest(redisRepo);
     return redisRepo;
 }
        /// <summary>
        /// Configure the given container with the 
        /// registrations provided by the service.
        /// </summary>
        /// <param name="container">Container to register.</param>
        public override void Configure(Container container)
        {
            this.SetConfig(new EndpointHostConfig { ServiceStackHandlerFactoryPath = "api" });

            // Access Web.Config AppSettings
            var appSettings = new AppSettings();
            container.Register(appSettings);

            AppConfig = new AppConfig(appSettings);

            // Add all the Auth Providers to allow registration with
            this.ConfigureAuth();

            // register REST-ful urls
            this.ConfigureRoutes();

            // register Response Filters
            this.ConfigureResponseFilters();

            // Adds caching
            container.Register<ICacheClient>(new MemoryCacheClient());

            // Adds persistent user repository
            var userRep = new InMemoryAuthRepository();
            container.Register<IUserAuthRepository>(userRep);
        }
예제 #7
0
        static void Main(string[] args)
        {
            string archivoPorProcesar = null;

            if (args.Length > 0) {
                archivoPorProcesar = args [0];
                Console.WriteLine (archivoPorProcesar);
            }

            var appSettings = new AppSettings();

            var fechaRadicacionInicial = appSettings.Get<DateTime>("FechaRadicacionInicial", new DateTime(2015, 1, 7));
            var fechaRadicacionFinal = appSettings.Get<DateTime>("FechaRadicacionFinal", DateTime.Today);
            var urlBaseVivanto = appSettings.Get<string>("UrlBaseVivanto", "http://190.60.70.149:82");
            var varConexionBD = appSettings.Get<string>("ConexionBD", "APP_CONEXION_IRD");
            var varUsuarioVivanto = appSettings.Get<string>("UsuarioVivanto", "APP_USUARIO_VIVANTO");
            var varClaveVivanto = appSettings.Get<string>("ClaveVivanto", "APP_CLAVE_VIVANTO");

            var conexionBD = Environment.GetEnvironmentVariable(varConexionBD);
            var usuarioVivanto = Environment.GetEnvironmentVariable(varUsuarioVivanto);
            var claveVivanto = Environment.GetEnvironmentVariable(varClaveVivanto);

            Console.WriteLine(fechaRadicacionInicial);
            Console.WriteLine(fechaRadicacionFinal);
            Console.WriteLine(urlBaseVivanto);
            Console.WriteLine(varConexionBD);
            Console.WriteLine(varUsuarioVivanto);
            Console.WriteLine(varClaveVivanto);
            Console.WriteLine(conexionBD);
            Console.WriteLine(usuarioVivanto);
            Console.WriteLine(claveVivanto);

            var login = new LoginVivanto { Usuario = usuarioVivanto, Clave = claveVivanto };

            var par = new ParametrosServicio() { UrlBase = urlBaseVivanto };
            var parProcesamiento = new ParametrosProcesamiento()
            {
                FechaRadicacionInicial = fechaRadicacionInicial,
                FechaRadicacionFinal = fechaRadicacionFinal
            };

            using (IConexionVivanto cliente = new ConexionVivanto (par, login)) {

                var dbfactory = new OrmLiteConnectionFactory (conexionBD, SqlServerDialect.Provider);
                var dbcliente = new ConexionIRDCOL (dbfactory);
                cliente.IniciarSesion ();
                var proc = new Procesamiento (cliente, dbcliente, parProcesamiento);
                var np = proc.Iniciar (archivoPorProcesar);
                Console.WriteLine ("Listo primera fase");
                Console.WriteLine ("esperando 5 segundos para iniciar con los no procesados");
                System.Threading.Thread.Sleep (5 * 1000);
                Console.WriteLine ("Iniciando ahora con los no procesados...");
                //proc = new Procesamiento (cliente, dbcliente, parProcesamiento);
                proc.Iniciar (np);
                cliente.CerrarSession ();
            }

            return;
        }
            public override void Configure(Container container)
            {
                var appSettings = new AppSettings();

                Plugins.Add(new AuthFeature(() => new AuthUserSession(), new IAuthProvider[] {
                    new CustomCredentialsAuthProvider()
                }));
            }
예제 #9
0
 public ApiService(AzureClient azure, FsService fs, CertService certs, AppSettings settings, CustomBasicAuthProvider authProvider, LoggingService log)
 {
     _azure = azure.GetRoot();
     _fs = fs;
     _certs = certs;
     _settings = settings;
     _authProvider = authProvider;
     _log = log;
 }
예제 #10
0
			public override void Configure (Container container)
			{
				container.Register<ICacheClient> (new MemoryCacheClient ());
				var appSettings = new AppSettings ();
				Plugins.Add (new AuthFeature (() => new WrenchAuthUserSession (),
				                              new[] { new GoogleOpenIdOAuthProvider (appSettings) }));
				Plugins.Add (new ValidationFeature ());
				container.RegisterValidators (typeof (WrenchAppHost).Assembly);
				Routes.AddFromAssembly (typeof (WrenchAppHost).Assembly);
			}
예제 #11
0
파일: AppHost.cs 프로젝트: WimAtIHomer/Clio
        // Uncomment to enable ServiceStack Authentication and CustomUserSession
        private void ConfigureAuth(Funq.Container container)
        {
            var appSettings = new AppSettings();

            //Default route: /auth/{provider}
            Plugins.Add(new AuthFeature(() => new CustomUserSession(),
                new IAuthProvider[] {
                    new ClioAuthProvider(appSettings),
                }));
        }
예제 #12
0
        protected override void OnStart(string[] args)
        {
            eventLog.WriteEntry("Tracks Rest API host starting");

            var settings = new AppSettings();

            Host = new AppHost();
            Host.Init();
            Host.InitDb();
            Host.Start(settings.GetString("restBaseAddress"));
        }
        protected override void OnStart(string[] args)
        {
            appHost = new ToDoAppHost();
            appHost.Init();

            var appSettings = new AppSettings();
            var url = appSettings.GetString("Api.Url");
            Console.WriteLine("Listening: " + url);

            appHost.Start(url);
        }
예제 #14
0
        private void ConfigureAuth(Container container)
        {
            //Enable and register existing services you want this host to make use of.
            //Look in Web.config for examples on how to configure your oauth providers, e.g. oauth.facebook.AppId, etc.
            var appSettings = new AppSettings();

            //Register all Authentication methods you want to enable for this web app.            
            Plugins.Add(new AuthFeature(
                () => new CustomUserSession(), //Use your own typed Custom UserSession type
                new IAuthProvider[] {
                    new AspNetWindowsAuthProvider(this) {
                        LoadUserAuthFilter = LoadUserAuthInfo,
                        AllowAllWindowsAuthUsers = true
                    }, 
                    new CredentialsAuthProvider(),              //HTML Form post of UserName/Password credentials
                    new TwitterAuthProvider(appSettings),       //Sign-in with Twitter
                    new FacebookAuthProvider(appSettings),      //Sign-in with Facebook
                    new DigestAuthProvider(appSettings),        //Sign-in with Digest Auth
                    new BasicAuthProvider(),                    //Sign-in with Basic Auth
                    new GoogleOpenIdOAuthProvider(appSettings), //Sign-in with Google OpenId
                    new YahooOpenIdOAuthProvider(appSettings),  //Sign-in with Yahoo OpenId
                    new OpenIdOAuthProvider(appSettings),       //Sign-in with Custom OpenId
                    new GoogleOAuth2Provider(appSettings),      //Sign-in with Google OAuth2 Provider
                    new LinkedInOAuth2Provider(appSettings),    //Sign-in with LinkedIn OAuth2 Provider
                    new GithubAuthProvider(appSettings),        //Sign-in with GitHub OAuth Provider
                    new YandexAuthProvider(appSettings),        //Sign-in with Yandex OAuth Provider        
                    new VkAuthProvider(appSettings),            //Sign-in with VK.com OAuth Provider 
                    new OdnoklassnikiAuthProvider(appSettings), //Sign-in with Odnoklassniki OAuth Provider 
                }));

#if HTTP_LISTENER
            //Required for DotNetOpenAuth in HttpListener 
            OpenIdOAuthProvider.OpenIdApplicationStore = new InMemoryOpenIdApplicationStore();
#endif

            //Provide service for new users to register so they can login with supplied credentials.
            Plugins.Add(new RegistrationFeature());

            //override the default registration validation with your own custom implementation
            container.RegisterAs<CustomRegistrationValidator, IValidator<Register>>();

            //Store User Data into the referenced SqlServer database
            container.Register<IAuthRepository>(c =>
                new OrmLiteAuthRepository(c.Resolve<IDbConnectionFactory>())); //Use OrmLite DB Connection to persist the UserAuth and AuthProvider info

            var authRepo = (OrmLiteAuthRepository)container.Resolve<IAuthRepository>(); //If using and RDBMS to persist UserAuth, we must create required tables
            if (appSettings.Get("RecreateAuthTables", false))
                authRepo.DropAndReCreateTables(); //Drop and re-create all Auth and registration tables
            else
                authRepo.InitSchema();   //Create only the missing tables

            Plugins.Add(new RequestLogsFeature());
        }
예제 #15
0
 public AzureClient(AppSettings settings)
 {
     var account = settings.GetString("AzureAccount");
     if (account == "--SAMPLE--")
     {
         _root = AzureService.UseStorageEmulator();
     }
     else
     {
         var key = settings.GetString("AzureKey");
         _root = new AzureService(account, key);
     }
 }
        public override void Configure(Container container)
        {
            container.RegisterAutoWired<EmailProvider>();
            container.RegisterAutoWired<FacebookGateway>();
            container.RegisterAutoWired<TwitterGateway>();
            
            Plugins.Add(new RazorFormat());
            Plugins.Add(new RequestLogsFeature());

            var appSettings = new AppSettings();
            Plugins.Add(new AuthFeature(() => new CustomSession(), 
                new IAuthProvider[] {
                    new CredentialsAuthProvider(appSettings), 
                    new TwitterAuthProvider(appSettings),
                    new FacebookAuthProvider(appSettings), 
                }));

            container.Register<IRedisClientsManager>(new PooledRedisClientManager("localhost:6379"));
            container.Register(c => c.Resolve<IRedisClientsManager>().GetCacheClient());

            container.Register<IDbConnectionFactory>(
                new OrmLiteConnectionFactory("~/App_Data/db.sqlite".MapHostAbsolutePath(), 
                    SqliteDialect.Provider) {
                        ConnectionFilter = x => new ProfiledDbConnection(x, Profiler.Current)
                    });

            //Store User Data into above OrmLite database
            container.Register<IAuthRepository>(c => 
                new OrmLiteAuthRepository(c.Resolve<IDbConnectionFactory>()));

            //If using and RDBMS to persist UserAuth, we must create required tables
            var authRepo = container.Resolve<IAuthRepository>();
            authRepo.InitSchema();

            //Register MQ Service
            var mqService = new RedisMqServer(container.Resolve<IRedisClientsManager>());
            container.Register<IMessageService>(mqService);
            container.Register(mqService.MessageFactory);

            mqService.RegisterHandler<SMessage>(ServiceController.ExecuteMessage);
            mqService.RegisterHandler<CallFacebook>(ServiceController.ExecuteMessage);
            mqService.RegisterHandler<EmailMessage>(ServiceController.ExecuteMessage);
            mqService.RegisterHandler<PostStatusTwitter>(ServiceController.ExecuteMessage);

            mqService.Start();

            if (appSettings.Get("ResetAllOnStartUp", false))
            {
                ResetAll(container, (OrmLiteAuthRepository)authRepo);
            }
        }
예제 #17
0
        public override void Configure(Container container)
        {
            ////var dbConnectionFactory = new OrmLiteConnectionFactory(HttpContext.Current.Server.MapPath("~/App_Data/db.sql"), SqliteDialect.Provider);
            ////container.Register<IDbConnectionFactory>(dbConnectionFactory);

            IAppSettings appSettings = new AppSettings();

            Plugins.Add(new SwaggerFeature());
            //Plugins.Add(new RequestLogsFeature() { RequiredRoles = null });

            container.Register(appSettings);
            container.RegisterAutoWired<IISManager>();
            container.RegisterAutoWired<AppSettingsApiKeyValidator>();
        }
예제 #18
0
        public override void Configure(Container container)
        {
            var appSettings = new AppSettings();
            container.Register<IRedisClientsManager>(c => new PooledRedisClientManager(
                new string[] { appSettings.GetString("Redis.Host") ?? "localhost" }));
            container.Register<IMessageService>(c => new RedisMqServer(c.Resolve<IRedisClientsManager>()));
            container.Register<IMessageFactory>(c => c.Resolve<IMessageService>().MessageFactory);

            var mqServer = (RedisMqServer)container.Resolve<IMessageService>();
            mqServer.RegisterHandler<AnyTestMq>(ServiceController.ExecuteMessage);
            mqServer.RegisterHandler<PostTestMq>(ServiceController.ExecuteMessage);

            mqServer.Start();
        }
예제 #19
0
            private static IDbConnectionFactory GetDataFactory()
            {
                var appSettings = new AppSettings();

                var connStringName = appSettings.Get<string>("ConnectionString", null);
                if (connStringName == null)
                {
                    // TODO
                    return null;
                }

                var connString = ConfigurationManager.ConnectionStrings[connStringName];
                var provider = GetDialectProvider(connString.ProviderName);

                return new OrmLiteConnectionFactory(connString.ConnectionString, provider);
            }
        public void SetUp()
        {
			try
			{
                tests = new OAuthUserSessionTests();

                appHost = new BasicAppHost().Init();
                
                var inMemoryRepo = new InMemoryAuthRepository();
				inMemoryRepo.Clear();
				userAuthRepositorys.Add(inMemoryRepo);

                var appSettings = new AppSettings();
				var redisRepo = new RedisAuthRepository(new BasicRedisClientManager(new[] { appSettings.GetString("Redis.Host") ?? "localhost" }));
				redisRepo.Clear();
				userAuthRepositorys.Add(redisRepo);

				if (OAuthUserSessionTestsBase.UseSqlServer)
				{
					var connStr = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\App_Data\auth.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True";
					var sqlServerFactory = new OrmLiteConnectionFactory(connStr, SqlServerOrmLiteDialectProvider.Instance);
					var sqlServerRepo = new OrmLiteAuthRepository(sqlServerFactory);
					sqlServerRepo.DropAndReCreateTables();
				}
				else
				{
					var sqliteInMemoryRepo = new OrmLiteAuthRepository(dbFactory);

                    sqliteInMemoryRepo.InitSchema();
                    sqliteInMemoryRepo.Clear();
					userAuthRepositorys.Add(sqliteInMemoryRepo);

					var sqliteDbFactory = new OrmLiteConnectionFactory( 
						"~/App_Data/auth.sqlite".MapProjectPath()); 
                    var sqliteDbRepo = new OrmLiteAuthRepository(sqliteDbFactory);
                    sqliteDbRepo.InitSchema();
					userAuthRepositorys.Add(sqliteDbRepo);
				}
			}
			catch (Exception ex)
			{
				Console.WriteLine(ex.Message);
				throw;
			}
		}
        public override void Configure(Container container)
        {
            Plugins.Add(new ValidationFeature());
            container.RegisterValidators(typeof(ValidateTestMqValidator).Assembly);

            var appSettings = new AppSettings();
            container.Register<IRedisClientsManager>(c => new PooledRedisClientManager(
                new[] { appSettings.GetString("Redis.Host") ?? "localhost" }));
            container.Register<IMessageService>(c => new RedisMqServer(c.Resolve<IRedisClientsManager>()));

            var mqServer = (RedisMqServer)container.Resolve<IMessageService>();
            mqServer.RegisterHandler<AnyTestMq>(ServiceController.ExecuteMessage);
            mqServer.RegisterHandler<PostTestMq>(ServiceController.ExecuteMessage);
            mqServer.RegisterHandler<ValidateTestMq>(ServiceController.ExecuteMessage);
            mqServer.RegisterHandler<ThrowGenericError>(ServiceController.ExecuteMessage);

            mqServer.Start();
        }
        public override void Configure(Container container)
        {
            var appSettings = new AppSettings();

            //Default route: /auth/{provider}
            Plugins.Add(new AuthFeature(() => new CustomUserSession(), new IAuthProvider[] { new BasicAuthProvider(appSettings) }));

            //Default route: /register
            Plugins.Add(new RegistrationFeature());

            var dbConnectionFactory = new OrmLiteConnectionFactory(ConfigurationManager.ConnectionStrings["AuthDB"].ConnectionString, SqlServerDialect.Provider);
            container.Register<IDbConnectionFactory>(dbConnectionFactory);

            //Store User Data into the referenced SqlServer database
            container.Register<IUserAuthRepository>(c => new OrmLiteAuthRepository(c.Resolve<IDbConnectionFactory>()));

            Plugins.Add(new CorsFeature());
        }
        public override void Configure(Container container)
        {
            Plugins.Add(new ValidationFeature());
            container.RegisterValidators(typeof(ValidateTestMqValidator).Assembly);

            var appSettings = new AppSettings();
            container.Register<IMessageService>(c =>
                new RabbitMqServer(appSettings.GetString("RabbitMq.Host") ?? "localhost"));
            container.Register(c =>
                ((RabbitMqServer) c.Resolve<IMessageService>()).ConnectionFactory);

            var mqServer = (RabbitMqServer)container.Resolve<IMessageService>();
            mqServer.RegisterHandler<AnyTestMq>(ServiceController.ExecuteMessage);
            mqServer.RegisterHandler<PostTestMq>(ServiceController.ExecuteMessage);
            mqServer.RegisterHandler<ValidateTestMq>(ServiceController.ExecuteMessage);
            mqServer.RegisterHandler<ThrowGenericError>(ServiceController.ExecuteMessage);

            mqServer.Start();
        }
예제 #24
0
        public override void Configure(Container container)
        {
            var appSettings = new AppSettings();

            var clientsManager = new RedisManagerPool(appSettings.Get("RedisConnectionString", "redis://localhost:6379"));
            container.Register<IRedisClientsManager>(c => clientsManager);

            container.Register<IPasswordGenerator>(
                new RngPasswordGenerator()
                {
                    PasswordLength = appSettings.Exists("PasswordLength") ? appSettings.Get<uint>("PasswordLength") : 16
                });

            container.Register<IOneTimePasswordRepository>(c => new RedisOneTimePasswordRepository()
            {
                ClientsManager = clientsManager,
                PasswordExpiryInSeconds = appSettings.Get<uint>("PasswordExpiryInSeconds", 30)
            });
        }
예제 #25
0
        public static void Start(IAppHost appHost, Container container)
        {
            var appSettings = new AppSettings();

            //Default route: /auth/{provider}
            appHost.Plugins.Add(new AuthFeature(() => new AuthUserSession(),
                new IAuthProvider[] {
                    new BasicAuthProvider(appSettings),
                    new CredentialsAuthProvider(appSettings)
                }) { IncludeAssignRoleServices = false, HtmlRedirect = null });

            appHost.Plugins.Add(new RegistrationFeature());

            container.Register<ICacheClient>(new MemoryCacheClient());

            container.Register<IUserAuthRepository>(c =>
            {
                var documentStore = c.Resolve<IDocumentStore>();
                return new RavenUserAuthRepository(documentStore);
            });
        }
예제 #26
0
        public void SendSmtpEmail(EmailServiceModels model)
        {
            var appSetting = new AppSettings();
            MailMessage mail = new MailMessage();

            mail.Body = model.Body;
            mail.IsBodyHtml = model.IsBodyHtml;
            mail.Priority = MailPriority.High;
            mail.Subject = model.Subject;

            foreach (var item in model.Attachments)
            {
                mail.Attachments.Add(new Attachment(item));
            }

            foreach (var to in model.To)
            {
                mail.To.Add(to);
            }

            new SmtpClient().SendAsync(mail, new Guid().ToString());
        }
            public override void Configure(Container container)
            {
                Func<string, string> localize = s => HostContext.AppHost.ResolveLocalizedString(s, null);
                Plugins.Add(new SessionFeature());
                SetConfig(new HostConfig(){AllowSessionIdsInHttpParams = true});

                var appSettings = new AppSettings();

                var authFeature = new AuthFeature(() => new AuthUserSession(), new IAuthProvider[] { new CredentialsAuthProvider{ SkipPasswordVerificationForInProcessRequests = true }, new FacebookAuthProvider(appSettings) }) { HtmlRedirect = null };
                authFeature.IncludeAssignRoleServices = false;

                Plugins.Add(new ServerEventsFeature()
                {
                    LimitToAuthenticatedUsers = true,
                    NotifyChannelOfSubscriptions = false,
                });
                Plugins.Add(new RegistrationFeature());
                Plugins.Add(authFeature);
                var authRepo = new InMemoryAuthRepository();
                container.Register<IUserAuthRepository>(authRepo);
                authRepo.CreateUserAuth(new UserAuth() { UserName = "******" }, "testpassword");
            }
        public void Ready()
        {
            //Invoke on DOM ready
            var appSettings = new AppSettings();
            var checkForUpdates = appSettings.Get<bool>("EnableAutoUpdate");
            if (!checkForUpdates)
                return;

            var releaseFolderUrl = appSettings.GetString("UpdateManagerUrl");
            try
            {
                var updatesAvailableTask = AppUpdater.CheckForUpdates(releaseFolderUrl);
                updatesAvailableTask.ContinueWith(isAvailable =>
                {
                    isAvailable.Wait(TimeSpan.FromMinutes(1));
                    bool updatesAvailable = isAvailable.Result;
                    //Only check once one launch then release UpdateManager.
                    if (!updatesAvailable)
                    {
                        AppUpdater.Dispose();
                        return;
                    }
                    if (formMain == null)
                    {
                        return;
                    }
                    // Notify web client updates are available.
                    formMain.InvokeOnUiThreadIfRequired(() =>
                    {
                        formMain.ChromiumBrowser.GetMainFrame().ExecuteJavaScriptAsync("window.updateAvailable();");
                    });
                });
            }
            catch (Exception e)
            {
                // Error reaching update server
            }
        }
예제 #29
0
        public void Configure(IAppHost appHost)
        {
            var appSettings = new ServiceStack.Configuration.AppSettings();

            if (appHost.Plugins.Exists(p => p is AuthFeature))
            {
                appHost.Plugins.Remove(appHost.Plugins.First(p => p is AuthFeature));
            }

            string oauthLogin = appSettings.GetString("oauth.login");

            if (oauthLogin == null)
            {
                oauthLogin = "******";
            }


            appHost.Plugins.Add(new AuthFeature(() => new AuthUserSession(), new IAuthProvider[] {
                //  new MyJwtAuthProvider(appSettings) { },
                new MyOAuth2Provider(appSettings)
                //  new MyOAuth2Provider(appSettings) { Provider = "GoogleOAuthApp", ConsumerKey = appSettings.Get("oauth.GoogleOAuthApp.ConsumerKey")}
            }, oauthLogin));
        }
예제 #30
0
        public override void Configure(Funq.Container container)
        {
            container.Adapter = new StructureMapContainerAdapter();

            var appSettings = new AppSettings();

            Plugins.Add(new AuthFeature(
            () => new AuthUserSession(), //Use your own typed Custom UserSession type
            new IAuthProvider[] {
                    new GoogleOpenIdOAuthProvider(appSettings), //Sign-in with Google OpenId
                    new YahooOpenIdOAuthProvider(appSettings), //Sign-in with Yahoo OpenId
                    new OpenIdOAuthProvider(appSettings), //Sign-in with Custom OpenId
                    new GoogleOAuth2Provider(appSettings), //Sign-in with Google OAuth2 Provider
                    new LinkedInOAuth2Provider(appSettings), //Sign-in with LinkedIn OAuth2 Provider
                }));

            Routes
                .Add<AddUserItemRequest>("/user/{OwnerId}/items/add/", "GET,POST")
                .Add<AddOrganisationItemRequest>("/org/{OwnerId}/items/add/")
                .Add<ConnectRequest>("/connection/add/{FromUserId}/{ToUserId}/")
                .Add<BorrowItemRequest>("/borrow/{OwnershipId}/{RequestorId}/")
                ;
        }
예제 #31
0
파일: AuthConfig.cs 프로젝트: xmkevin/ym
        public static void ConfigureAuth(List<IPlugin> Plugins, Funq.Container container)
        {
            //Enable and register existing services you want this host to make use of.
            //Look in Web.config for examples on how to configure your oauth proviers, e.g. oauth.facebook.AppId, etc.
            var appSettings = new AppSettings();

            //Register all Authentication methods you want to enable for this web app.
            Plugins.Add(new AuthFeature(
                () => new AuthUserSession(), //Use your own typed Custom UserSession type
                new IAuthProvider[] {
                    new CredentialsAuthProvider()
                }));

            //Provide service for new users to register so they can login with supplied credentials.
            Plugins.Add(new RegistrationFeature());

            //Create a DB Factory configured to access the UserAuth SQL Server DB
            var connStr = appSettings.Get("MYSQL_CONNECTION_STRING", //AppHarbor or Local connection string
                ConfigUtils.GetConnectionString("UserAuth"));
            container.Register<IDbConnectionFactory>(
                new OrmLiteConnectionFactory(connStr, //ConnectionString in Web.Config
                    ServiceStack.OrmLite.MySql.MySqlDialectProvider.Instance)
                {
                    ConnectionFilter = x => new ProfiledDbConnection(x, Profiler.Current)
                });

            //Store User Data into the referenced SqlServer database
            container.Register<IUserAuthRepository>(c =>
                new OrmLiteAuthRepository(c.Resolve<IDbConnectionFactory>())); //Use OrmLite DB Connection to persist the UserAuth and AuthProvider info

            var authRepo = (OrmLiteAuthRepository)container.Resolve<IUserAuthRepository>(); //If using and RDBMS to persist UserAuth, we must create required tables
            if (appSettings.Get("RecreateAuthTables", false))
                authRepo.DropAndReCreateTables(); //Drop and re-create all Auth and registration tables
            else
                authRepo.CreateMissingTables();   //Create only the missing tables
        }