コード例 #1
0
ファイル: Startup.cs プロジェクト: ychebotarev/InColUn_V0_1
        public void ConfigureServices(IServiceCollection services)
        {
            var connectionString = Configuration["connection_string:mssql"];

            var authService = new OAuthService(new OAuthServiceOptions());

            //TODO initialize logger

            var msDBContext = new MSSqlDbContext(connectionString);
            var flakeIdGenerator = new FlakeGen.Id64Generator();

            this.AddFacebookOAuthStrategy(authService);
            this.AddGoogleOAuthStrategy(authService);

            var userRepository = new UserRepository(msDBContext);
            var boardsRepository = new BoardsRepository(msDBContext);
            var userBoardsRepository = new UserBoardRepository(msDBContext, boardsRepository);

            services.AddSingleton(authService);
            services.AddSingleton(flakeIdGenerator);
            services.AddSingleton<IDbContext>(msDBContext);
            services.AddSingleton<IUserRepository>(userRepository);
            services.AddSingleton<IBoardsRepository>(boardsRepository);
            services.AddSingleton<IUserBoardRepository>(userBoardsRepository);

            this.ConfigureToken(services);

            services.AddMvc();
        }
コード例 #2
0
ファイル: Startup.cs プロジェクト: ychebotarev/InColUn_V0_1
        private void AddFacebookOAuthStrategy(OAuthService authService)
        {
            var fbOptions = FacebookStrategyOptions.CreateDefault();
            fbOptions.ClientId = Configuration["facebook:appid"];
            fbOptions.ClientSecret = Configuration["facebook:appsecret"];
            fbOptions.CallbackPath = "auth/facebook/callback";

            var fbStrategy = new FacebookOAuthStrategy(fbOptions);

            authService.AddStrategy(fbStrategy);
        }
コード例 #3
0
ファイル: Startup.cs プロジェクト: ychebotarev/InColUn_V0_1
        private void AddGoogleOAuthStrategy(OAuthService authService)
        {
            var gOptions = GoogleStrategyOptions.CreateDefault();
            gOptions.ClientId = Configuration["google:clientid"];
            gOptions.ClientSecret = Configuration["google:clientsecret"];
            gOptions.CallbackPath = "auth/google/callback";

            var gStrategy = new GoogleOAuthStrategy(gOptions);

            authService.AddStrategy(gStrategy);
        }