-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
495 additions
and
89 deletions.
There are no files selected for viewing
55 changes: 32 additions & 23 deletions
55
...min-server/src/main/kotlin/com/sphereon/oid/fed/server/admin/controllers/KeyController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,33 @@ | ||
package com.sphereon.oid.fed.server.admin.controllers | ||
|
||
import com.sphereon.oid.fed.openapi.models.JwkDto | ||
import com.sphereon.oid.fed.persistence.models.Jwk | ||
import com.sphereon.oid.fed.services.KeyService | ||
import org.springframework.web.bind.annotation.* | ||
|
||
@RestController | ||
@RequestMapping("/accounts/{accountUsername}/keys") | ||
class KeyController { | ||
private val keyService = KeyService() | ||
|
||
@PostMapping | ||
fun create(@PathVariable accountUsername: String): Int { | ||
val key = keyService.create(accountUsername) | ||
return key.id | ||
} | ||
|
||
@GetMapping | ||
fun getKeys(@PathVariable accountUsername: String): List<JwkDto> { | ||
val keys = keyService.getKeys(accountUsername) | ||
return keys | ||
} | ||
package com.sphereon.oid.fed.server.admin.controllers | ||
|
||
import com.sphereon.oid.fed.openapi.models.JwkDto | ||
import com.sphereon.oid.fed.services.KeyService | ||
import com.sphereon.oid.fed.services.extensions.toJwkDTO | ||
import org.springframework.web.bind.annotation.* | ||
|
||
@RestController | ||
@RequestMapping("/accounts/{accountUsername}/keys") | ||
class KeyController { | ||
private val keyService = KeyService() | ||
|
||
@PostMapping | ||
fun create(@PathVariable accountUsername: String): JwkDto { | ||
val key = keyService.create(accountUsername) | ||
return key.toJwkDTO() | ||
} | ||
|
||
@GetMapping | ||
fun getKeys(@PathVariable accountUsername: String): List<JwkDto> { | ||
val keys = keyService.getKeys(accountUsername) | ||
return keys | ||
} | ||
|
||
@DeleteMapping("/{keyId}") | ||
fun revokeKey( | ||
@PathVariable accountUsername: String, | ||
@PathVariable keyId: Int, | ||
@RequestParam reason: String? | ||
): JwkDto { | ||
return keyService.revokeKey(accountUsername, keyId, reason) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
...openid-federation-common/src/commonMain/kotlin/com/sphereon/oid/fed/common/jwt/JoseJwt.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
package com.sphereon.oid.fed.common.jwt | ||
|
||
import com.sphereon.oid.fed.openapi.models.JwtWithPrivateKey | ||
|
||
expect class JwtHeader | ||
expect class JwtPayload | ||
|
||
expect fun sign(payload: JwtPayload, header: JwtHeader, opts: Map<String, Any>): String | ||
expect fun verify(jwt: String, key: Any, opts: Map<String, Any>): Boolean | ||
expect fun generateKeyPair(): String | ||
expect fun generateKeyPair(): JwtWithPrivateKey |
Oops, something went wrong.