0 Replies Latest reply on May 3, 2013 10:13 AM by Tobias W

    Problems with Errai authentication

    Tobias W Newbie

      Hi

       

      i'm trying to get Errai authentication to work. This is what I do:

       

      I add the following two lines to the ErraiService.properties:

      errai.authentication_adapter=com.mypackage.TestAuthenticationAdapter

      errai.require_authentication_for_all=true

       

      The TestAuthenticationAdapter is a custom class which implements org.jboss.errai.bus.server.security.auth.AuthenticationAdapter. According to the discussion https://community.jboss.org/thread/197641 I also subscribed to "LoginClient" subject when my Application entry point is initialized:

       

      ErraiBus.get().subscribe("LoginClient", new MessageCallback() {

       

                @Override

                public void callback(Message message) {

       

                          if (message.getCommandType().equals("FailedAuth")) {

                     // ..

                          } else if (message.getCommandType().equals("SuccessfulAuth")) {

                     // ..

                          } else {

                                         MessageBuilder.createConversation(message).subjectProvided().command(SecurityCommands.AuthRequest)

                                                                  .with(MessageParts.ReplyTo, "LoginClient").with(SecurityParts.Name, "test").with(SecurityParts.Password, "secret").done().reply();

                          }

                }

      });

       

      When I debug my application I see that TestAuthenticationAdapter is actually initialized by Errai, which is fine. The problem is that its challenge() method, which is meant to do the actual authentication work, is never called.

       

      Debugging Errai I don't understand how this is actually meant to be working. errai.require_authentication_for_all=true triggers org.jboss.errai.bus.server.service.bootstrap.AuthenticationRules to add a RolesRequiredRule (which should trigger the client callback, when authorization is needed) to org.jboss.errai.bus.server.ServerMessageBusImpl.subscriptions mapped by the subject "AuthorizationService". But I don't see any way how this rule is ever evaluated.

       

      What do I have to do to make this work? Unfortunately the documentation on Errai service-security is still a little meager.

       

      Tobias