public async Task <IActionResult> UpsertAccessControlPolicy(Capl.Authorization.AuthorizationPolicy policy)
        {
            try
            {
                await GraphManager.UpsertAcessControlPolicyAsync(policy.PolicyId.ToString(), policy);

                return(StatusCode(200));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex.Message));
            }
        }
        public async Task <ActionResult <Capl.Authorization.AuthorizationPolicy> > GetAccessControlPolicy(string policyUriString)
        {
            try
            {
                Capl.Authorization.AuthorizationPolicy policy = await GraphManager.GetAccessControlPolicyAsync(policyUriString);

                return(StatusCode(200, policy));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex.Message));
            }
        }
Esempio n. 3
0
        public async Task <IActionResult> UpsertAccessControlPolicy(AuthorizationPolicy policy)
        {
            try
            {
                _ = policy ?? throw new ArgumentNullException(nameof(policy));

                await graphManager.UpsertAcessControlPolicyAsync(policy.PolicyId.ToString(), policy);

                return(StatusCode(200));
            }
            catch (Exception ex)
            {
                logger?.LogError(ex, "Error upserting CAPL policy.");
                return(StatusCode(500, ex.Message));
            }
        }
Esempio n. 4
0
        public async Task <ActionResult <AuthorizationPolicy> > GetAccessControlPolicy(string policyUriString)
        {
            try
            {
                _ = policyUriString ?? throw new ArgumentNullException(nameof(policyUriString));

                AuthorizationPolicy policy = await graphManager.GetAccessControlPolicyAsync(policyUriString);

                return(StatusCode(200, policy));
            }
            catch (Exception ex)
            {
                logger?.LogError(ex, "Error getting CAPL policy.");
                return(StatusCode(500, ex.Message));
            }
        }
Esempio n. 5
0
        public async Task <ActionResult <Capl.Authorization.AuthorizationPolicy> > GetAccessControlPolicy(string policyUriString)
        {
            try
            {
                if (string.IsNullOrEmpty(policyUriString))
                {
                    throw new ArgumentNullException("policyUriString");
                }

                Capl.Authorization.AuthorizationPolicy policy = await graphManager.GetAccessControlPolicyAsync(policyUriString);

                return(StatusCode(200, policy));
            }
            catch (Exception ex)
            {
                logger?.LogError(ex, $"Error getting CAPL policy.");
                return(StatusCode(500, ex.Message));
            }
        }
Esempio n. 6
0
 public ApiAccessRequirement(Capl.Authorization.AuthorizationPolicy policy)
 {
     Policy = policy;
 }