Пример #1
0
        /// <summary>

        /// Check that the options are valid.  Should throw an exception if things are not ok.

        /// </summary>

        public virtual void Validate(OAuthOptions oAuthOptions)
        {
            if (string.IsNullOrEmpty(ClientId))
            {
                throw new ArgumentException(nameof(ClientId));
            }

            if (string.IsNullOrEmpty(ClientSecret))
            {
                throw new ArgumentException(nameof(ClientSecret));
            }

            if (string.IsNullOrEmpty(AuthorizationEndpoint))
            {
                throw new ArgumentException(nameof(AuthorizationEndpoint));
            }

            if (string.IsNullOrEmpty(TokenEndpoint))
            {
                throw new ArgumentException(nameof(TokenEndpoint));
            }

            if (string.IsNullOrEmpty(ProviderCallbackUri) && string.IsNullOrEmpty(oAuthOptions.DefaultCallbackUri))
            {
                throw new ArgumentException("If no OAuthOptions.DefaultCallbackUri exists, each agent must supply a CallbackUri in its options.", nameof(ProviderCallbackUri));
            }

            if (string.IsNullOrEmpty(ProviderId))
            {
                throw new ArgumentException(nameof(ProviderId));
            }

            if (string.IsNullOrEmpty(ProviderDisplayName))
            {
                throw new ArgumentException(nameof(ProviderDisplayName));
            }
        }
 public OAuthAgentPostConfigureOptions(IDataProtectionProvider dataProtection, IOptionsMonitor <OAuthOptions> optionsMonitor)
 {
     _dp           = dataProtection;
     _oAuthOptions = optionsMonitor.CurrentValue;
 }
Пример #3
0
 public OAuthService(IOptionsMonitor <OAuthOptions> optionsMonitor, IServiceProvider serviceProvider)
 {
     Options          = optionsMonitor.CurrentValue;
     _serviceProvider = serviceProvider;
 }