-
1. Re: Request authentication from servlet filter in Elytron
mayerw01 Feb 8, 2019 6:19 AM (in response to gersonjohan)1 of 1 people found this helpfulThe login could be done via the HttpServletRequest like:
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException {
request.login(username, password);
...
You should mention the security-domain in your jboss-web.xml like
<jboss-web>
...
<security-domain>mySecurityDomain</security-domain>
...
</jboss-web>
-
2. Re: Request authentication from servlet filter in Elytron
gersonjohan Feb 10, 2019 10:34 PM (in response to mayerw01)Hi Mayer,
I followed your recommendations and it did not work. The login method is invoked without problems, but in a next invokation to de ejb sever (via @EJB injection), I get the exception "EJBAccessException: WFLYEJB0364: Invocation on method ... is not allowed." It seems that the authentication against the server is not carried out.
On the other hand, how would authentication be done in case of being in a non-web context, such as a task scheduled with @Schedule, which I did in the same way with LoginContext.login?
Thank you
-
3. Re: Request authentication from servlet filter in Elytron
mayerw01 Feb 11, 2019 5:22 AM (in response to gersonjohan)WildFly (Elytron) uses the standard EJB security annotations. So you should make sure that your user has a role assigned which is allowed via the
@RolesAllowed annotation like:
@Stateless
@RolesAllowed({"admin"})
public class HelloBean {
...
On the other hand, how would authentication be done in case of being in a non-web context, such as a task scheduled with @Schedule, which I did in the same way with LoginContext.login?
You could use the @RunAs annotation to "simulate" some login.
But I'd suggest to look also into the JavaEE tutorial and the 'quickstart' (GitHub - wildfly/quickstart: Holds all versioned WildFly quickstarts )
-
4. Re: Request authentication from servlet filter in Elytron
gersonjohan Feb 13, 2019 7:38 PM (in response to mayerw01)Thank you Mayer,
It worked. I forgot enable this property in EJB:
<default-missing-method-permissions-deny-access value="false"/>