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

IAM-769: add id validation to make sure it's never empty #273

Merged
merged 1 commit into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pkg/clients/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ type PaginationLinksResponse struct {
func (a *API) RegisterEndpoints(mux *chi.Mux) {
mux.Get("/api/v0/clients", a.ListClients)
mux.Post("/api/v0/clients", a.CreateClient)
mux.Get("/api/v0/clients/{id}", a.GetClient)
mux.Put("/api/v0/clients/{id}", a.UpdateClient)
mux.Delete("/api/v0/clients/{id}", a.DeleteClient)
mux.Get("/api/v0/clients/{id:.+}", a.GetClient)
mux.Put("/api/v0/clients/{id:.+}", a.UpdateClient)
mux.Delete("/api/v0/clients/{id:.+}", a.DeleteClient)
}

func (a *API) RegisterValidation(v validation.ValidationRegistryInterface) {
Expand Down
24 changes: 12 additions & 12 deletions pkg/groups/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,19 @@ type API struct {
// RegisterEndpoints hooks up all the endpoints to the server mux passed via the arg
func (a *API) RegisterEndpoints(mux *chi.Mux) {
mux.Get("/api/v0/groups", a.handleList)
mux.Get("/api/v0/groups/{id}", a.handleDetail)
mux.Get("/api/v0/groups/{id:.+}", a.handleDetail)
mux.Post("/api/v0/groups", a.handleCreate)
mux.Patch("/api/v0/groups/{id}", a.handleUpdate)
mux.Delete("/api/v0/groups/{id}", a.handleRemove)
mux.Get("/api/v0/groups/{id}/roles", a.handleListRoles)
mux.Post("/api/v0/groups/{id}/roles", a.handleAssignRoles)
mux.Delete("/api/v0/groups/{id}/roles/{r_id}", a.handleRemoveRole)
mux.Get("/api/v0/groups/{id}/entitlements", a.handleListPermission)
mux.Patch("/api/v0/groups/{id}/entitlements", a.handleAssignPermission)
mux.Delete("/api/v0/groups/{id}/entitlements/{e_id}", a.handleRemovePermission)
mux.Get("/api/v0/groups/{id}/identities", a.handleListIdentities)
mux.Patch("/api/v0/groups/{id}/identities", a.handleAssignIdentities)
mux.Delete("/api/v0/groups/{id}/identities/{i_id}", a.handleRemoveIdentities)
mux.Patch("/api/v0/groups/{id:.+}", a.handleUpdate)
mux.Delete("/api/v0/groups/{id:.+}", a.handleRemove)
mux.Get("/api/v0/groups/{id:.+}/roles", a.handleListRoles)
mux.Post("/api/v0/groups/{id:.+}/roles", a.handleAssignRoles)
mux.Delete("/api/v0/groups/{id:.+}/roles/{r_id:.+}", a.handleRemoveRole)
mux.Get("/api/v0/groups/{id:.+}/entitlements", a.handleListPermission)
mux.Patch("/api/v0/groups/{id:.+}/entitlements", a.handleAssignPermission)
mux.Delete("/api/v0/groups/{id:.+}/entitlements/{e_id:.+}", a.handleRemovePermission)
mux.Get("/api/v0/groups/{id:.+}/identities", a.handleListIdentities)
mux.Patch("/api/v0/groups/{id:.+}/identities", a.handleAssignIdentities)
mux.Delete("/api/v0/groups/{id:.+}/identities/{i_id:.+}", a.handleRemoveIdentities)
}

func (a *API) RegisterValidation(v validation.ValidationRegistryInterface) {
Expand Down
12 changes: 6 additions & 6 deletions pkg/identities/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ type API struct {

func (a *API) RegisterEndpoints(mux *chi.Mux) {
mux.Get("/api/v0/identities", a.handleList)
mux.Get("/api/v0/identities/{id}", a.handleDetail)
mux.Get("/api/v0/identities/{id:.+}", a.handleDetail)
mux.Post("/api/v0/identities", a.handleCreate)
mux.Put("/api/v0/identities/{id}", a.handleUpdate)
// mux.Patch("/api/v0/identities/{id}", a.handlePartialUpdate)
mux.Delete("/api/v0/identities/{id}", a.handleRemove)
// mux.Delete("/api/v0/identities/{id}/sessions", a.handleSessionRemove)
// mux.Delete("/api/v0/identities/{id}/credentials/{type}", a.handleCrededntialRemove)
mux.Put("/api/v0/identities/{id:.+}", a.handleUpdate)
// mux.Patch("/api/v0/identities/{id:.+}", a.handlePartialUpdate)
mux.Delete("/api/v0/identities/{id:.+}", a.handleRemove)
// mux.Delete("/api/v0/identities/{id:.+}/sessions", a.handleSessionRemove)
// mux.Delete("/api/v0/identities/{id:.+}/credentials/{type}", a.handleCrededntialRemove)
}

func (a *API) RegisterValidation(v validation.ValidationRegistryInterface) {
Expand Down
14 changes: 7 additions & 7 deletions pkg/roles/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ type API struct {
// RegisterEndpoints hooks up all the endpoints to the server mux passed via the arg
func (a *API) RegisterEndpoints(mux *chi.Mux) {
mux.Get("/api/v0/roles", a.handleList)
mux.Get("/api/v0/roles/{id}", a.handleDetail)
mux.Get("/api/v0/roles/{id:.+}", a.handleDetail)
mux.Post("/api/v0/roles", a.handleCreate)
mux.Patch("/api/v0/roles/{id}", a.handleUpdate)
mux.Delete("/api/v0/roles/{id}", a.handleRemove)
mux.Get("/api/v0/roles/{id}/entitlements", a.handleListPermission)
mux.Patch("/api/v0/roles/{id}/entitlements", a.handleAssignPermission) // this can only work for assignment unless payload includes add and remove
mux.Delete("/api/v0/roles/{id}/entitlements/{e_id}", a.handleRemovePermission)
mux.Get("/api/v0/roles/{id}/groups", a.handleListRoleGroup)
mux.Patch("/api/v0/roles/{id:.+}", a.handleUpdate)
mux.Delete("/api/v0/roles/{id:.+}", a.handleRemove)
mux.Get("/api/v0/roles/{id:.+}/entitlements", a.handleListPermission)
mux.Patch("/api/v0/roles/{id:.+}/entitlements", a.handleAssignPermission) // this can only work for assignment unless payload includes add and remove
mux.Delete("/api/v0/roles/{id:.+}/entitlements/{e_id:.+}", a.handleRemovePermission)
mux.Get("/api/v0/roles/{id:.+}/groups", a.handleListRoleGroup)
}
func (a *API) RegisterValidation(v validation.ValidationRegistryInterface) {
err := v.RegisterValidatingFunc("roles", a.validatingFunc)
Expand Down
6 changes: 3 additions & 3 deletions pkg/rules/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ type API struct {

func (a *API) RegisterEndpoints(mux *chi.Mux) {
mux.Get("/api/v0/rules", a.handleList)
mux.Get("/api/v0/rules/{id}", a.handleDetail)
mux.Get("/api/v0/rules/{id:.+}", a.handleDetail)
mux.Post("/api/v0/rules", a.handleCreate)
mux.Put("/api/v0/rules/{id}", a.handleUpdate)
mux.Delete("/api/v0/rules/{id}", a.handleRemove)
mux.Put("/api/v0/rules/{id:.+}", a.handleUpdate)
mux.Delete("/api/v0/rules/{id:.+}", a.handleRemove)
}

func (a *API) RegisterValidation(v validation.ValidationRegistryInterface) {
Expand Down
Loading