Identity: Allow specifying a custom OIDC client_id field (#8165)
This commit is contained in:
parent
2b78d6ca9d
commit
d74463bbcc
|
@ -251,6 +251,10 @@ func oidcPaths(i *IdentityStore) []*framework.Path {
|
|||
Description: "TTL of the tokens generated against the role.",
|
||||
Default: "24h",
|
||||
},
|
||||
"client_id": {
|
||||
Type: framework.TypeString,
|
||||
Description: "Optional client_id",
|
||||
},
|
||||
},
|
||||
Callbacks: map[logical.Operation]framework.OperationFunc{
|
||||
logical.UpdateOperation: i.pathOIDCCreateUpdateRole,
|
||||
|
@ -931,6 +935,10 @@ func (i *IdentityStore) pathOIDCCreateUpdateRole(ctx context.Context, req *logic
|
|||
role.TokenTTL = time.Duration(d.Get("ttl").(int)) * time.Second
|
||||
}
|
||||
|
||||
if clientID, ok := d.GetOk("client_id"); ok {
|
||||
role.ClientID = clientID.(string)
|
||||
}
|
||||
|
||||
// create role path
|
||||
if role.ClientID == "" {
|
||||
clientID, err := base62.Random(26)
|
||||
|
|
|
@ -65,8 +65,9 @@ func TestOIDC_Path_OIDCRoleRole(t *testing.T) {
|
|||
Path: "oidc/role/test-role1",
|
||||
Operation: logical.UpdateOperation,
|
||||
Data: map[string]interface{}{
|
||||
"template": "{\"some-key\":\"some-value\"}",
|
||||
"ttl": "2h",
|
||||
"template": "{\"some-key\":\"some-value\"}",
|
||||
"ttl": "2h",
|
||||
"client_id": "my_custom_id",
|
||||
},
|
||||
Storage: storage,
|
||||
})
|
||||
|
@ -83,7 +84,7 @@ func TestOIDC_Path_OIDCRoleRole(t *testing.T) {
|
|||
"key": "test-key",
|
||||
"ttl": int64(7200),
|
||||
"template": "{\"some-key\":\"some-value\"}",
|
||||
"client_id": resp.Data["client_id"],
|
||||
"client_id": "my_custom_id",
|
||||
}
|
||||
if diff := deep.Equal(expected, resp.Data); diff != nil {
|
||||
t.Fatal(diff)
|
||||
|
|
Loading…
Reference in New Issue