Skip to content

Commit

Permalink
Scopes string is incorrectly formed when required RequiredScopes is s… (
Browse files Browse the repository at this point in the history
#352)

* Scopes string is incorrectly formed when required RequiredScopes is specified
Co-authored-by: Tim Hess <[email protected]>
  • Loading branch information
macsux authored Jun 8, 2020
1 parent b381a7d commit 151f3d2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ internal List<KeyValuePair<string, string>> CommonTokenRequestParams()
var scopes = "openid " + _options.AdditionalTokenScopes;
if (_options.RequiredScopes != null)
{
scopes = string.Join(" ", scopes, _options.RequiredScopes);
scopes = scopes.Trim() + " " + string.Join(" ", _options.RequiredScopes);
}

return new List<KeyValuePair<string, string>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@ public void ClientCredentialsTokenRequestParameters_ReturnsCorrectly()
Assert.Equal(OpenIdConnectGrantTypes.ClientCredentials, parameters.First(i => i.Key == "grant_type").Value);
}

[Fact]
public void CommonTokenRequestParamsHandlesScopes()
{
// arrange
var opts = new AuthServerOptions { AdditionalTokenScopes = "onescope", RequiredScopes = new string[] { "twoscope" } };
var tEx = new TokenExchanger(opts);

// act
var parameters = tEx.CommonTokenRequestParams();
Assert.Equal("openid onescope twoscope", parameters.First(i => i.Key == CloudFoundryDefaults.ParamsScope).Value);
}

[Fact]
public async void ExchangeAuthCodeForClaimsIdentity_ExchangesCodeForIdentity()
{
Expand Down

0 comments on commit 151f3d2

Please sign in to comment.