public OpenIDLoginResponse(OpenIDResponseType responseType, string id, string issuer, string audience, IdentityModel identity, string x509Thumbprint, string nonce, string state) { if (responseType == OpenIDResponseType.Code) { this.AccessCode = AuthTokenManager.GenerateAccessCode(id, identity); } else if (responseType == OpenIDResponseType.IdToken) { this.ID = id; this.Issuer = issuer; this.Subject = Guid.NewGuid().ToString(); this.Audience = audience; this.UserID = identity.UserID; this.UserName = identity.UserName; this.Roles = identity.Roles; this.KeyID = x509Thumbprint; this.X509Thumbprint = x509Thumbprint; //same https://docs.microsoft.com/en-us/azure/active-directory/develop/id-tokens this.Nonce = nonce; this.State = state; this.IssuedAtTime = DateTimeOffset.UtcNow.ToUnixTimeSeconds(); this.NotBefore = DateTimeOffset.UtcNow.AddMinutes(-5).ToUnixTimeSeconds(); this.Expiration = DateTimeOffset.UtcNow.AddMinutes(5).ToUnixTimeSeconds(); } else { throw new IdentityProviderException($"Not supported response type {responseType}"); } }
public OAuth2LoginResponse(string serviceProvider, IdentityModel identity, string state) { this.ServiceProvider = serviceProvider; this.AccessCode = AuthTokenManager.GenerateAccessCode(serviceProvider, identity); this.State = state; }