Ejemplo n.º 1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IAuthenticationDelegate @delegate)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseHttpsRedirection();

            app.UseRouting();

            app.UseSwagger();
            // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
            // specifying the Swagger JSON endpoint.
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
                c.RoutePrefix = "";
            });

            app.UseLyciumAuthentication(@delegate);

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CloseAccountJob"/> class.
        /// </summary>
        /// <param name="configuration">The configuration to use.</param>
        /// <param name="logger">The logger to use.</param>
        /// <param name="profileDelegate">The profile delegate.</param>
        /// <param name="emailService">The email service.</param>
        /// <param name="authDelegate">The OAuth2 authentication service.</param>
        /// <param name="userAdminDelegate">The AccessManagement userAdmin delegate.</param>
        /// <param name="dbContext">The db context to use.</param>
        public CloseAccountJob(
            IConfiguration configuration,
            ILogger <CloseAccountJob> logger,
            IUserProfileDelegate profileDelegate,
            IEmailQueueService emailService,
            IAuthenticationDelegate authDelegate,
            IUserAdminDelegate userAdminDelegate,
            GatewayDbContext dbContext)
        {
            this.configuration       = configuration;
            this.logger              = logger;
            this.profileDelegate     = profileDelegate;
            this.emailService        = emailService;
            this.authDelegate        = authDelegate;
            this.userAdminDelegate   = userAdminDelegate;
            this.dbContext           = dbContext;
            this.profilesPageSize    = this.configuration.GetValue <int>($"{JobKey}:{ProfilesPageSizeKey}");
            this.hoursBeforeDeletion = this.configuration.GetValue <int>($"{JobKey}:{HoursDeletionKey}") * -1;
            this.emailTemplate       = this.configuration.GetValue <string>($"{JobKey}:{EmailTemplateKey}");

            IConfigurationSection?configSection = configuration?.GetSection(AuthConfigSectionName);

            this.tokenUri = configSection.GetValue <Uri>(@"AuthTokenUri");

            this.tokenRequest = new ClientCredentialsTokenRequest();
            configSection.Bind(this.tokenRequest);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NotificationSettingsJob"/> class.
 /// </summary>
 /// <param name="configuration">The configuration to use.</param>
 /// <param name="logger">The logger to use.</param>
 /// <param name="notificationSettingsDelegate">The email delegate to use.</param>
 /// <param name="authDelegate">The OAuth2 authentication service.</param>
 public NotificationSettingsJob(IConfiguration configuration, ILogger <NotificationSettingsJob> logger, INotificationSettingsDelegate notificationSettingsDelegate, IAuthenticationDelegate authDelegate)
 {
     this.configuration = configuration !;
     this.logger        = logger;
     this.notificationSettingsDelegate = notificationSettingsDelegate;
     this.authDelegate = authDelegate;
     this.jobEnabled   = this.configuration.GetSection(JobConfigKey).GetValue <bool>(JobEnabledKey, true);
 }
        public FacebookAuthenticator(string clientId, string scope, IAuthenticationDelegate authenticationDelegate)
        {
            _authenticationDelegate = authenticationDelegate;
            //GetUserName = async ( accountProperties) => { return await accountProperties.Keys.ToString() };

            _auth = new OAuth2Authenticator(clientId, scope,
                                            new Uri(AuthorizeUrl),
                                            new Uri(RedirectUrl),
                                            null, //GetUserName,
                                            IsUsingNativeUI);

            _auth.Completed += OnAuthenticationCompleted;
            _auth.Error     += OnAuthenticationFailed;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SalesforeceDelegate"/> class.
        /// </summary>
        /// <param name="logger">Injected Logger Provider.</param>
        /// <param name="httpClientService">The injected http client service.</param>
        /// <param name="configuration">The injected configuration provider.</param>
        /// <param name="authDelegate">The delegate responsible authentication.</param>
        public SalesforeceDelegate(
            ILogger <SalesforeceDelegate> logger,
            IHttpClientService httpClientService,
            IConfiguration configuration,
            IAuthenticationDelegate authDelegate)
        {
            this.logger            = logger;
            this.httpClientService = httpClientService;
            this.configuration     = configuration;
            this.authDelegate      = authDelegate;

            this.salesforceConfig = new Models.Salesforce.Config();
            this.configuration.Bind(SalesforceConfigSectionKey, this.salesforceConfig);
        }
Ejemplo n.º 6
0
 public FacebookAuthenticator(string i_ClientId,
                              string i_Scope,
                              IAuthenticationDelegate i_AuthenticationDelegate)
 {
     m_OAuth2Authenticator = new OAuth2Authenticator(
         i_ClientId,
         i_Scope,
         new Uri(FacebookAuth),
         new Uri(Configuration.FacebookRedirectUrl),
         null,
         IsUsingNativeUI);
     m_AuthenticationDelegate         = i_AuthenticationDelegate;
     m_OAuth2Authenticator.Completed += OnAuthenticationCompleted;
     m_OAuth2Authenticator.Error     += OnAuthenticationFailed;
 }
Ejemplo n.º 7
0
 public GoogleAuthenticator(string i_ClientId,
                            string i_Scope,
                            IAuthenticationDelegate i_AuthenticationDelegate)
 {
     m_OAuth2Authenticator = new OAuth2Authenticator(
         i_ClientId,
         string.Empty,
         i_Scope,
         new Uri(GoogleAuth),
         new Uri(Configuration.GoogleRedirectUrl),
         new Uri(GoogleAccessTokenUrl),
         null,
         IsUsingNativeUI);
     m_AuthenticationDelegate         = i_AuthenticationDelegate;
     m_OAuth2Authenticator.Completed += OnAuthenticationCompleted;
     m_OAuth2Authenticator.Error     += OnAuthenticationFailed;
 }
        public GoogleAuthenticator(string clientId, string scope, IAuthenticationDelegate authenticationDelegate)
        {
            _authenticationDelegate = authenticationDelegate;

            //_auth = new OAuth2Authenticator(clientId, string.Empty, scope,
            //                                new Uri(AuthorizeUrl),
            //                                new Uri(RedirectUrl),
            //                                new Uri(AccessTokenUrl),
            //                                null, IsUsingNativeUI);
            _auth = new OAuth2Authenticator(clientId, scope,
                                            new Uri(AuthorizeUrl),
                                            new Uri(RedirectUrl),
                                            null, //GetUserName,
                                            IsUsingNativeUI);

            _auth.Completed += OnAuthenticationCompleted;
            _auth.Error     += OnAuthenticationFailed;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="NotificationSettingsJob"/> class.
        /// </summary>
        /// <param name="configuration">The configuration to use.</param>
        /// <param name="logger">The logger to use.</param>
        /// <param name="notificationSettingsDelegate">The email delegate to use.</param>
        /// <param name="authDelegate">The OAuth2 authentication service.</param>
        /// <param name="eventLogDelegate">The Eventlog delegate.</param>
        public NotificationSettingsJob(
            IConfiguration configuration,
            ILogger <NotificationSettingsJob> logger,
            INotificationSettingsDelegate notificationSettingsDelegate,
            IAuthenticationDelegate authDelegate,
            IEventLogDelegate eventLogDelegate)
        {
            this.configuration = configuration !;
            this.logger        = logger;
            this.notificationSettingsDelegate = notificationSettingsDelegate;
            this.authDelegate     = authDelegate;
            this.eventLogDelegate = eventLogDelegate;
            this.jobEnabled       = this.configuration.GetSection(JobConfigKey).GetValue <bool>(JobEnabledKey, true);

            IConfigurationSection?configSection = configuration?.GetSection(AuthConfigSectionName);

            this.tokenUri = configSection.GetValue <Uri>(@"TokenUri");

            this.tokenRequest = new ClientCredentialsTokenRequest();
            configSection.Bind(this.tokenRequest); // Client ID, Client Secret, Audience, Username, Password
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CloseAccountJob"/> class.
 /// </summary>
 /// <param name="configuration">The configuration to use.</param>
 /// <param name="logger">The logger to use.</param>
 /// <param name="profileDelegate">The profile delegate.</param>
 /// <param name="emailService">The email service.</param>
 /// <param name="authDelegate">The OAuth2 authentication service.</param>
 /// <param name="userAdminDelegate">The AccessManagement userAdmin delegate.</param>
 /// <param name="dbContext">The db context to use.</param>
 public CloseAccountJob(
     IConfiguration configuration,
     ILogger <CloseAccountJob> logger,
     IUserProfileDelegate profileDelegate,
     IEmailQueueService emailService,
     IAuthenticationDelegate authDelegate,
     IUserAdminDelegate userAdminDelegate,
     GatewayDbContext dbContext)
 {
     this.configuration     = configuration;
     this.logger            = logger;
     this.profileDelegate   = profileDelegate;
     this.emailService      = emailService;
     this.authDelegate      = authDelegate;
     this.userAdminDelegate = userAdminDelegate;
     this.dbContext         = dbContext;
     this.profilesPageSize  = this.configuration.GetValue <int>($"{JobKey}:{ProfilesPageSizeKey}");
     this.host = this.configuration.GetValue <string>($"{HostKey}");
     this.hoursBeforeDeletion = this.configuration.GetValue <int>($"{JobKey}:{HoursDeletionKey}") * -1;
     this.emailTemplate       = this.configuration.GetValue <string>($"{JobKey}:{EmailTemplateKey}");
 }
Ejemplo n.º 11
0
 public void AuthenticateGoogle(IAuthenticationDelegate _delegate)
 {
     authDelegate = _delegate;
     platformGoogleAuth.AuthenticateGoogle(googleAuth);
 }
Ejemplo n.º 12
0
 public static OAuth2Authenticator GetGoogle2Authenticator(IAuthenticationDelegate i_AuthenticationDelegate)
 {
     s_GoogleAuthenticator = new GoogleAuthenticator(Keys.GoogleClientId, Configuration.GoogleAuthScope, i_AuthenticationDelegate);
     s_AuthType            = MobileServiceAuthenticationProvider.Google;
     return(s_GoogleAuthenticator.GetOAuth2());
 }
Ejemplo n.º 13
0
 public static OAuth2Authenticator GetFacebook2Authenticator(IAuthenticationDelegate i_AuthenticationDelegate)
 {
     s_FacebookAuthenticator = new FacebookAuthenticator(Keys.FacebookAppId, Configuration.FacebookAuthScope, i_AuthenticationDelegate);
     s_AuthType = MobileServiceAuthenticationProvider.Facebook;
     return(s_FacebookAuthenticator.GetOAuth2());
 }
 public static async void UseLyciumAuthentication(this IApplicationBuilder app, IAuthenticationDelegate @delegate)
 {
     ClientConfiguration.SetAppBuilderCache(app);
     app.Use(@delegate.PipelineDelegate);
     while (ClientConfiguration.GetDataSources() == null || ClientConfiguration.GetDataSources().Count == 0)
     {
         await Task.Delay(2000);
     }
     //添加本地白名单
     LyciumScanHelper.AddLyciumRoute();
     @delegate.StartSync();
 }