Skip to content

Commit

Permalink
Merge pull request #273 from canonical/IAM-769
Browse files Browse the repository at this point in the history
IAM-769: add id validation to make sure it's never empty
  • Loading branch information
shipperizer authored Apr 12, 2024
2 parents 5a7ea8c + fc7d560 commit 6fc6d35
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 31 deletions.
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

0 comments on commit 6fc6d35

Please sign in to comment.