Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: OIDC provider client API #12272

Merged
merged 55 commits into from
Aug 23, 2021
Merged
Show file tree
Hide file tree
Changes from 53 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
e57cf07
initial commit
fairclothjm Jul 28, 2021
f14e587
add read and delete operations
fairclothjm Jul 28, 2021
c7a5032
fix bug in delete and add list unit test
fairclothjm Jul 29, 2021
ec5cd06
func doc typo fix
fairclothjm Jul 29, 2021
eb8cd78
add existence check for assignment
fairclothjm Jul 29, 2021
ad9786e
remove locking on the assignment resource
fairclothjm Aug 4, 2021
b7348a4
convert Callbacks to Operations
fairclothjm Aug 4, 2021
f1de027
add CRUD operations and test cases
fairclothjm Aug 4, 2021
f9a4c27
add client api and tests
fairclothjm Aug 5, 2021
b0173be
remove use of oidcCache
fairclothjm Aug 5, 2021
740c8e1
Merge branch 'oidc-provider-assignment-api' into oidc-provider-scope-api
fairclothjm Aug 5, 2021
9bbfca6
remove use of oidcCache
fairclothjm Aug 5, 2021
31c2552
add template validation and update tests
fairclothjm Aug 5, 2021
c461c17
Merge branch 'oidc-provider-scope-api' into oidc-provider-client-api
fairclothjm Aug 5, 2021
62e0f27
remove usage of oidcCache
fairclothjm Aug 5, 2021
f465774
refactor struct and var names
fairclothjm Aug 12, 2021
f2c59a0
harmonize test name conventions
fairclothjm Aug 12, 2021
f36150c
fix merge conflicts
fairclothjm Aug 12, 2021
b56639d
refactor struct and var names
fairclothjm Aug 12, 2021
e0c0e72
add changelog and refactor
fairclothjm Aug 12, 2021
591a5c5
Merge branch 'oidc-provider-assignment-api' into oidc-provider-scope-api
fairclothjm Aug 12, 2021
ced1882
refactor
fairclothjm Aug 12, 2021
9751d5d
remove extra period from changelog
fairclothjm Aug 12, 2021
b04a40a
Merge branch 'oidc-provider-assignment-api' into oidc-provider-scope-api
fairclothjm Aug 12, 2021
6d0c78f
update scope path to be OIDC provider specific
fairclothjm Aug 12, 2021
f129332
fix merge conflicts
fairclothjm Aug 12, 2021
981a254
refactor naming conventions
fairclothjm Aug 12, 2021
a01710b
update assignment path
fairclothjm Aug 12, 2021
cc8d9bc
fix merge conflict
fairclothjm Aug 12, 2021
51bd841
update scope path
fairclothjm Aug 12, 2021
a93b1d4
fix merge conflicts
fairclothjm Aug 12, 2021
464c0c3
enforce key existence on client creation
fairclothjm Aug 16, 2021
7a6259d
removed unused name field
fairclothjm Aug 16, 2021
0681fc7
Merge branch 'oidc-provider-assignment-api' into oidc-provider-scope-api
fairclothjm Aug 16, 2021
0ea328c
removed unused name field
fairclothjm Aug 16, 2021
ae86723
Merge branch 'oidc-provider-scope-api' into oidc-provider-client-api
fairclothjm Aug 16, 2021
5aa3ea4
removed unused name field
fairclothjm Aug 16, 2021
f6e2074
Merge remote-tracking branch 'origin/main' into oidc-provider-assignm…
fairclothjm Aug 16, 2021
1619537
Merge branch 'oidc-provider-assignment-api' into oidc-provider-scope-api
fairclothjm Aug 16, 2021
4ca579c
Merge branch 'oidc-provider-scope-api' into oidc-provider-client-api
fairclothjm Aug 16, 2021
435354c
prevent assignment deletion when ref'ed by a client
fairclothjm Aug 17, 2021
14b6f6e
enfoce assignment existence on client create/update
fairclothjm Aug 17, 2021
c2f93fd
update scope template description
fairclothjm Aug 17, 2021
84ff701
fix merge conflicts
fairclothjm Aug 17, 2021
f43c5bf
error when attempting to created scope with openid reserved name
fairclothjm Aug 18, 2021
0257470
fix merge conflicts
fairclothjm Aug 18, 2021
2af727b
fix UT failures after requiring assignment existence
fairclothjm Aug 18, 2021
5952ee0
disallow key deletion when ref'ed by existing client
fairclothjm Aug 18, 2021
ed65079
merge main && fix conflict
fairclothjm Aug 18, 2021
e018624
generate client_id and client_secret on CreateOp
fairclothjm Aug 18, 2021
e4b016b
do not allow key modification on client update
fairclothjm Aug 18, 2021
8ac2e1c
return client_id and client_secret on read ops
fairclothjm Aug 18, 2021
d466676
small refactor
fairclothjm Aug 18, 2021
f72b1d8
fix bug in delete assignment op
fairclothjm Aug 19, 2021
c3e2e2e
remove client secret get call
fairclothjm Aug 19, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 17 additions & 2 deletions vault/identity_store_oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,9 @@ func (i *IdentityStore) pathOIDCReadKey(ctx context.Context, req *logical.Reques
}, nil
}

// rolesReferencingTargetKeyName returns a map of role names to roles referenced by targetKeyName.
// rolesReferencingTargetKeyName returns a map of role names to roles
// referencing targetKeyName.
//
// Note: this is not threadsafe. It is to be called with Lock already held.
func (i *IdentityStore) rolesReferencingTargetKeyName(ctx context.Context, req *logical.Request, targetKeyName string) (map[string]role, error) {
roleNames, err := req.Storage.List(ctx, roleConfigPath)
Expand Down Expand Up @@ -605,7 +607,8 @@ func (i *IdentityStore) rolesReferencingTargetKeyName(ctx context.Context, req *
}

// roleNamesReferencingTargetKeyName returns a slice of strings of role
// names referenced by targetKeyName.
// names referencing targetKeyName.
//
// Note: this is not threadsafe. It is to be called with Lock already held.
func (i *IdentityStore) roleNamesReferencingTargetKeyName(ctx context.Context, req *logical.Request, targetKeyName string) ([]string, error) {
roles, err := i.rolesReferencingTargetKeyName(ctx, req, targetKeyName)
Expand Down Expand Up @@ -644,6 +647,18 @@ func (i *IdentityStore) pathOIDCDeleteKey(ctx context.Context, req *logical.Requ
return logical.ErrorResponse(errorMessage), logical.ErrInvalidRequest
}

clientNames, err := i.clientNamesReferencingTargetKeyName(ctx, req, targetKeyName)
if err != nil {
return nil, err
}

if len(clientNames) > 0 {
errorMessage := fmt.Sprintf("unable to delete key %q because it is currently referenced by these clients: %s",
targetKeyName, strings.Join(clientNames, ", "))
i.oidcLock.Unlock()
return logical.ErrorResponse(errorMessage), logical.ErrInvalidRequest
}

// key can safely be deleted now
err = req.Storage.Delete(ctx, namedKeyConfigPath+targetKeyName)
if err != nil {
Expand Down