Skip to content

Commit

Permalink
Fixes #17506 (#17536)
Browse files Browse the repository at this point in the history
Now the validation of ClientId has a max of 255 characters
  • Loading branch information
bergmania authored Nov 15, 2024
1 parent 5c8d460 commit ba8092f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ protected IActionResult BackOfficeUserClientCredentialsOperationStatusResult(Bac
.Build()),
BackOfficeUserClientCredentialsOperationStatus.InvalidClientId => BadRequest(problemDetailsBuilder
.WithTitle("Invalid client ID")
.WithDetail("The specified client ID is invalid. A valid client ID can only contain [a-z], [A-Z], [0-9], and [-._~].")
.WithDetail("The specified client ID is invalid. A valid client ID can only contain [a-z], [A-Z], [0-9], and [-._~]. Furthermore, including the prefix it cannot be longer than 255 characters.")
.Build()),
_ => StatusCode(StatusCodes.Status500InternalServerError, problemDetailsBuilder
.WithTitle("Unknown client credentials operation status.")
Expand Down
2 changes: 1 addition & 1 deletion src/Umbraco.Core/Services/UserService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2677,7 +2677,7 @@ private static void AddAdditionalPermissions(ISet<string> assignedPermissions, I
}
}

[GeneratedRegex(@"^[\w\d\-\._~]*$")]
[GeneratedRegex(@"^[\w\d\-\._~]{1,255}$")]
private static partial Regex ValidClientId();

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1004,6 +1004,7 @@ public async Task Can_Assign_ClientId_To_Api_User(UserKind userKind, UserClientC
[TestCase("@", UserClientCredentialsOperationStatus.InvalidClientId)]
[TestCase("[", UserClientCredentialsOperationStatus.InvalidClientId)]
[TestCase("]", UserClientCredentialsOperationStatus.InvalidClientId)]
[TestCase("More_Than_255_characters_012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", UserClientCredentialsOperationStatus.InvalidClientId)]
public async Task Can_Use_Only_Unreserved_Characters_For_ClientId(string clientId, UserClientCredentialsOperationStatus expectedResult)
{
// Arrange
Expand Down

0 comments on commit ba8092f

Please sign in to comment.