public async Task <ActionResult> ExecuteAsync(string name)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            var result = await _authenticationProviderRepository.GetAuthenticationProvider(name);

            if (result == null)
            {
                return(new NotFoundResult());
            }

            return(new OkObjectResult(result));
        }
Пример #2
0
        public async Task <ActionResult> ExecuteAsync(AuthenticationProvider authenticationProvider)
        {
            if (authenticationProvider == null)
            {
                throw new ArgumentNullException(nameof(authenticationProvider));
            }

            var authProvider = await _authenticationProviderRepository.GetAuthenticationProvider(authenticationProvider.Name);

            if (authProvider == null)
            {
                return(new NotFoundResult());
            }

            var isUpdated = await _authenticationProviderRepository.UpdateAuthenticationProvider(authenticationProvider);

            if (isUpdated)
            {
                return(new NoContentResult());
            }

            return(new StatusCodeResult(StatusCodes.Status500InternalServerError));
        }
        public async Task <ActionResult> ExecuteAsync(string name)
        {
            _configurationEventSource.StartToRemoveAuthenticationProvider(name);
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            var result = await _authenticationProviderRepository.GetAuthenticationProvider(name);

            if (result == null)
            {
                return(new NotFoundResult());
            }

            if (!await _authenticationProviderRepository.RemoveAuthenticationProvider(name))
            {
                return(new StatusCodeResult(StatusCodes.Status500InternalServerError));
            }

            _configurationEventSource.FinishToRemoveAuthenticationProvider(name);
            return(new NoContentResult());
        }
        public async Task <ActionResult> ExecuteAsync(AuthenticationProvider authenticationProvider)
        {
            var json = authenticationProvider == null ? string.Empty : JsonConvert.SerializeObject(authenticationProvider);

            _configurationEventSource.StartToAddAuthenticationProvider(json);
            if (authenticationProvider == null)
            {
                throw new ArgumentNullException(nameof(authenticationProvider));
            }

            if (string.IsNullOrWhiteSpace(authenticationProvider.Name))
            {
                throw new ArgumentNullException(nameof(authenticationProvider.Name));
            }

            if (string.IsNullOrWhiteSpace(authenticationProvider.CallbackPath))
            {
                throw new ArgumentNullException(nameof(authenticationProvider.CallbackPath));
            }

            var authProvider = await _authenticationProviderRepository.GetAuthenticationProvider(authenticationProvider.Name);

            if (authProvider != null)
            {
                throw new IdentityConfigurationException(
                          ErrorCodes.InternalErrorCode,
                          string.Format(ErrorDescriptions.TheAuthenticationProviderAlreadyExists, authenticationProvider.Name));
            }

            if (!await _authenticationProviderRepository.AddAuthenticationProvider(authenticationProvider))
            {
                return(new StatusCodeResult(StatusCodes.Status500InternalServerError));
            }

            _configurationEventSource.FinishToAddAuthenticationProvider(json);
            return(new NoContentResult());
        }
Пример #5
0
        public async Task<ActionResult> ExecuteAsync(string name, bool isEnabled)
        {
            _configurationEventSource.EnableAuthenticationProvider(name, isEnabled);
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            var authProvider = await _authenticationProviderRepository.GetAuthenticationProvider(name);
            if (authProvider == null)
            {
                return new NotFoundResult();
            }

            authProvider.IsEnabled = isEnabled;
            var isUpdated = await _authenticationProviderRepository.UpdateAuthenticationProvider(authProvider);
            if (isUpdated)
            {
                _configurationEventSource.FinishToEnableAuthenticationProvider(name, isEnabled);
                return new NoContentResult();
            }

            return new StatusCodeResult(StatusCodes.Status500InternalServerError);
        }