allow hyphen in username (#731)

* allow hyphen in username

* remove extra escaping

---------

Co-authored-by: Enrice <erich.mauerboeck@ergo-versicherung.at>
This commit is contained in:
Erich Mauerböck 2023-11-03 15:36:02 +01:00 committed by GitHub
parent 13762eb67f
commit 428e898a7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 7 deletions

View File

@ -21,7 +21,7 @@ public class ValidationUtil {
private static Pattern ALPHANUMERIC_PATTERN = Pattern.compile("[a-zA-Z0-9_]+"); private static Pattern ALPHANUMERIC_PATTERN = Pattern.compile("[a-zA-Z0-9_]+");
private static Pattern USERNAME_PATTERN = Pattern.compile("[a-zA-Z0-9_@\\.]+"); private static Pattern USERNAME_PATTERN = Pattern.compile("[a-zA-Z0-9_@.-]+");
/** /**
* Checks that the argument is not null. * Checks that the argument is not null.

View File

@ -313,7 +313,7 @@ public class GroupResource extends BaseResource {
* @return Response * @return Response
*/ */
@DELETE @DELETE
@Path("{groupName: [a-zA-Z0-9_]+}/{username: [a-zA-Z0-9_@\\.]+}") @Path("{groupName: [a-zA-Z0-9_]+}/{username: [a-zA-Z0-9_@.-]+}")
public Response removeMember(@PathParam("groupName") String groupName, public Response removeMember(@PathParam("groupName") String groupName,
@PathParam("username") String username) { @PathParam("username") String username) {
if (!authenticate()) { if (!authenticate()) {

View File

@ -195,7 +195,7 @@ public class UserResource extends BaseResource {
* @return Response * @return Response
*/ */
@POST @POST
@Path("{username: [a-zA-Z0-9_@\\.]+}") @Path("{username: [a-zA-Z0-9_@.-]+}")
public Response update( public Response update(
@PathParam("username") String username, @PathParam("username") String username,
@FormParam("password") String password, @FormParam("password") String password,
@ -497,7 +497,7 @@ public class UserResource extends BaseResource {
* @return Response * @return Response
*/ */
@DELETE @DELETE
@Path("{username: [a-zA-Z0-9_@\\.]+}") @Path("{username: [a-zA-Z0-9_@.-]+}")
public Response delete(@PathParam("username") String username) { public Response delete(@PathParam("username") String username) {
if (!authenticate()) { if (!authenticate()) {
throw new ForbiddenClientException(); throw new ForbiddenClientException();
@ -563,7 +563,7 @@ public class UserResource extends BaseResource {
* @return Response * @return Response
*/ */
@POST @POST
@Path("{username: [a-zA-Z0-9_@\\.]+}/disable_totp") @Path("{username: [a-zA-Z0-9_@.-]+}/disable_totp")
public Response disableTotpUsername(@PathParam("username") String username) { public Response disableTotpUsername(@PathParam("username") String username) {
if (!authenticate()) { if (!authenticate()) {
throw new ForbiddenClientException(); throw new ForbiddenClientException();
@ -685,7 +685,7 @@ public class UserResource extends BaseResource {
* @return Response * @return Response
*/ */
@GET @GET
@Path("{username: [a-zA-Z0-9_@\\.]+}") @Path("{username: [a-zA-Z0-9_@.-]+}")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public Response view(@PathParam("username") String username) { public Response view(@PathParam("username") String username) {
if (!authenticate()) { if (!authenticate()) {

View File

@ -9,7 +9,7 @@
<label class="col-sm-2 control-label" for="inputUserUsername">{{ 'settings.user.edit.username' | translate }}</label> <label class="col-sm-2 control-label" for="inputUserUsername">{{ 'settings.user.edit.username' | translate }}</label>
<div class="col-sm-7"> <div class="col-sm-7">
<input name="userUsername" type="text" id="inputUserUsername" required ng-disabled="isEdit()" class="form-control" <input name="userUsername" type="text" id="inputUserUsername" required ng-disabled="isEdit()" class="form-control"
ng-pattern="/^[a-zA-Z0-9_@\.]*$/" ng-pattern="/^[a-zA-Z0-9_@.-]*$/"
ng-minlength="3" ng-maxlength="50" ng-attr-placeholder="{{ 'settings.user.edit.username' | translate }}" ng-model="user.username"/> ng-minlength="3" ng-maxlength="50" ng-attr-placeholder="{{ 'settings.user.edit.username' | translate }}" ng-model="user.username"/>
</div> </div>