private static async Task SignIn()
        {
            // create a redirect URI using an available port on the loopback address.
            // requires the OP to allow random ports on 127.0.0.1 - otherwise set a static port

            var    browser     = new SystemBrowser(45656);
            string redirectUri = string.Format($"http://127.0.0.1:{browser.Port}");

            var options = new OidcClientOptions
            {
                Authority    = _authority,
                ClientId     = "native.code",
                RedirectUri  = redirectUri,
                Scope        = "openid profile offline_access native_api",
                FilterClaims = false,
                Browser      = browser,
                Flow         = OidcClientOptions.AuthenticationFlow.AuthorizationCode,
                ResponseMode = OidcClientOptions.AuthorizeResponseMode.Redirect
            };

            var serilog = new LoggerConfiguration()
                          .MinimumLevel.Error()
                          .Enrich.FromLogContext()
                          .WriteTo.LiterateConsole(outputTemplate: "[{Timestamp:HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message}{NewLine}{Exception}{NewLine}")
                          .CreateLogger();

            options.LoggerFactory.AddSerilog(serilog);

            _oidcClient = new OidcClient(options);
            var result = await _oidcClient.LoginAsync();

            ShowResult(result);
            await NextSteps(result);
        }
	//private string editableText = "Начальный текст";

	// Use this for initialization
	void Start () 
	{
		stop.transform.gameObject.SetActive (false);

		SetInitialGUIState ();

		//get target browsing object
		target = GameObject.FindGameObjectWithTag ("Browser");
		if (target == null)
			return;

		//get components
		list = target.GetComponent<SubsystemList> ();
		browser = target.GetComponent<SystemBrowser> ();
		if (list == null || browser == null)
			return;

		//get visualizations
		Visualizations = target.GetComponentsInChildren<VisClass>();

		textSystemName.text = list.systemName;
		if (list.list.Count > 0)
			menu.interactable = true;

		AddDropDownButtonsAssociatedWithSubsystems ();
	}
Exemplo n.º 3
0
        /// <summary>
        ///     Invoked when the application is launched through a custom URI scheme, such as
        ///     is the case in an OAuth 2.0 authorization flow.
        /// </summary>
        /// <param name="args">Details about the URI that activated the app.</param>
        protected override void OnActivated(IActivatedEventArgs args)
        {
            // When the app was activated by a Protocol (custom URI scheme), forwards
            // the URI to the SystemBrowser through a static method.
            if (args.Kind == ActivationKind.Protocol)
            {
                // Extracts the authorization response URI from the arguments.
                var protocolArgs = (ProtocolActivatedEventArgs)args;
                var uri          = protocolArgs.Uri;
                Debug.WriteLine("Authorization Response: " + uri.AbsoluteUri);
                SystemBrowser.ProcessResponse(uri);
            }
            //自启动
            Frame rootFrame = Window.Current.Content as Frame;

            if (rootFrame == null)
            {
                rootFrame = new Frame();
                Window.Current.Content = rootFrame;
            }

            if (args.Kind == ActivationKind.StartupTask)
            {
                var startupArgs = args as StartupTaskActivatedEventArgs;
            }

            rootFrame.Navigate(typeof(MainPage), args.Kind);
            Window.Current.Activate();
        }
Exemplo n.º 4
0
        /// <summary>
        /// The entry point of the application
        /// </summary>
        /// <param name="args">The CLI arguments</param>
        public static async Task Main(string[] args)
        {
            var network = new NetworkService();

            var browser     = new SystemBrowser(network.GetNextAvailablePort());
            var redirectUri = $"http://127.0.0.1:{browser.Port}";

            var options = new OidcClientOptions
            {
                Authority    = "https://localhost:11009",
                ClientId     = "native",
                RedirectUri  = redirectUri,
                Browser      = browser,
                Scope        = "openid profile email",
                FilterClaims = false
            };

            var client = new OidcClient(options);

            var result = await client.LoginAsync(new LoginRequest
            {
                BrowserTimeout     = (int)TimeSpan.FromMinutes(5).TotalSeconds,
                BrowserDisplayMode = DisplayMode.Visible
            });

            if (result.IsError)
            {
                Console.WriteLine($"Error while logging in {result.Error}");
                return;
            }

            Console.WriteLine($"Got token {result.AccessToken}");

            Console.WriteLine("Hello World!");
        }
