public async Task <OktaState> SignIn(IOktaConfig oktaConfig = default)
        {
            oktaConfig = oktaConfig ?? OktaConfig.LoadFromPList("OktaConfig.plist");
            OidcClient oidcClient = new OidcClient(this, oktaConfig);

            return(await oidcClient.SignInWithBrowserAsync());
        }
 /// <summary>
 /// Creates a new iOS Okta OidcClient, attached to the provided <see cref="UIKit.UIViewController"/> and based on the specified <see cref="OktaConfig"/>
 /// </summary>
 /// <param name="iOSViewController">A reference to the current iOS <see cref="UIKit.UIViewController"/>, for use in launching the browser for login</param>
 /// <param name="config">The <see cref="OktaConfig"/> to use for this client.  The config must be valid at the time this is called.</param>
 public OidcClient(UIKit.UIViewController iOSViewController, IOktaConfig config)
 {
     while (iOSViewController.PresentedViewController != null)
     {
         iOSViewController = iOSViewController.PresentedViewController;
     }
     this.iOSViewController = iOSViewController;
     this.Config            = config;
     validator.Validate(Config);
 }
Beispiel #3
0
 /// <summary>
 /// Creates a new UWO Okta OidcClient based on the specified <see cref="OktaConfig"/>
 /// </summary>
 /// <param name="config">The <see cref="OktaConfig"/> to use for this client.  The config must be valid at the time this is called.</param>
 public OidcClient(IOktaConfig config)
 {
     this.Config = config;
     validator.Validate(Config);
 }
        /// <summary>
        /// Validates all fields in this config object and throws an exception if anything is wrong.
        /// </summary>
        /// <param name="config">The config object to validate</param>
        public void Validate(IOktaConfig config)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            if (string.IsNullOrEmpty(config.OktaDomain))
            {
                throw new ArgumentNullException(
                          nameof(config.OktaDomain),
                          "Your Okta URL is missing. You can copy your domain from the Okta Developer Console. Follow these instructions to find it: https://bit.ly/finding-okta-domain");
            }

            if (string.IsNullOrEmpty(config.ClientId))
            {
                throw new ArgumentNullException(
                          nameof(config.ClientId),
                          "Your Okta ClientId is missing. You can copy your ClientId from the Okta Developer Console.");
            }

            if (string.IsNullOrEmpty(config.RedirectUri))
            {
                throw new ArgumentNullException(
                          nameof(config.RedirectUri),
                          "Your RedirectUri is missing. This is typically something like \"{ yourAppScheme }://callback\", and should match your scheme/intent settings for your mobile project.");
            }

            if (string.IsNullOrEmpty(config.PostLogoutRedirectUri))
            {
                throw new ArgumentNullException(
                          nameof(config.PostLogoutRedirectUri),
                          "Your PostLogoutRedirectUri is missing. This is typically something like \"{ yourAppScheme }://logout\", and should match your scheme/intent settings for your mobile project.");
            }


            if (!config.OktaDomain.StartsWith("https://"))
            {
                throw new ArgumentException(
                          $"Your Okta URL must start with https. Current value: {config.OktaDomain}. You can copy your domain from the Okta Developer Console. Follow these instructions to find it: https://bit.ly/finding-okta-domain",
                          nameof(config.OktaDomain));
            }

            if (config.OktaDomain.IndexOf("{yourOktaDomain}", StringComparison.OrdinalIgnoreCase) >= 0)
            {
                throw new ArgumentException(
                          "Replace {yourOktaDomain} with your Okta domain. You can copy your domain from the Okta Developer Console. Follow these instructions to find it: https://bit.ly/finding-okta-domain", nameof(config.OktaDomain));
            }

            if (config.OktaDomain.IndexOf("-admin.oktapreview.com", StringComparison.OrdinalIgnoreCase) >= 0 ||
                config.OktaDomain.IndexOf("-admin.okta.com", StringComparison.OrdinalIgnoreCase) >= 0 ||
                config.OktaDomain.IndexOf("-admin.okta-emea.com", StringComparison.OrdinalIgnoreCase) >= 0)
            {
                throw new ArgumentException(
                          $"Your Okta domain should not contain -admin. Current value: {config.OktaDomain}. You can copy your domain from the Okta Developer Console. Follow these instructions to find it: https://bit.ly/finding-okta-domain", nameof(config.OktaDomain));
            }

            if (config.OktaDomain.IndexOf(".com.com", StringComparison.OrdinalIgnoreCase) >= 0 || Regex.Matches(config.OktaDomain, "://").Count != 1)
            {
                throw new ArgumentException(
                          $"It looks like there's a typo in your Okta domain. Current value: {config.OktaDomain}. You can copy your domain from the Okta Developer Console. Follow these instructions to find it: https://bit.ly/finding-okta-domain", nameof(config.OktaDomain));
            }

            ValidateInternal((T)config);
        }
Beispiel #5
0
 /// <summary>
 /// Retrieves a stored state manager for a given config.  This is an async method and should be awaited.
 /// </summary>
 /// <param name="config">the Okta configuration that corresponds to a manager you are interested in</param>
 /// <returns>If a state manager is found for the provided config, this Task will return the <see cref="OktaState"/>.</returns>
 public static async Task <OktaState> ReadFromSecureStorageAsync(IOktaConfig config)
 {
     throw new NotImplementedException();
 }
 public LogoutOptions(OktaState stateManager, IOktaConfig oktaConfig, string state)
 {
     this.IdTokenHint           = stateManager.IdToken;
     this.PostLogoutRedirectUri = oktaConfig.PostLogoutRedirectUri;
     this.State = state;
 }
Beispiel #7
0
 /// <summary>
 /// Creates a new Android Okta OidcClient, attached to the provided <see cref="Context"/> and based on the specified <see cref="OktaConfig"/>
 /// </summary>
 /// <param name="context">A reference to the current Android <see cref="Context"/>, for use in launching the browser for login</param>
 /// <param name="config">The <see cref="OktaConfig"/> to use for this client.  The config must be valid at the time this is called.</param>
 public OidcClient(Context context, IOktaConfig config)
 {
     this.AndroidContext = context;
     this.Config         = config;
     validator.Validate(Config);
 }