Exemple #1
0
        private void ConfigureGoogleOAuth(OpenIdConnectOptions oidcOptions)
        {
            var callbackPathOption = "/signin-oidc-google";
            var gcfg = new GoogleConfig();

            Configuration.Bind(nameof(GoogleConfig), gcfg);
            oidcOptions.ClientId     = gcfg.ClientId;
            oidcOptions.ClientSecret = gcfg.ClientSecret;
            oidcOptions.Authority    = "https://accounts.google.com";
            oidcOptions.CallbackPath = callbackPathOption;
            oidcOptions.Scope.Add("https://www.googleapis.com/auth/userinfo.email");
            oidcOptions.Scope.Add("https://www.googleapis.com/auth/userinfo.profile");
            oidcOptions.ResponseType = OpenIdConnectResponseType.CodeIdToken;
            oidcOptions.GetClaimsFromUserInfoEndpoint = true;
            oidcOptions.SaveTokens = true;
            oidcOptions.ClaimActions.Add(new GoogleClaimsProcessor(AppClaimTypes.GoogleImageUrl));
            oidcOptions.Events = new OpenIdConnectEvents
            {
                OnUserInformationReceived = UserInformationReceived
            };
            oidcOptions.TokenValidationParameters = new TokenValidationParameters
            {
                ValidateAudience         = true,
                ValidateIssuer           = true,
                ValidateLifetime         = true,
                ValidateIssuerSigningKey = true
            };
            if (!string.IsNullOrWhiteSpace(AppPathPrefix))
            {
                var callbackPath = $"{AppPathPrefix}{oidcOptions.CallbackPath}";
                logger.LogDebug($"Setting google callback path: {callbackPath}");
                oidcOptions.CallbackPath = callbackPath;
            }
        }
        public GoogleConfig GetGoogleConfig()
        {
            var appConfig = new GoogleConfig();

            _config.GetSection("Google").Bind(appConfig);
            return(appConfig);
        }
Exemple #3
0
 public async void addGoogle(string unparsedConfig)
 {
     var          options      = JsonHelper.Deserialize <string[]>(unparsedConfig)[0];
     var          config       = JsonHelper.Deserialize <Config>(options);
     GoogleConfig googleConfig = GoogleConfig.Create(config.clientId, config.scopes, config.accountId);
     await AccountManager.AddAccount(googleConfig);
 }
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            if (file == null)
            {
                var openPicker = new FileOpenPicker
                {
                    SuggestedStartLocation = PickerLocationId.PicturesLibrary,
                    ViewMode = PickerViewMode.Thumbnail
                };
                openPicker.FileTypeFilter.Add(".jpg");
                openPicker.PickSingleFileAndContinue();
                button.Content = "Upload";
            }
            else
            {
                var config = await GoogleConfig.Create(
                    "517285908032-12332132132131321312.apps.googleusercontent.com",
                    new List <string>(new string[] { "https://www.googleapis.com/auth/drive" }),
                    "google"
                    );

                //var config = await KeycloakConfig.Create("shoot-third-party", "https://localhost:8443", "shoot-realm");
                //var config = FacebookConfig.Create("1654557457742519", "9cab3cb953d3194908f44f1764b5b921",
                //    new List<string>(new string[] { "photo_upload, publish_actions" }), "facebook");

                var module = await AccountManager.AddAccount(config);

                if (await module.RequestAccessAndContinue())
                {
                    Upload(module);
                }
            }
        }
Exemple #5
0
        public GoogleTextToSpeechSynthesizer(string inputFile, string outDirectory, string prepend, Action <string> logAction) : base(inputFile, outDirectory, prepend, logAction, 1000)
        {
            var cred = GoogleCredential.FromFile(Path.Combine(AppContext.BaseDirectory, "googleCreds.json")).ToChannelCredentials();

            Client = new TextToSpeechClientBuilder {
                ChannelCredentials = cred
            }.Build();
            GoogleConfig = ConfigReader.ReadSettings <GoogleConfig>();
        }
