简体   繁体   English

在WildFly上的RESTful应用程序中进行身份验证

[英]Authentication in RESTful application on WildFly

I have two apps, server side is based on java with rest easy and client where I'm using angular js. 我有两个应用程序,服务器端基于Java,具有轻松易用性,而客户端则是我使用angular js的客户端。

I used basic authentication where I generated token in first request and all requests used this token, but since I moved project to Wildfly, and there is no Tomcat this way doesn't work. 我使用了基本身份验证,在该请求中我在第一个请求中生成了令牌,并且所有请求都使用了此令牌,但是由于我将项目移至Wildfly,并且没有Tomcat,因此这种方法行不通。

My class TokenAuthenticator extends BasicAuthenticator from Catalina; 我的类TokenAuthenticator扩展了Catalina的BasicAuthenticator

web.xml has: web.xml具有:

<login-config>
    <realm-name>App</realm-name>
</login-config>

<security-role>
    <role-name>user</role-name>
</security-role>

and jboss-web.xml : jboss-web.xml

<jboss-web>
    <security-domain>App</security-domain>
    <valve>
        <class-name>package.TokenAuthenticator</class-name>
    </valve>
    <context-root>/app-server</context-root>
</jboss-web>

In my EJB beans I'm using @RolesAllowed annotation to restrict access to resources. 在我的EJB bean中,我使用@RolesAllowed注释来限制对资源的访问。

I read that for now, Wildfly doesn't support valves. 我读到现在,Wildfly不支持阀门。

What is my the best alternative? 我最好的选择是什么?

I've changed my mind and implemented form based authentication, but answering on my previous question, I should write a ServletExtension which adds an AuthenticationMechanism to DeploymentInfo . 我已经改变主意并实现了基于表单的身份验证,但是要回答我的上一个问题,我应该编写一个ServletExtension ,它将AuthenticationMechanism添加到DeploymentInfo In AuthenticationMechanism , there is a authenticate() method, which authenticate users. AuthenticationMechanism ,存在一个authenticate()方法,该方法对用户进行身份验证。 You can find a bit info in Undertow documentation . 您可以在Undertow 文档中找到一些信息。

Probably (before final) they will allow configuration via XML. 可能(在最终之前)它们将允许通过XML进行配置。

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

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