Skip to content

Commit 3bae786

Browse files
committed
Parse multiple roles as string
Even if the access token contains a string for the scopes or scp claims, and not an array, it might still contain multiple scopes separated by spaces. This was not handled by the current code. This commit splits strings like this into multiple scopes to handle the situation properly.
1 parent 8bf8fd7 commit 3bae786

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/jwk.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,9 @@ scopes_t parse_jwt_scopes(const picojson::value& jsonScopes) {
201201
return {scope_range.begin(), scope_range.end()};
202202
}
203203
if (jsonScopes.is<std::string>()) {
204-
return {jsonScopes.get<std::string>()};
204+
auto scope_range = jsonScopes.get<std::string>() | std::views::split(' ') |
205+
std::views::transform([](auto r) { return std::string(r.data(), r.size()); });
206+
return {scope_range.begin(), scope_range.end()};
205207
}
206208

207209
return {};

0 commit comments

Comments
 (0)