Exemple #6
0
        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.
        /// This parameter is typically used to configure the page.</param>
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            // TODO: Prepare page for display here.

            // TODO: If your application contains multiple pages, ensure that you are
            // handling the hardware Back button by registering for the
            // Windows.Phone.UI.Input.HardwareButtons.BackPressed event.
            // If you are using the NavigationHelper provided by some templates,
            // this event is handled for you.

            captureMgr = new MediaCapture();
            await captureMgr.InitializeAsync();

            capturePreview.Source = captureMgr;
            await captureMgr.StartPreviewAsync();

            IsPreviewing   = true;
            uploadLocation = new Dictionary <string, Uri>();

            DisplayInformation displayInfo = DisplayInformation.GetForCurrentView();

            displayInfo.OrientationChanged += DisplayInfo_OrientationChanged;
            DisplayInfo_OrientationChanged(displayInfo, null);

            var config = await GoogleConfig.Create(
                "517285908032-11moj33qbn01m7sem6g7gmfco2tp252v.apps.googleusercontent.com",
                new List <string>(new string[] { "https://www.googleapis.com/auth/drive" }),
                "google"
                );

            uploadLocation.Add("google", new Uri("https://www.googleapis.com/upload/drive/v2/files"));
            await AccountManager.AddAccount(config);

            var keyCloak = await KeycloakConfig.Create("shoot-third-party", "https://localhost:8443", "shoot-realm");

            uploadLocation.Add("shoot-third-party", new Uri("https://localhost:8443/shoot/rest/photos"));
            await AccountManager.AddKeyCloak(keyCloak);

            var facebook = FacebookConfig.Create("YYY", "XXX",
                                                 new List <string>(new string[] { "photo_upload, publish_actions" }), "facebook");

            uploadLocation.Add("facebook", new Uri("https://graph.facebook.com/me/photos"));
            await AccountManager.AddFacebook(facebook);
        }
Exemple #7
0
        private void ConfigureIdentityServer(IServiceCollection services)
        {
            var builder = services.AddIdentityServer(options =>
            {
                options.Events.RaiseErrorEvents       = true;
                options.Events.RaiseInformationEvents = true;
                options.Events.RaiseFailureEvents     = true;
                options.Events.RaiseSuccessEvents     = true;
            })
                          .AddAspNetIdentity <ApplicationUser>();

            if (Environment.IsDevelopment())
            {
                builder.AddDeveloperSigningCredential();
            }
            else
            {
                throw new Exception("need to configure key material");
            }

            // configure identity server with in-memory stores, keys, clients and scopes
            builder
            //.AddTestUsers(Config.GetUsers())
            // this adds the config data from DB (clients, resources)
            .AddConfigurationStore(options =>
            {
                options.ConfigureDbContext = ConfigureDbContextAction(MigrationsAssembly);
            })
            // this adds the operational data from DB (codes, tokens, consents)
            .AddOperationalStore(options =>
            {
                options.ConfigureDbContext = ConfigureDbContextAction(MigrationsAssembly);

                // this enables automatic token cleanup. this is optional.
                options.EnableTokenCleanup = true;
            });

            var gcfg = new GoogleConfig();

            Configuration.Bind(nameof(GoogleConfig), gcfg);

            services.AddAuthentication()
            .AddGoogleOpenIdConnect(ConfigureGoogleOAuth);
        }
Exemple #8
0
        private void ConfigureGoogleOAuth(OpenIdConnectOptions oidcOptions)
        {
            var gcfg = new GoogleConfig();

            Configuration.Bind(nameof(GoogleConfig), gcfg);

            oidcOptions.SignInScheme  = IdentityServerConstants.ExternalCookieAuthenticationScheme;
            oidcOptions.SignOutScheme = IdentityServerConstants.SignoutScheme;

            oidcOptions.ClientId     = gcfg.ClientId;
            oidcOptions.ClientSecret = gcfg.ClientSecret;
            oidcOptions.ResponseType = OpenIdConnectResponseType.CodeIdToken;
            oidcOptions.GetClaimsFromUserInfoEndpoint = true;
            oidcOptions.SaveTokens = true;
            //oidcOptions.ClaimActions.Add (new GoogleClaimsProcessor (AppClaimTypes.GoogleImageUrl));
            //oidcOptions.Events = new OpenIdConnectEvents {
            //    OnUserInformationReceived = UserInformationReceived
            //};
            oidcOptions.TokenValidationParameters = new TokenValidationParameters
            {
                ValidateAudience         = true,
                ValidateIssuer           = true,
                ValidateLifetime         = true,
                ValidateIssuerSigningKey = true
            };

            /*if(!string.IsNullOrWhiteSpace(AppPathPrefix))
             * {
             *  var callbackPath = $"{AppPathPrefix}{oidcOptions.CallbackPath}";
             *  logger.LogDebug($"Setting google callback path: {callbackPath}");
             *  oidcOptions.CallbackPath = callbackPath;
             * }*/

            oidcOptions.Events.OnRedirectToIdentityProviderForSignOut = (ctx) =>
            {
                var c = ctx;
                return(Task.CompletedTask);
            };
        }
 public GoogleSearchEngineRepository(IOptions <GoogleConfig> googleConfig)
 {
     _googleConfig = googleConfig.Value;
 }
Exemple #10
0
 public HomeController(ILogger <HomeController> logger,
                       IOptions <GoogleConfig> options)
 {
     this.logger        = logger;
     this.googleOptions = options?.Value ?? throw new ArgumentNullException("googleOptions");
 }
Exemple #11
0
 public GoogleHelper(GoogleConfig google)
 {
     _google = google ?? throw new ConfigurationException(@"The Google Workspace configuration has not been added.");
 }