Skip to content

Commit ba8092f

Browse files
authored
Fixes #17506 (#17536)
Now the validation of ClientId has a max of 255 characters
1 parent 5c8d460 commit ba8092f

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

src/Umbraco.Cms.Api.Management/Controllers/User/ClientCredentials/ClientCredentialsUserControllerBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ protected IActionResult BackOfficeUserClientCredentialsOperationStatusResult(Bac
2020
.Build()),
2121
BackOfficeUserClientCredentialsOperationStatus.InvalidClientId => BadRequest(problemDetailsBuilder
2222
.WithTitle("Invalid client ID")
23-
.WithDetail("The specified client ID is invalid. A valid client ID can only contain [a-z], [A-Z], [0-9], and [-._~].")
23+
.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.")
2424
.Build()),
2525
_ => StatusCode(StatusCodes.Status500InternalServerError, problemDetailsBuilder
2626
.WithTitle("Unknown client credentials operation status.")

src/Umbraco.Core/Services/UserService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2677,7 +2677,7 @@ private static void AddAdditionalPermissions(ISet<string> assignedPermissions, I
26772677
}
26782678
}
26792679

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

26832683
#endregion

tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/UserServiceTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,6 +1004,7 @@ public async Task Can_Assign_ClientId_To_Api_User(UserKind userKind, UserClientC
10041004
[TestCase("@", UserClientCredentialsOperationStatus.InvalidClientId)]
10051005
[TestCase("[", UserClientCredentialsOperationStatus.InvalidClientId)]
10061006
[TestCase("]", UserClientCredentialsOperationStatus.InvalidClientId)]
1007+
[TestCase("More_Than_255_characters_012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", UserClientCredentialsOperationStatus.InvalidClientId)]
10071008
public async Task Can_Use_Only_Unreserved_Characters_For_ClientId(string clientId, UserClientCredentialsOperationStatus expectedResult)
10081009
{
10091010
// Arrange

0 commit comments

Comments
 (0)