You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by "coheigea (via GitHub)" <gi...@apache.org> on 2026/07/23 09:48:28 UTC
[PR] CXF-9223 - Improve prefix matching for OAuth audience URIs [cxf]
coheigea opened a new pull request, #3331:
URL: https://github.com/apache/cxf/pull/3331
(no comment)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@cxf.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CXF-9223 - Improve prefix matching for OAuth audience URIs [cxf]
Posted by "coheigea (via GitHub)" <gi...@apache.org>.
coheigea merged PR #3331:
URL: https://github.com/apache/cxf/pull/3331
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@cxf.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CXF-9223 - Improve prefix matching for OAuth audience URIs [cxf]
Posted by "coheigea (via GitHub)" <gi...@apache.org>.
coheigea commented on code in PR #3331:
URL: https://github.com/apache/cxf/pull/3331#discussion_r3637910470
##########
rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/filters/OAuthRequestFilter.java:
##########
@@ -295,6 +297,28 @@ protected String validateAudiences(List<String> audiences) {
return null;
}
+ /**
+ * Checks whether a configured audience matches a request URL using safe prefix semantics.
+ * <p>
+ * This keeps subtree-style matching (for example, "/api/read" matching "/api/read/item")
+ * but prevents same-prefix sibling matches (for example, "/api/readadmin").
+ * A match is accepted only when the configured audience is an exact match, ends with '/',
+ * or is followed by a URL boundary character ('/', '?', '#').
+ */
+ protected boolean matchesAudiencePrefix(String requestPath, String configuredAudience) {
+ if (requestPath == null || configuredAudience == null) {
+ return false;
+ }
+ if (!requestPath.startsWith(configuredAudience)) {
+ return false;
+ }
+ if (requestPath.length() == configuredAudience.length() || configuredAudience.endsWith("/")) {
Review Comment:
I don't think it is redundant. The startsWith check makes sure that the audience matches the start of the request URI. Then the next check is to make sure either they're equal or if it ends with a forward slash then we can accept the match.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@cxf.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CXF-9223 - Improve prefix matching for OAuth audience URIs [cxf]
Posted by "reta (via GitHub)" <gi...@apache.org>.
reta commented on code in PR #3331:
URL: https://github.com/apache/cxf/pull/3331#discussion_r3637833719
##########
rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/filters/OAuthRequestFilter.java:
##########
@@ -295,6 +297,28 @@ protected String validateAudiences(List<String> audiences) {
return null;
}
+ /**
+ * Checks whether a configured audience matches a request URL using safe prefix semantics.
+ * <p>
+ * This keeps subtree-style matching (for example, "/api/read" matching "/api/read/item")
+ * but prevents same-prefix sibling matches (for example, "/api/readadmin").
+ * A match is accepted only when the configured audience is an exact match, ends with '/',
+ * or is followed by a URL boundary character ('/', '?', '#').
+ */
+ protected boolean matchesAudiencePrefix(String requestPath, String configuredAudience) {
+ if (requestPath == null || configuredAudience == null) {
+ return false;
+ }
+ if (!requestPath.startsWith(configuredAudience)) {
+ return false;
+ }
+ if (requestPath.length() == configuredAudience.length() || configuredAudience.endsWith("/")) {
Review Comment:
```suggestion
if (configuredAudience.endsWith("/")) {
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@cxf.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CXF-9223 - Improve prefix matching for OAuth audience URIs [cxf]
Posted by "reta (via GitHub)" <gi...@apache.org>.
reta commented on code in PR #3331:
URL: https://github.com/apache/cxf/pull/3331#discussion_r3637827178
##########
rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/filters/OAuthRequestFilter.java:
##########
@@ -295,6 +297,28 @@ protected String validateAudiences(List<String> audiences) {
return null;
}
+ /**
+ * Checks whether a configured audience matches a request URL using safe prefix semantics.
+ * <p>
+ * This keeps subtree-style matching (for example, "/api/read" matching "/api/read/item")
+ * but prevents same-prefix sibling matches (for example, "/api/readadmin").
+ * A match is accepted only when the configured audience is an exact match, ends with '/',
+ * or is followed by a URL boundary character ('/', '?', '#').
+ */
+ protected boolean matchesAudiencePrefix(String requestPath, String configuredAudience) {
+ if (requestPath == null || configuredAudience == null) {
+ return false;
+ }
+ if (!requestPath.startsWith(configuredAudience)) {
+ return false;
+ }
+ if (requestPath.length() == configuredAudience.length() || configuredAudience.endsWith("/")) {
Review Comment:
I believe this specific condition is redundant;
```suggestion
if (requestPath.length() == configuredAudience.length()) {
```
it would match `requestPath.startsWith(configuredAudience)` exactly, right?
##########
rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/filters/OAuthRequestFilter.java:
##########
@@ -295,6 +297,28 @@ protected String validateAudiences(List<String> audiences) {
return null;
}
+ /**
+ * Checks whether a configured audience matches a request URL using safe prefix semantics.
+ * <p>
+ * This keeps subtree-style matching (for example, "/api/read" matching "/api/read/item")
+ * but prevents same-prefix sibling matches (for example, "/api/readadmin").
+ * A match is accepted only when the configured audience is an exact match, ends with '/',
+ * or is followed by a URL boundary character ('/', '?', '#').
+ */
+ protected boolean matchesAudiencePrefix(String requestPath, String configuredAudience) {
+ if (requestPath == null || configuredAudience == null) {
+ return false;
+ }
+ if (!requestPath.startsWith(configuredAudience)) {
+ return false;
+ }
+ if (requestPath.length() == configuredAudience.length() || configuredAudience.endsWith("/")) {
Review Comment:
I believe this specific condition is redundant;
```
if (requestPath.length() == configuredAudience.length()) {
```
it would match `requestPath.startsWith(configuredAudience)` exactly, right?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@cxf.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] CXF-9223 - Improve prefix matching for OAuth audience URIs [cxf]
Posted by "reta (via GitHub)" <gi...@apache.org>.
reta commented on code in PR #3331:
URL: https://github.com/apache/cxf/pull/3331#discussion_r3637944099
##########
rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/filters/OAuthRequestFilter.java:
##########
@@ -295,6 +297,28 @@ protected String validateAudiences(List<String> audiences) {
return null;
}
+ /**
+ * Checks whether a configured audience matches a request URL using safe prefix semantics.
+ * <p>
+ * This keeps subtree-style matching (for example, "/api/read" matching "/api/read/item")
+ * but prevents same-prefix sibling matches (for example, "/api/readadmin").
+ * A match is accepted only when the configured audience is an exact match, ends with '/',
+ * or is followed by a URL boundary character ('/', '?', '#').
+ */
+ protected boolean matchesAudiencePrefix(String requestPath, String configuredAudience) {
+ if (requestPath == null || configuredAudience == null) {
+ return false;
+ }
+ if (!requestPath.startsWith(configuredAudience)) {
+ return false;
+ }
+ if (requestPath.length() == configuredAudience.length() || configuredAudience.endsWith("/")) {
Review Comment:
Oh I see, basically `== equals` part
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@cxf.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org