-
Notifications
You must be signed in to change notification settings - Fork 611
NMS-20106: versioned user management API and PrimeVue Manage Users page #8713
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
Open
joseanesONMS
wants to merge
14
commits into
develop
Choose a base branch
from
jira/NMS-20106-manage-users-primevue
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 8 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
03147ef
NMS-20106: versioned user management API and PrimeVue Manage Users page
joseanesONMS e669680
NMS-20106: validation, atomic updates, and tests for the users API
joseanesONMS 57abe65
NMS-20106: duty schedule runtime semantics, clearable fields, and help
joseanesONMS 62be7fd
NMS-20106: validate user fields inline and surface API errors in the …
joseanesONMS fe26ac8
NMS-20106: close review findings on the users API and editor
joseanesONMS a166426
NMS-20106: follow the Manage Users menu entry to the new page in Menu…
joseanesONMS a823b51
NMS-20106: use @opennms/onms-ui wrappers on the Manage Users page
joseanesONMS fe58b32
NMS-20106: address review — route dialog sizing through the OnmsDialo…
joseanesONMS f1e27d0
NMS-20106: carry on-call role supervisor across user rename
joseanesONMS 9a8ac40
NMS-20106: bring Manage Users dialogs onto the current onms-ui seam
joseanesONMS efe0d57
NMS-20106: make the v2 users API pure camelCase JSON
joseanesONMS 7d0bf5f
NMS-20106: finish camelCase column fields on the users table
joseanesONMS 6096878
NMS-20106: adopt the Info-dialog help and overflow-menu row actions
joseanesONMS 601d33c
NMS-20106: point the Manage Users menu entry to the Vue page in the d…
joseanesONMS File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
527 changes: 527 additions & 0 deletions
527
opennms-webapp-rest/src/main/java/org/opennms/web/rest/v2/UsersRestService.java
Large diffs are not rendered by default.
Oops, something went wrong.
97 changes: 97 additions & 0 deletions
97
opennms-webapp-rest/src/main/java/org/opennms/web/rest/v2/api/UsersRestApi.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| /* | ||
| * Licensed to The OpenNMS Group, Inc (TOG) under one or more | ||
| * contributor license agreements. See the LICENSE.md file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. | ||
| * | ||
| * TOG licenses this file to You under the GNU Affero General | ||
| * Public License Version 3 (the "License") or (at your option) | ||
| * any later version. You may not use this file except in | ||
| * compliance with the License. You may obtain a copy of the | ||
| * License at: | ||
| * | ||
| * https://www.gnu.org/licenses/agpl-3.0.txt | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | ||
| * either express or implied. See the License for the specific | ||
| * language governing permissions and limitations under the | ||
| * License. | ||
| */ | ||
| package org.opennms.web.rest.v2.api; | ||
|
|
||
| import javax.ws.rs.Consumes; | ||
| import javax.ws.rs.DELETE; | ||
| import javax.ws.rs.GET; | ||
| import javax.ws.rs.POST; | ||
| import javax.ws.rs.PUT; | ||
| import javax.ws.rs.Path; | ||
| import javax.ws.rs.PathParam; | ||
| import javax.ws.rs.Produces; | ||
| import javax.ws.rs.core.Context; | ||
| import javax.ws.rs.core.MediaType; | ||
| import javax.ws.rs.core.Response; | ||
| import javax.ws.rs.core.SecurityContext; | ||
|
|
||
| import org.opennms.web.rest.v2.model.UserDto; | ||
| import org.opennms.web.rest.v2.model.UserPasswordRequest; | ||
| import org.opennms.web.rest.v2.model.UserRenameRequest; | ||
| import org.opennms.web.rest.v2.model.UserWriteRequest; | ||
|
|
||
| import io.swagger.v3.oas.annotations.Operation; | ||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||
|
|
||
| /** | ||
| * Versioned user management API backed by users.xml. Password hashes are | ||
| * never returned; admin-only (enforced by Spring Security and in-code). | ||
| */ | ||
| @Path("users") | ||
| @Tag(name = "Users", description = "User Management API") | ||
| public interface UsersRestApi { | ||
|
|
||
| @GET | ||
| @Produces(MediaType.APPLICATION_JSON) | ||
| @Operation(summary = "List all users", operationId = "listUsers") | ||
| Response listUsers(@Context SecurityContext securityContext); | ||
|
|
||
| @GET | ||
| @Path("{userId}") | ||
| @Produces(MediaType.APPLICATION_JSON) | ||
| @Operation(summary = "Get one user", operationId = "getUser") | ||
| Response getUser(@Context SecurityContext securityContext, @PathParam("userId") String userId); | ||
|
|
||
| @GET | ||
| @Path("available-roles") | ||
| @Produces(MediaType.APPLICATION_JSON) | ||
| @Operation(summary = "List the assignable security roles", operationId = "listAvailableRoles") | ||
| Response listAvailableRoles(@Context SecurityContext securityContext); | ||
|
|
||
| @POST | ||
| @Consumes(MediaType.APPLICATION_JSON) | ||
| @Operation(summary = "Create a user", operationId = "createUser") | ||
| Response createUser(@Context SecurityContext securityContext, UserWriteRequest request); | ||
|
|
||
| @PUT | ||
| @Path("{userId}") | ||
| @Consumes(MediaType.APPLICATION_JSON) | ||
| @Operation(summary = "Update a user's details (contact types and password not covered here are preserved)", operationId = "updateUser") | ||
| Response updateUser(@Context SecurityContext securityContext, @PathParam("userId") String userId, UserDto user); | ||
|
|
||
| @PUT | ||
| @Path("{userId}/password") | ||
| @Consumes(MediaType.APPLICATION_JSON) | ||
| @Operation(summary = "Set a user's password (stored salted)", operationId = "setUserPassword") | ||
| Response setPassword(@Context SecurityContext securityContext, @PathParam("userId") String userId, UserPasswordRequest request); | ||
|
|
||
| @POST | ||
| @Path("{userId}/rename") | ||
| @Consumes(MediaType.APPLICATION_JSON) | ||
| @Operation(summary = "Rename a user (also updates group memberships)", operationId = "renameUser") | ||
| Response renameUser(@Context SecurityContext securityContext, @PathParam("userId") String userId, UserRenameRequest request); | ||
|
|
||
| @DELETE | ||
| @Path("{userId}") | ||
| @Operation(summary = "Delete a user (also removes group memberships; admin and rtc are protected)", operationId = "deleteUser") | ||
| Response deleteUser(@Context SecurityContext securityContext, @PathParam("userId") String userId); | ||
| } |
152 changes: 152 additions & 0 deletions
152
opennms-webapp-rest/src/main/java/org/opennms/web/rest/v2/model/UserDto.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,152 @@ | ||
| /* | ||
| * Licensed to The OpenNMS Group, Inc (TOG) under one or more | ||
| * contributor license agreements. See the LICENSE.md file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. | ||
| * | ||
| * TOG licenses this file to You under the GNU Affero General | ||
| * Public License Version 3 (the "License") or (at your option) | ||
| * any later version. You may not use this file except in | ||
| * compliance with the License. You may obtain a copy of the | ||
| * License at: | ||
| * | ||
| * https://www.gnu.org/licenses/agpl-3.0.txt | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | ||
| * either express or implied. See the License for the specific | ||
| * language governing permissions and limitations under the | ||
| * License. | ||
| */ | ||
| package org.opennms.web.rest.v2.model; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import javax.xml.bind.annotation.XmlAccessType; | ||
| import javax.xml.bind.annotation.XmlAccessorType; | ||
| import javax.xml.bind.annotation.XmlElement; | ||
| import javax.xml.bind.annotation.XmlRootElement; | ||
|
|
||
| /** | ||
| * A user as exposed by the v2 user management API. Field names mirror | ||
| * users.xml where they overlap; the password hash is deliberately never part | ||
| * of this representation, and contact types the API does not expose (XMPP, | ||
| * microblog, phones, pager PINs) are preserved server-side on update. | ||
| */ | ||
| @XmlRootElement(name = "user") | ||
| @XmlAccessorType(XmlAccessType.FIELD) | ||
| public class UserDto { | ||
|
|
||
| @XmlElement(name = "user-id") | ||
| private String userId; | ||
|
|
||
| @XmlElement(name = "full-name") | ||
| private String fullName; | ||
|
|
||
| @XmlElement(name = "user-comments") | ||
| private String userComments; | ||
|
|
||
| @XmlElement(name = "email") | ||
| private String email; | ||
|
|
||
| @XmlElement(name = "pager-email") | ||
| private String pagerEmail; | ||
|
|
||
| @XmlElement(name = "tui-pin") | ||
| private String tuiPin; | ||
|
|
||
| @XmlElement(name = "time-zone-id") | ||
| private String timeZoneId; | ||
|
|
||
| // null (not empty) defaults: a request body that omits these keys | ||
| // deserializes to null, which update semantics treat as "preserve" | ||
| @XmlElement(name = "duty-schedule") | ||
| private List<String> dutySchedules; | ||
|
|
||
| @XmlElement(name = "role") | ||
| private List<String> roles; | ||
|
|
||
| @XmlElement(name = "read-only") | ||
| private Boolean readOnly; | ||
|
|
||
| public String getUserId() { | ||
| return userId; | ||
| } | ||
|
|
||
| public void setUserId(final String userId) { | ||
| this.userId = userId; | ||
| } | ||
|
|
||
| public String getFullName() { | ||
| return fullName; | ||
| } | ||
|
|
||
| public void setFullName(final String fullName) { | ||
| this.fullName = fullName; | ||
| } | ||
|
|
||
| public String getUserComments() { | ||
| return userComments; | ||
| } | ||
|
|
||
| public void setUserComments(final String userComments) { | ||
| this.userComments = userComments; | ||
| } | ||
|
|
||
| public String getEmail() { | ||
| return email; | ||
| } | ||
|
|
||
| public void setEmail(final String email) { | ||
| this.email = email; | ||
| } | ||
|
|
||
| public String getPagerEmail() { | ||
| return pagerEmail; | ||
| } | ||
|
|
||
| public void setPagerEmail(final String pagerEmail) { | ||
| this.pagerEmail = pagerEmail; | ||
| } | ||
|
|
||
| public String getTuiPin() { | ||
| return tuiPin; | ||
| } | ||
|
|
||
| public void setTuiPin(final String tuiPin) { | ||
| this.tuiPin = tuiPin; | ||
| } | ||
|
|
||
| public String getTimeZoneId() { | ||
| return timeZoneId; | ||
| } | ||
|
|
||
| public void setTimeZoneId(final String timeZoneId) { | ||
| this.timeZoneId = timeZoneId; | ||
| } | ||
|
|
||
| public List<String> getDutySchedules() { | ||
| return dutySchedules; | ||
| } | ||
|
|
||
| public void setDutySchedules(final List<String> dutySchedules) { | ||
| this.dutySchedules = dutySchedules; | ||
| } | ||
|
|
||
| public List<String> getRoles() { | ||
| return roles; | ||
| } | ||
|
|
||
| public void setRoles(final List<String> roles) { | ||
| this.roles = roles; | ||
| } | ||
|
|
||
| public Boolean getReadOnly() { | ||
| return readOnly; | ||
| } | ||
|
|
||
| public void setReadOnly(final Boolean readOnly) { | ||
| this.readOnly = readOnly; | ||
| } | ||
| } | ||
43 changes: 43 additions & 0 deletions
43
opennms-webapp-rest/src/main/java/org/opennms/web/rest/v2/model/UserPasswordRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| /* | ||
| * Licensed to The OpenNMS Group, Inc (TOG) under one or more | ||
| * contributor license agreements. See the LICENSE.md file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. | ||
| * | ||
| * TOG licenses this file to You under the GNU Affero General | ||
| * Public License Version 3 (the "License") or (at your option) | ||
| * any later version. You may not use this file except in | ||
| * compliance with the License. You may obtain a copy of the | ||
| * License at: | ||
| * | ||
| * https://www.gnu.org/licenses/agpl-3.0.txt | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | ||
| * either express or implied. See the License for the specific | ||
| * language governing permissions and limitations under the | ||
| * License. | ||
| */ | ||
| package org.opennms.web.rest.v2.model; | ||
|
|
||
| import javax.xml.bind.annotation.XmlAccessType; | ||
| import javax.xml.bind.annotation.XmlAccessorType; | ||
| import javax.xml.bind.annotation.XmlElement; | ||
| import javax.xml.bind.annotation.XmlRootElement; | ||
|
|
||
| @XmlRootElement(name = "user-password-request") | ||
| @XmlAccessorType(XmlAccessType.FIELD) | ||
|
synqotik marked this conversation as resolved.
Outdated
|
||
| public class UserPasswordRequest { | ||
|
|
||
| @XmlElement(name = "password") | ||
| private String password; | ||
|
|
||
| public String getPassword() { | ||
| return password; | ||
| } | ||
|
|
||
| public void setPassword(final String password) { | ||
| this.password = password; | ||
| } | ||
| } | ||
43 changes: 43 additions & 0 deletions
43
opennms-webapp-rest/src/main/java/org/opennms/web/rest/v2/model/UserRenameRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| /* | ||
| * Licensed to The OpenNMS Group, Inc (TOG) under one or more | ||
| * contributor license agreements. See the LICENSE.md file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. | ||
| * | ||
| * TOG licenses this file to You under the GNU Affero General | ||
| * Public License Version 3 (the "License") or (at your option) | ||
| * any later version. You may not use this file except in | ||
| * compliance with the License. You may obtain a copy of the | ||
| * License at: | ||
| * | ||
| * https://www.gnu.org/licenses/agpl-3.0.txt | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | ||
| * either express or implied. See the License for the specific | ||
| * language governing permissions and limitations under the | ||
| * License. | ||
| */ | ||
| package org.opennms.web.rest.v2.model; | ||
|
|
||
| import javax.xml.bind.annotation.XmlAccessType; | ||
| import javax.xml.bind.annotation.XmlAccessorType; | ||
| import javax.xml.bind.annotation.XmlElement; | ||
| import javax.xml.bind.annotation.XmlRootElement; | ||
|
|
||
| @XmlRootElement(name = "user-rename-request") | ||
| @XmlAccessorType(XmlAccessType.FIELD) | ||
| public class UserRenameRequest { | ||
|
|
||
| @XmlElement(name = "new-user-id") | ||
| private String newUserId; | ||
|
|
||
| public String getNewUserId() { | ||
| return newUserId; | ||
| } | ||
|
|
||
| public void setNewUserId(final String newUserId) { | ||
| this.newUserId = newUserId; | ||
| } | ||
| } |
49 changes: 49 additions & 0 deletions
49
opennms-webapp-rest/src/main/java/org/opennms/web/rest/v2/model/UserWriteRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| /* | ||
| * Licensed to The OpenNMS Group, Inc (TOG) under one or more | ||
| * contributor license agreements. See the LICENSE.md file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. | ||
| * | ||
| * TOG licenses this file to You under the GNU Affero General | ||
| * Public License Version 3 (the "License") or (at your option) | ||
| * any later version. You may not use this file except in | ||
| * compliance with the License. You may obtain a copy of the | ||
| * License at: | ||
| * | ||
| * https://www.gnu.org/licenses/agpl-3.0.txt | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | ||
| * either express or implied. See the License for the specific | ||
| * language governing permissions and limitations under the | ||
| * License. | ||
| */ | ||
| package org.opennms.web.rest.v2.model; | ||
|
|
||
| import javax.xml.bind.annotation.XmlAccessType; | ||
| import javax.xml.bind.annotation.XmlAccessorType; | ||
| import javax.xml.bind.annotation.XmlElement; | ||
| import javax.xml.bind.annotation.XmlRootElement; | ||
|
|
||
| /** | ||
| * Create request for the v2 user management API: the UserDto fields plus the | ||
| * initial password, which is hashed (salted) before it reaches users.xml. | ||
| * Password changes on existing users go through the dedicated password | ||
| * endpoint instead. | ||
| */ | ||
| @XmlRootElement(name = "user-create-request") | ||
| @XmlAccessorType(XmlAccessType.FIELD) | ||
| public class UserWriteRequest extends UserDto { | ||
|
|
||
| @XmlElement(name = "password") | ||
| private String password; | ||
|
|
||
| public String getPassword() { | ||
| return password; | ||
| } | ||
|
|
||
| public void setPassword(final String password) { | ||
| this.password = password; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.