2016-05-24 10 views
0

Ich migriere eine große Web-App von jboss als 6 zu Wildfly 9, und stieß auf ein paar Hindernisse auf dem Weg.Wildfly 9 Sicherheitsdomänen werden nicht funktionieren

Einer von ihnen ist die Sicherheitsdomäne.

Der relevante Teil des standalone.xml ist wie folgt: ist

<subsystem xmlns="urn:jboss:domain:security:1.2"> 
    <security-domains> 
     <security-domain name="other" cache-type="default"> 
      <authentication> 
       <login-module code="Remoting" flag="optional"> 
        <module-option name="password-stacking" value="useFirstPass"/> 
       </login-module> 
       <login-module code="RealmDirect" flag="required"> 
        <module-option name="password-stacking" value="useFirstPass"/> 
       </login-module> 
      </authentication> 
     </security-domain> 
     <security-domain name="jboss-web-policy" cache-type="default"> 
      <authorization> 
       <policy-module code="Delegating" flag="required"/> 
      </authorization> 
     </security-domain> 
     <security-domain name="jboss-ejb-policy" cache-type="default"> 
      <authorization> 
       <policy-module code="Delegating" flag="required"/> 
      </authorization> 
     </security-domain> 
     <security-domain name="mydomain" cache-type="default"> 
      <authentication> 
       <login-module code="foo.token.LoginModule" flag="required"> 
        <module-option name="hashAlgorithm" value="SHA-512"/> 
        <module-option name="hashEncoding" value="base64"/> 
        <module-option name="unauthenticatedIdentity" value="guest"/> 
        <module-option name="dsJndiName" value="jdbc/fooDS"/> 
        <module-option name="principalsQuery" value="select ..."/> 
        <module-option name="rolesQuery" value="select o.name, 'Roles' from roles up join ef_usuario ..."/> 
       </login-module> 
      </authentication> 
     </security-domain> 
    </security-domains> 
</subsystem> 

Die foo.token.LoginModule.java etwas wie folgt aus:

@NoArgsConstructor 
public class FooLoginModule extends DatabaseServerLoginModule { 

    private Principal principal; 
    private String userName; 

    @Override 
    public boolean login() throws LoginException { 
     super.loginOk = false; 
     super.loginOk = tryLogin(); 
     return super.loginOk; 
    } 

    protected boolean tryLogin() throws LoginException { 
     if (doesSomeAdditionalLoginValidation()) { 
      createPrincipal(); 
      return true; 
     } 
     return false; 
    } 

    @VisibleForTesting 
    protected UserResourceClient createUserResourceClient() { 
     return new UserResourceClient(createAuth(), createEndPoint()); 
    } 

    private EndPoint createEndPoint() { 
     return new EndPointProvider(...).create(); 
    } 

    private Auth createAuth() { 
     return new AuthProvider(...).createAuth(); 
    } 

    private void createPrincipal() throws LoginException { 
     try { 
      principal = createIdentity(userName); 
     } catch (Exception e) { 
      throw new LoginException(PROCESSING_FAILED + "Failed to create principal: " + e.getMessage()); 
     } 
    } 

    @Override 
    protected String getUsername() { 
     return userName; 
    } 

    @Override 
    protected Principal getIdentity() { 
     return principal; 
    } 

} 

Die App als ear eingesetzt wird, so, in .war Dateien Ich habe eine jboss-web.xml und in .jar Dateien habe ich eine jboss-app.xml. jboss-web:

<jboss-web> 
    <security-domain>mydomain</security-domain> 
</jboss-web> 

jboss-App:

<?xml version="1.0" encoding="UTF-8"?> 
<jboss-app> 
    <security-domain>mydomain</security-domain> 
</jboss-app> 

Aber, wenn ich versuche, die App einen Stateless Bean mit @SecurityDomain("mydomain") kommentierte zu verwenden versucht, erhalte ich Zugriffsfehler:

19: 35: 40.530 ERROR [org.jboss.as.ejb3.invocation] (Standardtask-26) WFLYEJB0034: EJB-Aufruf fehlgeschlagen auf Komponente FooService für Methode public java.lang.String foo .service.blah.FooService.find(): javax.ejb.EJBAccessException: WFLYEJB0364: Aufruf bei Methode: public java.lang.String foo.service.blah.FooService.find() von bean: FooService ist nicht erlaubt

der Code des FooService wie folgt aussieht:

@Stateless 
@SecurityDomain("mydomain") 
public class FooService { 

    public List<Foo> find() { 
     return ...; 
    } 
} 

ich sehe, dass das Präfix java:/jaas/ von überall entfernt werden muss, und ich tat es, aber immer noch wird dies nicht funktionieren.

Kann nichts anderes finden, das in Migrationsleitfäden damit verwandt scheint.

Was fehlt mir?

Antwort

0

Im Wesentlichen ändert sich das Standardverhalten.

On JBoss AS, war das Standardverhalten zu @PermitAll, wenn keine Rolle angegeben wurde, in Wildfly ist es durch default-missing-method-permissions-deny-access konfigurierbar, und es ist standardmäßig @DenyAll.

Ich änderte meine standalone.xml etwas wie folgt aus:

<subsystem xmlns="urn:jboss:domain:ejb3:3.0"> 
    <!-- other stuff --> 
    <default-missing-method-permissions-deny-access value="false"/> 
    <!-- other stuff --> 
</subsystem> 

Und es funktionierte vor wie.

Verwandte Themen