public void Init() { _sm = new StaffMemberIndicator(SeedGuidFactory.Get("1")); _ti = new TenancyIndicator(SeedGuidFactory.Get("1")); _cii = new ClientInstanceIndicator(SeedGuidFactory.Get("1")); _secKey = new StubSecurityKeyFactory("SecretKeySecretKeySecretKeySecretKeySecretKeySecretKeySecretKeySecretKey").SecurityKey; }
public ValidatedJWTokenTestForgery(StaffMemberIndicator user, IEnumerable <SecurityAction> securityActions, TenancyIndicator tenancy, ClientInstanceIndicator clientInstance, DateTime requestTime, bool hasExpiration) { var sskf = new StubSecurityKeyFactory("SecretKeySecretKeySecretKeySecretKeySecretKeySecretKeySecretKeySecretKey"); ACC = new AuthenticatedClientClaims { Tenancy = tenancy, User = user, Client = clientInstance, }; ACC.SecurityActions.UnionWith(securityActions); RawTokenData = new JWToken(clientInstance, user, securityActions, tenancy, requestTime, hasExpiration, sskf.SigningCredentials).SignedToken; }
private void CreateToken(ClientInstanceIndicator client, StaffMemberIndicator user, IEnumerable <SecurityAction> securityActions, TenancyIndicator tenancy, DateTime requestTime, bool hasExpiration, SigningCredentials creds) { var claims = new List <Claim> { new Claim(JwtRegisteredClaimNames.Jti, Id.ToString()), new Claim(UserIdKey, user.GuidID.ToString()), new Claim(TenancyIdKey, tenancy.GuidID.ToString()), new Claim(ClientIdKey, client.GuidID.ToString()), new Claim(GrantsDocumentKey, JsonConvert.SerializeObject(securityActions.Select(x => x.ToString()).ToList())), }; var expiry = hasExpiration ? requestTime.ToUniversalTime().AddMinutes(AccessTokenExpirationMinutes) : (DateTime?)null; var tok = new JwtSecurityToken(Issuer, Audience, claims, null, expiry, creds); SignedToken = new JwtSecurityTokenHandler().WriteToken(tok); }
public JWToken(ClientInstanceIndicator client, StaffMemberIndicator user, IEnumerable <SecurityAction> securityActions, TenancyIndicator tenancy, DateTime requestTime, bool hasExpiration, SigningCredentials creds) { Id = Guid.NewGuid(); CreateToken(client, user, securityActions, tenancy, requestTime, hasExpiration, creds); }