Exemplo n.º 5
0
        public InterpreterEngine(MainForm parent)
        {
            _parent        = parent;
            _fileIndexer   = new FileIndexer();
            _systemBrowser = new SystemBrowser();
            _menuEngine    = new MenuEngine(parent);
            _plugins       = new List <InterpreterPlugin>();
            //_special_keywords = new string[] { @"!this", @"!clipboard", @"!actproc", @"!desktop", @"!explorer" };
            _indexer_timer           = new System.Timers.Timer();
            _indexer_timer.Elapsed  += new System.Timers.ElapsedEventHandler(_indexer_timer_Elapsed);
            _indexer_timer.AutoReset = true;
            LoadIndex();
            if (SettingsManager.Instance.GetSystemOptionsInfo().UpdateTime > 0)
            {
                BuildIndex();
                _indexer_timer.Interval = 1000 * 60 * SettingsManager.Instance.GetSystemOptionsInfo().UpdateTime;
                _indexer_timer.Start();
            }

            _automation_timer           = new System.Timers.Timer();
            _automation_timer.Elapsed  += new System.Timers.ElapsedEventHandler(_automation_timer_Elapsed);
            _automation_timer.Interval  = 5000;
            _automation_timer.AutoReset = true;
            _automation_timer.Start();

            _auto_update_timer           = new System.Timers.Timer();
            _auto_update_timer.Elapsed  += new System.Timers.ElapsedEventHandler(_auto_update_timer_Elapsed);
            _auto_update_timer.Interval  = 15000;
            _auto_update_timer.AutoReset = true;
            _auto_update_timer.Start();

            _commandCache = new PluginCommandCache(30);
        }
Exemplo n.º 6
0
 public OAuthClientLogin(string baseUrl, string clientId, string clientSecret, HttpMessageHandler?web = null)
 {
     this.baseUrl      = baseUrl;
     this.clientId     = clientId;
     this.clientSecret = clientSecret;
     browser           = new SystemBrowser();
     this.web          = new HttpClient(web ?? new HttpClientHandler());
 }
Exemplo n.º 7
0
 /// <summary>
 ///     Invoked when the application is launched through a custom URI scheme, such as
 ///     is the case in an OAuth 2.0 authorization flow.
 /// </summary>
 /// <param name="args">Details about the URI that activated the app.</param>
 protected override void OnActivated(IActivatedEventArgs args)
 {
     // When the app was activated by a Protocol (custom URI scheme), forwards
     // the URI to the SystemBrowser through a static method.
     if (args.Kind == ActivationKind.Protocol)
     {
         // Extracts the authorization response URI from the arguments.
         var protocolArgs = (ProtocolActivatedEventArgs)args;
         var uri          = protocolArgs.Uri;
         Debug.WriteLine("Authorization Response: " + uri.AbsoluteUri);
         SystemBrowser.ProcessResponse(uri);
     }
 }
Exemplo n.º 8
0
        public static OidcClientOptions ConfigureClient(string authority, string clientId, string clientSecret,
                                                        string desiredScopes)
        {
            var systemBrowser = new SystemBrowser();      // cannot inline because it is used twice below
            var options       = new OidcClientOptions
            {
                Authority    = authority,
                ClientId     = clientId,
                RedirectUri  = systemBrowser.RedirectUri,
                ClientSecret = clientSecret,
                Scope        = desiredScopes,
                Browser      = systemBrowser,
            };

            return(options);
        }
    public PkceProfileTokenProvider(string authority, string clientId)
    {
        var browser     = new SystemBrowser(4200);
        var redirectUri = $"http://127.0.0.1:{browser.Port}";

        var options = new OidcClientOptions
        {
            Authority    = authority,
            ClientId     = clientId,
            RedirectUri  = redirectUri,
            Scope        = "openid profile offline_access",
            FilterClaims = false,
            Browser      = browser
        };

        options.Policy.RequireIdentityTokenSignature = false;

        _oidcClient = new OidcClient(options);
    }
