Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.x] Jwt scope handling extended over array support #5573

Merged
merged 1 commit into from
Dec 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions security/jwt/src/main/java/io/helidon/security/jwt/JwtUtil.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2021 Oracle and/or its affiliates.
* Copyright (c) 2018, 2022 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -42,6 +42,7 @@
import javax.crypto.Mac;

import jakarta.json.Json;
import jakarta.json.JsonArray;
import jakarta.json.JsonBuilderFactory;
import jakarta.json.JsonNumber;
import jakarta.json.JsonObject;
Expand Down Expand Up @@ -309,8 +310,12 @@ static Optional<Address> toAddress(JsonObject json, String name) {
}

static Optional<List<String>> toScopes(JsonObject json) {
return getString(json, "scope")
.map(it -> Arrays.asList(it.split(" ")));
if (json.get("scope") instanceof JsonArray) {
return getStrings(json, "scope");
} else {
return getString(json, "scope")
.map(it -> Arrays.asList(it.split(" ")));
}
}

static Optional<ZoneId> toTimeZone(JsonObject json, String name) {
Expand Down