Skip to content

Commit

Permalink
graph: Make roleService optional again
Browse files Browse the repository at this point in the history
Allow to use the /graph/users and /graph/education/users endpoints standalone
without the RoleService running. When there is no Roleservice do not expose
the `/appRoleAssignments` endpoint.
  • Loading branch information
rhafer committed Feb 2, 2023
1 parent 82021dc commit ba761a0
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions services/graph/pkg/service/v0/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,7 @@ func NewService(opts ...Option) (Graph, error) {
svc.permissionsService = options.PermissionService
}

if options.RoleService == nil {
svc.roleService = settingssvc.NewRoleService("com.owncloud.api.settings", grpc.DefaultClient())
} else {
svc.roleService = options.RoleService
}
svc.roleService = options.RoleService

roleManager := options.RoleManager
if roleManager == nil {
Expand Down Expand Up @@ -201,11 +197,13 @@ func NewService(opts ...Option) (Graph, error) {
r.Get("/", svc.GetUser)
r.With(requireAdmin).Delete("/", svc.DeleteUser)
r.With(requireAdmin).Patch("/", svc.PatchUser)
r.With(requireAdmin).Route("/appRoleAssignments", func(r chi.Router) {
r.Get("/", svc.ListAppRoleAssignments)
r.Post("/", svc.CreateAppRoleAssignment)
r.Delete("/{appRoleAssignmentID}", svc.DeleteAppRoleAssignment)
})
if svc.roleService != nil {
r.With(requireAdmin).Route("/appRoleAssignments", func(r chi.Router) {
r.Get("/", svc.ListAppRoleAssignments)
r.Post("/", svc.CreateAppRoleAssignment)
r.Delete("/{appRoleAssignmentID}", svc.DeleteAppRoleAssignment)
})
}
})
})
r.Route("/groups", func(r chi.Router) {
Expand Down

0 comments on commit ba761a0

Please sign in to comment.