Пример #1
0
        public IEnumerable <Claim> GetVerificationClaims()
        {
            var claims = new List <Claim>();

            if (HasVerifiedPostiveTest)
            {
                claims.Add(new Claim(JwtClaimTypes.Role, VerificationRoles.VerifiedPositive));

                claims.Add(new Claim(DkSmittestopClaims.Covid19Status, DkSmittestopClaims.StatusValues.Positive));
                claims.Add(new Claim(DkSmittestopClaims.Covid19Blocked, VerificationLimitExceeded.ToString().ToLowerInvariant()));
            }
            else
            {
                claims.Add(new Claim(DkSmittestopClaims.Covid19Status, DkSmittestopClaims.StatusValues.Negative));
            }

            if (VerificationLimitExceeded)
            {
                claims.Add(new Claim(DkSmittestopClaims.Covid19Blocked, VerificationLimitExceeded.ToString().ToLowerInvariant()));

                VerificationLimitConfig.MatchSome(verLimCfg =>
                {
                    claims.Add(new Claim(DkSmittestopClaims.Covid19LimitDuration, Convert.ToInt32(verLimCfg.MaxLimitDuration.TotalHours).ToString()));
                    claims.Add(new Claim(DkSmittestopClaims.Covid19LimitCount, verLimCfg.MaxVerificationsAllowed.ToString()));
                });
            }

            PositiveTestDate.Map(testDate => testDate.ToString("yyyy-MM-dd")).MatchSome(isoTestData =>
            {
                claims.Add(new Claim(VerificationClaims.VerifiedPositiveTestDate, isoTestData));
                claims.Add(new Claim(DkSmittestopClaims.Covid19InfectionStart, isoTestData));
            });

            return(claims);
        }
        public IEnumerable <Claim> GetVerificationClaims()
        {
            var claims = new List <Claim>
            {
                new Claim(DkSmittestopClaims.Covid19Status, HasVerifiedPostiveTest
                    ? DkSmittestopClaims.StatusValues.Positive
                    : DkSmittestopClaims.StatusValues.Negative)
            };

            PositiveTestDate.Map(testDate => testDate.ToString("yyyy-MM-dd")).MatchSome(isoTestDate =>
            {
                claims.Add(new Claim(VerificationClaims.VerifiedPositiveTestDate, isoTestDate));
                claims.Add(new Claim(DkSmittestopClaims.Covid19InfectionStart, isoTestDate));
            });


            claims.Add(new Claim(DkSmittestopClaims.Covid19Blocked, VerificationLimitExceeded.ToString().ToLowerInvariant()));
            if (VerificationLimitExceeded)
            {
                VerificationLimitConfig.MatchSome(verLimCfg =>
                {
                    claims.Add(new Claim(DkSmittestopClaims.Covid19LimitDuration, Convert.ToInt32(verLimCfg.MaxLimitDuration.TotalHours).ToString()));
                    claims.Add(new Claim(DkSmittestopClaims.Covid19LimitCount, verLimCfg.MaxVerificationsAllowed.ToString()));
                });
            }

            if (SkipMsisLookup)
            {
                claims.Add(new Claim(VerificationClaims.SkipMsisLookup, "true"));
            }

            if (CanUploadKeys)
            {
                // grants access to JWT to anonymous token exchange
                claims.Add(new Claim(JwtClaimTypes.Role, VerificationRoles.UploadApproved));
            }

            return(claims);
        }