Skip to content

Commit 52648a0

Browse files
committed
impl: models for dynamic client registration
OAuth allows programatic client registration for apps like Coder Toolbox via the DCR endpoint which requires a name for the client app, the requested scopes, redirect URI, etc... DCR replies back with a similar structure but in addition it returs two very important properties: client_id - a unique client identifier string and also a client_secret - a secret string value used by clients to authenticate to the token endpoint.
1 parent 7685feb commit 52648a0

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.coder.toolbox.oauth
2+
3+
import com.squareup.moshi.Json
4+
import com.squareup.moshi.JsonClass
5+
6+
@JsonClass(generateAdapter = true)
7+
data class ClientRegistrationRequest(
8+
@field:Json(name = "client_name") val clientName: String,
9+
@field:Json(name = "redirect_uris") val redirectUris: List<String>,
10+
@field:Json(name = "grant_types") val grantTypes: List<String>,
11+
@field:Json(name = "response_types") val responseTypes: List<String>,
12+
@field:Json(name = "scope") val scope: String,
13+
@field:Json(name = "token_endpoint_auth_method") val tokenEndpointAuthMethod: String? = null
14+
)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.coder.toolbox.oauth
2+
3+
import com.squareup.moshi.Json
4+
import com.squareup.moshi.JsonClass
5+
6+
/**
7+
* DCR response
8+
*/
9+
@JsonClass(generateAdapter = true)
10+
data class ClientRegistrationResponse(
11+
@field:Json(name = "client_id") val clientId: String,
12+
@field:Json(name = "client_secret") val clientSecret: String,
13+
@field:Json(name = "client_name") val clientName: String,
14+
@field:Json(name = "redirect_uris") val redirectUris: List<String>,
15+
@field:Json(name = "grant_types") val grantTypes: List<String>,
16+
@field:Json(name = "response_types") val responseTypes: List<String>,
17+
@field:Json(name = "scope") val scope: String,
18+
@field:Json(name = "token_endpoint_auth_method") val tokenEndpointAuthMethod: String,
19+
@field:Json(name = "client_id_issued_at") val clientIdIssuedAt: Long?,
20+
@field:Json(name = "client_secret_expires_at") val clientSecretExpiresAt: Long?
21+
)

0 commit comments

Comments
 (0)