Skip to content

Commit 9c81d04

Browse files
lujunsandmjb
andauthored
Secrets management API integration (#761)
Implements the new secret management APIs and some adjacent needed changes. Signed-off-by: lujunsan <[email protected]> Co-authored-by: Don Browne <[email protected]>
1 parent 98d9e5c commit 9c81d04

File tree

8 files changed

+1544
-25
lines changed

8 files changed

+1544
-25
lines changed

docs/server/docs.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/server/swagger.json

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

docs/server/swagger.yaml

Lines changed: 337 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,26 @@ components:
339339
type: array
340340
uniqueItems: false
341341
type: object
342+
v1.createSecretRequest:
343+
description: Request to create a new secret
344+
properties:
345+
key:
346+
description: Secret key name
347+
type: string
348+
value:
349+
description: Secret value
350+
type: string
351+
type: object
352+
v1.createSecretResponse:
353+
description: Response after creating a secret
354+
properties:
355+
key:
356+
description: Secret key that was created
357+
type: string
358+
message:
359+
description: Success message
360+
type: string
361+
type: object
342362
v1.createWorkloadResponse:
343363
description: Response after successfully creating a workload
344364
properties:
@@ -367,12 +387,34 @@ components:
367387
description: Version of the registry schema
368388
type: string
369389
type: object
390+
v1.getSecretsProviderResponse:
391+
description: Response containing secrets provider details
392+
properties:
393+
capabilities:
394+
$ref: '#/components/schemas/v1.providerCapabilitiesResponse'
395+
name:
396+
description: Name of the secrets provider
397+
type: string
398+
provider_type:
399+
description: Type of the secrets provider
400+
type: string
401+
type: object
370402
v1.getServerResponse:
371403
description: Response containing server details
372404
properties:
373405
server:
374406
$ref: '#/components/schemas/registry.Server'
375407
type: object
408+
v1.listSecretsResponse:
409+
description: Response containing a list of secret keys
410+
properties:
411+
keys:
412+
description: List of secret keys
413+
items:
414+
$ref: '#/components/schemas/v1.secretKeyResponse'
415+
type: array
416+
uniqueItems: false
417+
type: object
376418
v1.listServersResponse:
377419
description: Response containing a list of servers
378420
properties:
@@ -399,6 +441,25 @@ components:
399441
description: JWKS URL for key verification
400442
type: string
401443
type: object
444+
v1.providerCapabilitiesResponse:
445+
description: Capabilities of the secrets provider
446+
properties:
447+
can_cleanup:
448+
description: Whether the provider can cleanup all secrets
449+
type: boolean
450+
can_delete:
451+
description: Whether the provider can delete secrets
452+
type: boolean
453+
can_list:
454+
description: Whether the provider can list secrets
455+
type: boolean
456+
can_read:
457+
description: Whether the provider can read secrets
458+
type: boolean
459+
can_write:
460+
description: Whether the provider can write secrets
461+
type: boolean
462+
type: object
402463
v1.registryInfo:
403464
description: Basic information about a registry
404465
properties:
@@ -425,6 +486,55 @@ components:
425486
type: array
426487
uniqueItems: false
427488
type: object
489+
v1.secretKeyResponse:
490+
description: Secret key information
491+
properties:
492+
description:
493+
description: Optional description of the secret
494+
type: string
495+
key:
496+
description: Secret key name
497+
type: string
498+
type: object
499+
v1.setupSecretsRequest:
500+
description: Request to setup a secrets provider
501+
properties:
502+
password:
503+
description: |-
504+
Password for encrypted provider (optional, can be set via environment variable)
505+
TODO Review environment variable for this
506+
type: string
507+
provider_type:
508+
description: Type of the secrets provider (encrypted, 1password, none)
509+
type: string
510+
type: object
511+
v1.setupSecretsResponse:
512+
description: Response after initializing a secrets provider
513+
properties:
514+
message:
515+
description: Success message
516+
type: string
517+
provider_type:
518+
description: Type of the secrets provider that was setup
519+
type: string
520+
type: object
521+
v1.updateSecretRequest:
522+
description: Request to update an existing secret
523+
properties:
524+
value:
525+
description: New secret value
526+
type: string
527+
type: object
528+
v1.updateSecretResponse:
529+
description: Response after updating a secret
530+
properties:
531+
key:
532+
description: Secret key that was updated
533+
type: string
534+
message:
535+
description: Success message
536+
type: string
537+
type: object
428538
v1.versionResponse:
429539
properties:
430540
version:
@@ -720,6 +830,233 @@ paths:
720830
summary: Get a server from a registry
721831
tags:
722832
- registry
833+
/api/v1beta/secrets:
834+
post:
835+
description: Setup the secrets provider with the specified type and configuration.
836+
requestBody:
837+
content:
838+
application/json:
839+
schema:
840+
$ref: '#/components/schemas/v1.setupSecretsRequest'
841+
description: Setup secrets provider request
842+
required: true
843+
responses:
844+
"201":
845+
content:
846+
application/json:
847+
schema:
848+
$ref: '#/components/schemas/v1.setupSecretsResponse'
849+
description: Created
850+
"400":
851+
content:
852+
application/json:
853+
schema:
854+
type: string
855+
description: Bad Request
856+
"500":
857+
content:
858+
application/json:
859+
schema:
860+
type: string
861+
description: Internal Server Error
862+
summary: Setup or reconfigure secrets provider
863+
tags:
864+
- secrets
865+
/api/v1beta/secrets/default:
866+
get:
867+
description: Get details of the default secrets provider
868+
responses:
869+
"200":
870+
content:
871+
application/json:
872+
schema:
873+
$ref: '#/components/schemas/v1.getSecretsProviderResponse'
874+
description: OK
875+
"404":
876+
content:
877+
application/json:
878+
schema:
879+
type: string
880+
description: Not Found - Provider not setup
881+
"500":
882+
content:
883+
application/json:
884+
schema:
885+
type: string
886+
description: Internal Server Error
887+
summary: Get secrets provider details
888+
tags:
889+
- secrets
890+
/api/v1beta/secrets/default/keys:
891+
get:
892+
description: Get a list of all secret keys from the default provider
893+
responses:
894+
"200":
895+
content:
896+
application/json:
897+
schema:
898+
$ref: '#/components/schemas/v1.listSecretsResponse'
899+
description: OK
900+
"404":
901+
content:
902+
application/json:
903+
schema:
904+
type: string
905+
description: Not Found - Provider not setup
906+
"405":
907+
content:
908+
application/json:
909+
schema:
910+
type: string
911+
description: Method Not Allowed - Provider doesn't support listing
912+
"500":
913+
content:
914+
application/json:
915+
schema:
916+
type: string
917+
description: Internal Server Error
918+
summary: List secrets
919+
tags:
920+
- secrets
921+
post:
922+
description: Create a new secret in the default provider (encrypted provider
923+
only)
924+
requestBody:
925+
content:
926+
application/json:
927+
schema:
928+
$ref: '#/components/schemas/v1.createSecretRequest'
929+
description: Create secret request
930+
required: true
931+
responses:
932+
"201":
933+
content:
934+
application/json:
935+
schema:
936+
$ref: '#/components/schemas/v1.createSecretResponse'
937+
description: Created
938+
"400":
939+
content:
940+
application/json:
941+
schema:
942+
type: string
943+
description: Bad Request
944+
"404":
945+
content:
946+
application/json:
947+
schema:
948+
type: string
949+
description: Not Found - Provider not setup
950+
"405":
951+
content:
952+
application/json:
953+
schema:
954+
type: string
955+
description: Method Not Allowed - Provider doesn't support writing
956+
"409":
957+
content:
958+
application/json:
959+
schema:
960+
type: string
961+
description: Conflict - Secret already exists
962+
"500":
963+
content:
964+
application/json:
965+
schema:
966+
type: string
967+
description: Internal Server Error
968+
summary: Create a new secret
969+
tags:
970+
- secrets
971+
/api/v1beta/secrets/default/keys/{key}:
972+
delete:
973+
description: Delete a secret from the default provider (encrypted provider only)
974+
parameters:
975+
- description: Secret key
976+
in: path
977+
name: key
978+
required: true
979+
schema:
980+
type: string
981+
responses:
982+
"204":
983+
content:
984+
application/json:
985+
schema:
986+
type: string
987+
description: No Content
988+
"404":
989+
content:
990+
application/json:
991+
schema:
992+
type: string
993+
description: Not Found - Provider not setup or secret not found
994+
"405":
995+
content:
996+
application/json:
997+
schema:
998+
type: string
999+
description: Method Not Allowed - Provider doesn't support deletion
1000+
"500":
1001+
content:
1002+
application/json:
1003+
schema:
1004+
type: string
1005+
description: Internal Server Error
1006+
summary: Delete a secret
1007+
tags:
1008+
- secrets
1009+
put:
1010+
description: Update an existing secret in the default provider (encrypted provider
1011+
only)
1012+
parameters:
1013+
- description: Secret key
1014+
in: path
1015+
name: key
1016+
required: true
1017+
schema:
1018+
type: string
1019+
requestBody:
1020+
content:
1021+
application/json:
1022+
schema:
1023+
$ref: '#/components/schemas/v1.updateSecretRequest'
1024+
description: Update secret request
1025+
required: true
1026+
responses:
1027+
"200":
1028+
content:
1029+
application/json:
1030+
schema:
1031+
$ref: '#/components/schemas/v1.updateSecretResponse'
1032+
description: OK
1033+
"400":
1034+
content:
1035+
application/json:
1036+
schema:
1037+
type: string
1038+
description: Bad Request
1039+
"404":
1040+
content:
1041+
application/json:
1042+
schema:
1043+
type: string
1044+
description: Not Found - Provider not setup or secret not found
1045+
"405":
1046+
content:
1047+
application/json:
1048+
schema:
1049+
type: string
1050+
description: Method Not Allowed - Provider doesn't support writing
1051+
"500":
1052+
content:
1053+
application/json:
1054+
schema:
1055+
type: string
1056+
description: Internal Server Error
1057+
summary: Update a secret
1058+
tags:
1059+
- secrets
7231060
/api/v1beta/version:
7241061
get:
7251062
description: Returns the current version of the server

pkg/api/server.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ func Serve(
136136
"/api/v1beta/registry": v1.RegistryRouter(),
137137
"/api/v1beta/discovery": v1.DiscoveryRouter(),
138138
"/api/v1beta/clients": v1.ClientRouter(clientManager),
139+
"/api/v1beta/secrets": v1.SecretsRouter(),
139140
}
140141

141142
// Only mount docs router if enabled

0 commit comments

Comments
 (0)