对于任何不匹配的URL,Jetty ConstraintMapping?

问题描述 投票:1回答:1

我正在尝试使用ConstraintSecurityHandler来保护我的应用程序。到目前为止效果很好。但是,我想从中排除某些路径 - 特别是我希望任何以/api/开头的路径忽略常规安全/登录(使用API​​令牌保护它)。我喜欢类似的东西

/* (that doesn't match one of the below) Requires view role /api/* Skips security handler /admin/* Requires admin role

有没有一种简单的方法来实现这一目标?

security web-applications jetty embedded-jetty jetty-9
1个回答
1
投票

ConstraintSecurityHandler实现了Servlet规范的安全约束机制。

它只是一个受限制的路径列表。如果碰巧重叠则第一个约束获胜。

Servlet Spec约束没有从约束中“排除”路径的概念。

您可以尝试将/api/*实现为没有ConstraintMappingConstraint(没有角色,没有经过身份验证等)。

© www.soinside.com 2019 - 2024. All rights reserved.