// Copyright Epic Games, Inc. All Rights Reserved. using System; using System.Text.Json.Serialization; using Microsoft.AspNetCore.Mvc; namespace HordeServer.Accounts { /// /// Request to authorize a user using OAuth2 /// public class OAuthAuthorizeRequest { /// /// Client identifier /// [FromQuery(Name = "client_id")] public string ClientId { get; set; } = String.Empty; /// /// Redirect URI that the response will be sent to /// [FromQuery(Name = "redirect_uri")] public string RedirectUri { get; set; } = String.Empty; /// /// OAuth response type. Should be "code". /// [FromQuery(Name = "response_type")] public string ResponseType { get; set; } = String.Empty; /// /// Space separated list of the requested scope values. Should include openid. /// [FromQuery(Name = "scope")] public string Scope { get; set; } = String.Empty; /// /// PKCE code challenge. /// [FromQuery(Name = "code_challenge")] public string? PkceCodeChallenge { get; set; } /// /// PKCE code challenge method. Should be "plain" or "S256". /// [FromQuery(Name = "code_challenge_method")] public string? PkceCodeChallengeMethod { get; set; } /// /// Response method. Only "query" is supported by Horde. /// [FromQuery(Name = "response_mode")] public string ResponseMode { get; set; } = "query"; /// /// Random string used to prevent replay attacks /// [FromQuery(Name = "nonce")] public string? Nonce { get; set; } /// /// Optional application-defined state value. /// [FromQuery(Name = "state")] public string? State { get; set; } } /// /// Response from a token exchange operation /// public class OAuthGetTokenRequest { /// /// Type of token being specified. Should be "authorization_code" or "refresh_token". /// [FromForm(Name = "grant_type")] public string? GrantType { get; set; } /// /// Access token specified in the redirect. /// [FromForm(Name = "code")] public string? AuthorizationToken { get; set; } /// /// Refresh token specified in the redirect. /// [FromForm(Name = "refresh_token")] public string? RefreshToken { get; set; } /// /// /// [FromForm(Name = "redirect_url")] public string? RedirectUrl { get; set; } /// /// Data that the PKCE code challenge was generated from /// [FromForm(Name = "code_verifier")] public string? PkceCodeVerifier { get; set; } } /// /// Response from the OAuth2 token endpoint (https://datatracker.ietf.org/doc/html/rfc6749#section-5.1) /// public class OAuthGetTokenResponse { /// /// The access token return value /// [JsonPropertyName("access_token")] public string? AccessToken { get; set; } /// /// Type of . Typically "Bearer" for Horde responses. /// [JsonPropertyName("token_type")] public string? TokenType { get; set; } /// /// Expiry time in seconds for the access token /// [JsonPropertyName("expires_in")] public int? ExpiresIn { get; set; } /// /// /// [JsonPropertyName("scope")] public string? Scope { get; set; } /// /// Refresh token /// [JsonPropertyName("refresh_token")] public string? RefreshToken { get; set; } /// /// TTL for the refresh token /// [JsonPropertyName("refresh_token_expires_in")] public int? RefreshTokenExpiresIn { get; set; } /// /// JWT with information about the authorized user /// [JsonPropertyName("id_token")] public string? IdToken { get; set; } /// /// Error code /// [JsonPropertyName("error")] public string? Error { get; set; } /// /// The error description text /// [JsonPropertyName("error_description")] public string? ErrorDescription { get; set; } } }