Exemplo n.º 10
0
        private async Task <LoginResult> LoginAsync(Uri redirectUri, OidcClientOptions clientOptions)
        {
            IBrowser browser;

            if (!redirectUri.IsDefaultPort)
            {
                browser = new SystemBrowser(redirectUri.Port);
            }
            else
            {
                browser = new SystemBrowser();
            }

            clientOptions.Browser = browser;

            var client = new OidcClient(clientOptions);

            return(await client.LoginAsync(new LoginRequest()).ConfigureAwait(false));
        }
Exemplo n.º 11
0
	// Use this for initialization
	void Start () 
	{
		SetInitialGUIState ();

		//get target browsing object
		target = GameObject.FindGameObjectWithTag ("Browser");
		if (target == null)
			return;

		//get components
		list = target.GetComponent<SubsystemList> ();
		browser = target.GetComponent<SystemBrowser> ();
		if (list == null || browser == null)
			return;

		textSystemName.text = list.systemName;
		if (list.list.Count > 0)
			menu.interactable = true;

		AddDropDownButtonsAssociatedWithSubsystems ();
	}
Exemplo n.º 12
0
 private void SourceTextBox_PreviewMouseDown(object sender, MouseButtonEventArgs e)
 {
     SystemBrowser.SelectImage(model);
 }
Exemplo n.º 13
0
	// Use this for initialization
	void Start () 
	{
		Subs = GetComponent<SubsystemList> ();
		Browser = GetComponent<SystemBrowser> ();
	}
            public async Task <Response> Handle(Request request, CancellationToken cancellationToken)
            {
                Response response = new Response {
                };

                try
                {
                    var    browser     = new SystemBrowser(45656);
                    string redirectUri = "http://127.0.0.1:45656";

                    var scopes = new[] {
                        $"openid",
                        $"profile",
                        $"{ScopeBaseUrl}/{ServiceName}",
                        $"{ScopeBaseUrl}/{ServiceName}.readonly",
                        $"{ScopeBaseUrl}/{ServiceName}.modify",
                    };

                    var scope   = string.Join(" ", scopes);
                    var options = new OidcClientOptions
                    {
                        Authority    = _authority,
                        ClientId     = _clientId,
                        RedirectUri  = redirectUri,
                        Scope        = scope, //"openid profile"
                        FilterClaims = false,
                        Browser      = browser,
                        Flow         = OidcClientOptions.AuthenticationFlow.AuthorizationCode,
                        ResponseMode = OidcClientOptions.AuthorizeResponseMode.Redirect,
                        LoadProfile  = true
                    };
                    options.Policy.Discovery.ValidateIssuerName = false;
                    options.Policy.Discovery.ValidateEndpoints  = false;
                    var serilog = new LoggerConfiguration()
                                  .MinimumLevel.Verbose()
                                  .Enrich.FromLogContext()
                                  .WriteTo.LiterateConsole(outputTemplate: "[{Timestamp:HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message}{NewLine}{Exception}{NewLine}")
                                  .CreateLogger();

                    options.LoggerFactory.AddSerilog(serilog);

                    var oidcClient = new OidcClient(options);

                    Dictionary <string, string> extra = new Dictionary <string, string>
                    {
                        ["context-token"] = request.ContextToken
                    };

                    //   ResponseValidationResult rvr = null;
                    response.Result = await oidcClient.LoginAsync(new LoginRequest()
                    {
                        FrontChannelExtraParameters = extra,
                    });
                }
                catch (Exception ex)
                {
                    response.Exception = ex;
                }

                return(response);
            }
Exemplo n.º 15
0
 private void DestinationButton_Click(object sender, RoutedEventArgs e)
 {
     SystemBrowser.SelectFolder(model);
 }
Exemplo n.º 16
0
 private void DestinationTextBox_PreviewMouseDown(object sender, MouseButtonEventArgs e)
 {
     SystemBrowser.SelectFolder(model);
 }
Exemplo n.º 17
0
 private void SourceButton_Click(object sender, RoutedEventArgs e)
 {
     SystemBrowser.SelectImage(model);
 }