コード例 #1
0
        public static bool HasVerifyScope(this IIdentity self)
        {
            var scopeClaim = self.GetScopeClaim();

            return(ScopeEvaluator.ScopeClaimsAllowsActionForSubject(scopeClaim, subject: null,
                                                                    requestedActions: new [] { NuGetScopes.PackageVerify }));
        }
コード例 #2
0
        public void ScopeClaimsAllowsActionForSubjectEvaluatesCorrectly(
            string scopeClaims, string subject, string[] requestedActions, bool expectedResult)
        {
            var result = ScopeEvaluator.ScopeClaimsAllowsActionForSubject(
                scopeClaims,
                subject,
                requestedActions);

            Assert.Equal(expectedResult, result);
        }
コード例 #3
0
        public static bool HasScopeThatAllowsActionForSubject(
            this IIdentity self,
            string subject,
            string[] requestedActions)
        {
            var identity = self as ClaimsIdentity;

            if (identity == null)
            {
                return(false);
            }

            var scopeClaim = identity.GetClaimOrDefault(NuGetClaims.Scope);

            return(ScopeEvaluator.ScopeClaimsAllowsActionForSubject(scopeClaim, subject, requestedActions));
        }