简体   繁体   English

tomcat java web 应用程序的两因素身份验证

[英]Two-Factor Authentication for a tomcat java web application

I have implemented a simple java web application with tomcat realm authentication(Custom FORM authentication).我已经使用 tomcat 领域身份验证(自定义表单身份验证)实现了一个简单的 java web 应用程序。 Now, I'm trying to add a second authentication page for the user(two-factor authentication, I'm using Google authenticator).现在,我正在尝试为用户添加第二个身份验证页面(双因素身份验证,我使用的是 Google 身份验证器)。 As far as I have referred the Tomcat documentation, we can specify only one login-config.就我提到的 Tomcat 文档而言,我们只能指定一个 login-config。

I tried adding a filter and also tried managing whether the user has finished the Two-Factor authentication manually with session and tokens.我尝试添加过滤器,并尝试管理用户是否已使用会话和令牌手动完成双因素身份验证。

Is there a way to add the second authentication in the web.xml or the server.xml.有没有办法在 web.xml 或 server.xml 中添加第二个身份验证。 So, tomcat should handle whether the user has finished both the authentication.所以,tomcat 应该处理用户是否已经完成了两个认证。

Thanks in advance.提前致谢。

Tomcat only starts one login process. Tomcat 只启动一个登录过程。 That process may decide to ask the user for more than one credential but tomcat is not aware of it.该过程可能会决定向用户询问多个凭据,但 tomcat 并不知道。

So, you should create a filter and/or login servlet that handles authentication for the tomcat container.因此,您应该创建一个过滤器和/或登录 servlet 来处理 tomcat 容器的身份验证。 That filter/servlet (combination) must prompt for all desired credentials.该过滤器/servlet(组合)必须提示输入所有所需的凭据。

If you do not use a framework for your application that already has an authentication layer, you are essentially writing your own 2FA implementation.如果您没有为已经具有身份验证层的应用程序使用框架,那么您实际上是在编写自己的 2FA 实现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM