-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAuthDTO.java
More file actions
49 lines (44 loc) · 2.05 KB
/
AuthDTO.java
File metadata and controls
49 lines (44 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package org.openpodcastapi.opa.auth;
import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.validation.constraints.NotNull;
/// All data transfer objects for auth methods
public class AuthDTO {
/// A DTO representing an api login request
///
/// @param username the user's username
/// @param password the user's password
public record LoginRequest(
@JsonProperty(value = "username", required = true) @NotNull String username,
@JsonProperty(value = "password", required = true) @NotNull String password
) {
}
/// A DTO representing a successful api authentication attempt
///
/// @param accessToken the access token to be used to authenticate
/// @param expiresIn the TTL of the access token (in seconds)
/// @param refreshToken the refresh token to be used to request new access tokens
public record LoginSuccessResponse(
@JsonProperty(value = "accessToken", required = true) @NotNull String accessToken,
@JsonProperty(value = "refreshToken", required = true) @NotNull String refreshToken,
@JsonProperty(value = "expiresIn", required = true) @NotNull String expiresIn
) {
}
/// A DTO representing a refresh token request
///
/// @param username the username of the requesting user
/// @param refreshToken the refresh token used to issue a new token
public record RefreshTokenRequest(
@JsonProperty(value = "username", required = true) @NotNull String username,
@JsonProperty(value = "refreshToken", required = true) @NotNull String refreshToken
) {
}
/// A DTO representing an updated access token from the refresh endpoint
///
/// @param accessToken the newly generated access token
/// @param expiresIn the TTL of the token (in seconds)
public record RefreshTokenResponse(
@JsonProperty(value = "accessToken", required = true) @NotNull String accessToken,
@JsonProperty(value = "expiresIn", required = true) @NotNull String expiresIn
) {
}
}