Esempio n. 1
0
        public void OnAuthorization(HttpActionContext actionContext)
        {
            var isAuthorized = _authorizationLogic.IsAuthorized(actionContext, typeof(InvoicesController));

            if (!isAuthorized)
            {
                actionContext.Response = actionContext.Request.CreateResponse(HttpStatusCode.Unauthorized);
            }
        }
        public SignPrivateCertificateResult SignCertificate(SignPrivateCertificateModel model, ClaimsPrincipal user)
        {
            CertificateRequest csr = certificateProvider.InitializeFromEncodedCsr(model.EncodedCsr);

            AdcsTemplate template = templateLogic.DiscoverTemplate(csr.CipherAlgorithm, WindowsApi.Cng, KeyUsage.ServerAuthentication);

            if (authorizationLogic.IsAuthorized(template, user))
            {
                MicrosoftCertificateAuthority ca = configurationRepository.GetPrivateCertificateAuthority(model.HashAlgorithm);

                CertificateAuthorityRequestResponse response = ca.Sign(csr, template.Name, template.KeyUsage);

                return(HandleCertificateAuthorityResponse(model, response, csr.Subject));
            }
            else
            {
                return(ProcessPendingSigningWorkflow(model));
            }
        }
        public IEnumerable <OidcIdentityProvider> GetIdps(ClaimsPrincipal user)
        {
            if (!authorizationLogic.IsAuthorized(AuthorizationScopes.ManageIdentityProviders, user))
            {
                throw new UnauthorizedAccessException("Access Denied: This current user principal is not authorized to view OpenId Connect Identity Providers.");
            }

            IEnumerable <OidcIdentityProvider> idpList = configurationRepository.GetAll <OidcIdentityProvider>();

            if (idpList == null)
            {
                return(new List <OidcIdentityProvider>());
            }
            else
            {
                return(idpList);
            }
        }