简体   繁体   English

一个Java Web应用程序中可以有两种认证机制吗?

[英]Is it possible to have two authentication mechanisms in one Java web application?

I have a web application that contains ui based on jsf 2.0 and a set of rest apis. 我有一个Web应用程序,其中包含基于jsf 2.0的ui和一组rest api。 The ui side of the application is accessed from a browser and rest apis are invoked from a mobile app. 可从浏览器访问应用程序的ui端,并从移动应用程序调用rest api。

For the authentication for the UI is managed by jsf , (no form nothing, jsf manages everything). 对于UI的身份验证是由jsf管理的(没有任何形式,jsf管理所有内容)。 Now, I want the user to be authenticated before he/she can access the rest apis. 现在,我希望用户能够通过身份验证,然后才能访问其余的api。

Can I set up the web application to have Basic authentication so that I can set the username and password in the header when calling the rest apis? 我可以将Web应用程序设置为具有基本身份验证,以便在调用其余api时可以在标头中设置用户名和密码吗?

You will need to have a security filter for your web application. 您将需要为您的Web应用程序设置一个安全筛选器。 (this can be done with spring security - Integrating Spring security with JSF 2 ) (这可以通过spring security实现- 将Spring security与JSF 2集成

The user will have to pass a username and password to your application. 用户必须将用户名和密码传递给您的应用程序。

Then, you just need to configure your rest api to work with basic authentication. 然后,您只需要配置rest api即可使用基本身份验证。 Since basic authentication is a HTTP feature, every time you call the rest service, you will need to pass the username/password in the request. 由于基本身份验证是HTTP功能,因此每次调用rest服务时,都需要在请求中传递用户名/密码。

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

相关问题 两种认证机制:Kerberos 和 HTTP basic - Two mechanisms of authentication: Kerberos and HTTP basic tomcat java web 应用程序的两因素身份验证 - Two-Factor Authentication for a tomcat java web application Java 没有任何导入别名机制,我有两个同名的导入语句 - Java doesn't have any import aliasing mechanisms, and I have two import statements with the same name Wildfly 8.2应用程序客户端身份验证“所有可用的身份验证机制均失败” - Wildfly 8.2 application client authentication “all available authentication mechanisms failed” JAVA Web应用程序中的LDAP身份验证 - LDAP authentication in JAVA web application Web应用程序中的NTLM身份验证(java) - NTLM Authentication in a Web Application (java) 是否可以将Azure AD身份验证与AWS中托管的基于Java的现有Web应用程序集成? - Possible option to integrate Azure AD authentication with existing Java based web application hosted in aws? 使用Java配置在单个应用程序中使用多种身份验证机制 - multiple authentication mechanisms in a single app using java config 向我的Web应用程序添加双因素身份验证 - Add two factor authentication to my web application 一个数据库,两个Web应用程序 - One database, two web application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM