public IEnumerable <SecurityKey> ResolveSecurityKey( string token, SecurityToken securityToken, string kid, TokenValidationParameters validationParameters) { var requestContext = _contextDataProvider.GetRequestContext(_httpContextAccessor.HttpContext).Result; if (requestContext == null || !requestContext.IsTenantContext) { throw new UnauthorizedAccessException(ErrorCode.MissingTenantContext.ToString()); } if (requestContext.Tenant.TenantCode != kid) { throw new UnauthorizedAccessException(ErrorCode.KidMissmatch.ToString()); } var tenantSettings = _tenantProvider.GetTenantSettings(requestContext.Tenant.TenantCode); if (string.IsNullOrEmpty(tenantSettings?.TokenSecret)) { throw new UnauthorizedAccessException(ErrorCode.MissingTenantTokenSecret.ToString()); } return(new[] { new SymmetricSecurityKey(Encoding.UTF8.GetBytes(tenantSettings.TokenSecret)) }); }