Skip to content

Commit

Permalink
feat: allow listing identities by organization ID
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas-jonas committed Sep 12, 2024
1 parent f7c1024 commit 5cfbf66
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 0 deletions.
7 changes: 7 additions & 0 deletions identity/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@ type listIdentitiesParameters struct {
// in: query
DeclassifyCredentials []string `json:"include_credential"`

// OrganizationID is the organization id to filter identities by.
//
// If `ids` is set, this parameter is ignored.
// required: false
OrganizationID string `json:"organization_id"`

crdbx.ConsistencyRequestParameters
}

Expand Down Expand Up @@ -211,6 +217,7 @@ func (h *Handler) list(w http.ResponseWriter, r *http.Request, _ httprouter.Para
IdsFilter: r.URL.Query()["ids"],
CredentialsIdentifier: r.URL.Query().Get("credentials_identifier"),
CredentialsIdentifierSimilar: r.URL.Query().Get("preview_credentials_identifier_similar"),
OrganizationID: x.ParseUUID(r.URL.Query().Get("organization_id")),
ConsistencyLevel: crdbx.ConsistencyLevelFromRequest(r),
DeclassifyCredentials: declassify,
}
Expand Down
1 change: 1 addition & 0 deletions identity/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type (
CredentialsIdentifierSimilar string
DeclassifyCredentials []CredentialsType
KeySetPagination []keysetpagination.Option
OrganizationID uuid.UUID
// DEPRECATED
PagePagination *x.Page
ConsistencyLevel crdbx.ConsistencyLevel
Expand Down
8 changes: 8 additions & 0 deletions internal/client-go/api_identity.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions internal/httpclient/api_identity.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions persistence/sql/identity/persister_identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,11 @@ func (p *IdentityPersister) ListIdentities(ctx context.Context, params identity.
AND identities.id in (?)
`
args = append(args, params.IdsFilter)
} else if !params.OrganizationID.IsNil() {
wheres += `
AND identities.organization_id = ?
`
args = append(args, params.OrganizationID.String())

Check warning on line 866 in persistence/sql/identity/persister_identity.go

View check run for this annotation

Codecov / codecov/patch

persistence/sql/identity/persister_identity.go#L863-L866

Added lines #L863 - L866 were not covered by tests
}

query := fmt.Sprintf(`
Expand Down
8 changes: 8 additions & 0 deletions spec/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -4032,6 +4032,14 @@
},
"type": "array"
}
},
{
"description": "OrganizationID is the organization id to filter identities by.\n\nIf `ids` is set, this parameter is ignored.",
"in": "query",
"name": "organization_id",
"schema": {
"type": "string"
}
}
],
"responses": {
Expand Down
6 changes: 6 additions & 0 deletions spec/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,12 @@
"description": "Include Credentials in Response\n\nInclude any credential, for example `password` or `oidc`, in the response. When set to `oidc`, This will return\nthe initial OAuth 2.0 Access Token, OAuth 2.0 Refresh Token and the OpenID Connect ID Token if available.",
"name": "include_credential",
"in": "query"
},
{
"type": "string",
"description": "OrganizationID is the organization id to filter identities by.\n\nIf `ids` is set, this parameter is ignored.",
"name": "organization_id",
"in": "query"
}
],
"responses": {
Expand Down

0 comments on commit 5cfbf66

Please sign in to comment.