Skip to content

Add groups claim in OIDC token as secondary principals of SSH certs #1445

Locked Answered by maraino
hb3b asked this question in Q&A
Discussion options

You must be logged in to vote

Let's see with this simple template you can concatenate the "groups" in the token with the principals:

{
	"type": "{{ .Type }}",
	"keyId": "{{ .KeyID }}",
{{- if .Token.groups }}
	"principals": {{ concat .Principals .Token.groups | toJson  }},
{{- else }}
	"principals": {{ toJson .Principals }},
{{- end }}
	"extensions": {{ toJson .Extensions }},
	"criticalOptions": {{ toJson .CriticalOptions }}
}

Take into account that this template assumes "groups" if it exists is always an array. For more information on concat take a look to http://masterminds.github.io/sprig/lists.html

A token with "groups": ["admin", "engineers"] will create a certificate like:

$ step ssh inspect mariano-cert.pub
..…

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by tashian
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
3 participants
Converted from issue

This discussion was converted from issue #388 on June 20, 2023 17:18.