quarkus - 如何发布基于表单的身份验证
问题描述
我正在尝试使基于表单的身份验证正常工作,并且在网络上仅发现 1 个引用表明 url 是 j_security_check 并且参数是 j_username 和 j_password。在任何 quarkus 文档中都没有提到这一点。
我是否遗漏了某些内容,或者文档是否缺少此关键信息?
谢谢
杰夫
解决方案
是的,您完全正确地认为缺乏这方面的文档,尽管如此,我还是整合了一些信息。
进行身份验证
创建一个执行 POST 的 HTML 表单/j_security_check
<form action="j_security_check" method="post">
<div class="container">
<label for="j_username"><b>Username</b></label>
<input type="text" placeholder="Enter Username" name="j_username" required>
<label for="j_password"><b>Password</b></label>
<input type="password" placeholder="Enter Password" name="j_password" required>
<button type="submit">Login</button>
</div>
</form>
卷曲示例
$ curl -i -X POST http://localhost:8080/j_security_check -d 'j_username=admin&j_password=admin'
HTTP/1.1 302 Found
location: http://localhost:8080/index.html
content-length: 0
set-cookie: quarkus-credential=DPeFtSios6kIpWpJw6BpCfId3+MT151H3yPOc5VzfYdrdO6oRcE+dy18IL0KMeFx; Path=/
登录机制参考
我没有找到任何其他解释登录步骤的文档,但我在 quarkus 源代码上做了一些 greps,发现这个文件似乎可以处理/j_security_check
端点,看起来还没有办法自定义这个路径或参数名称。此文件存在于依赖项上quarkus-vertx-http-1.10.5.Final.jar
public class FormAuthenticationMechanism implements HttpAuthenticationMechanism {
private static final Logger log = Logger.getLogger(FormAuthenticationMechanism.class);
public static final String DEFAULT_POST_LOCATION = "/j_security_check";
一个有趣的事实是,在undertow project也可以找到一个同名但具有更高级代码的文件,可以在那里自定义路径。
推荐阅读
- javascript - 笑话:如何正确模拟节点模块?
- executable - 如何在 QNX SPD 7.0 目标上执行二进制文件
- xml - XSLT 1.0 Group by / distinct xml 节点值
- amazon-ec2 - 通过 terraform 终止 EC2 实例时删除 EBS 卷
- python-3.x - 检查python selenium中是否存在元素
- javascript - 跨域的 cookie 问题
- javascript - bootstrap-vue Form File Upload没有样式,但是其他组件有?
- db2 - 我们可以使用 sqlcmd 实用程序从 unix-putty 连接到远程 IBM Infomix 服务器吗?
- sql - 在 Sql Server 中格式化电话号码
- php - PHP:找到“最合适的”