Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Key斗篷、Wildfly和JSF-x27;禁止';_Jsf_Wildfly_Keycloak - Fatal编程技术网

Key斗篷、Wildfly和JSF-x27;禁止';

Key斗篷、Wildfly和JSF-x27;禁止';,jsf,wildfly,keycloak,Jsf,Wildfly,Keycloak,再见,朋友们 首先,我阅读了文档,用谷歌搜索并尝试了各种方法 我试图确保JSF2.2WebApp在Wildfly_11.0.0.0_Final上作为WAR部署的应用程序运行 KeyClope使用正确的领域信息进行设置,并定义了角色和用户 登录到KeyClope帐户(管理员和用户)可以100%工作 如果不“激活”keydape,应用程序工作正常(它加载并运行所有导航,ui主要是PrimeFaces和OmniFaces) 当“激活”keydove(并在端口偏移上运行它以确保端口不会与WildFly冲

再见,朋友们

首先,我阅读了文档,用谷歌搜索并尝试了各种方法

我试图确保JSF2.2WebApp在Wildfly_11.0.0.0_Final上作为WAR部署的应用程序运行

KeyClope使用正确的领域信息进行设置,并定义了角色和用户

登录到KeyClope帐户(管理员和用户)可以100%工作

如果不“激活”keydape,应用程序工作正常(它加载并运行所有导航,ui主要是PrimeFaces和OmniFaces)

当“激活”keydove(并在端口偏移上运行它以确保端口不会与WildFly冲突)时,在使用keydove进行身份验证后,我得到的只是一个“禁止”页面

我想做的就是访问应用程序中的安全令牌,以便能够呈现UI片段,并根据分配给用户的角色访问bean方法

好的,这是我当前尝试的设置和相关信息(如果你们中的一位大师看到与这个特定问题无关的东西,可以改进,所有反馈都将非常感谢)

我的POM文件:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">


    <!-- Model Version -->
    <modelVersion>4.0.0</modelVersion>

    <!-- mvn version prerequisite -->
    <prerequisites>
        <maven>3.3.9</maven>
    </prerequisites>

    <!-- Application package information -->
    <groupId>com.mydomain</groupId>
    <artifactId>myapp</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>

    <!-- Properties -->
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

    <!-- mvn repositories -->
    <repositories>
        <repository>
            <id>JBoss</id>
            <name>public-jboss</name>
            <url>http://repository.jboss.org/nexus/content/groups/public-jboss/</url>
        </repository>
        <repository>
            <id>java.net-maven2-SNAPSHOT-repository</id>
            <name>Java.net SNAPSHOT-Repository for Maven</name>
            <url>https://maven.java.net/content/repositories/snapshots/</url>
            <layout>default</layout>
        </repository>
        <repository>
            <id>java.net-maven2-repository</id>
            <name>Java.net Repository for Maven</name>
            <url>https://maven.java.net/content/repositories/releases/</url>
            <layout>default</layout>
        </repository>
        <repository>
            <id>oss.sonatype.org</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
        </repository>
        <repository>
            <id>bintray-snapshot</id>
            <name>libs-snapshot</name>
            <url>http://oss.jfrog.org/artifactory/libs-snapshot</url>
        </repository>
    </repositories>

    <!-- Dependencies -->
    <dependencies>
        <!-- Server specific dependencies for WildFly 11 -->
        <dependency>
            <groupId>com.sun.faces</groupId>
            <artifactId>jsf-api</artifactId>
            <version>2.2.13</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.sun.faces</groupId>
            <artifactId>jsf-impl</artifactId>
            <version>2.2.13</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>5.1.10.Final</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-search-orm</artifactId>
            <version>5.5.8.Final</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>5.3.5.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate.javax.persistence</groupId>
            <artifactId>hibernate-jpa-2.1-api</artifactId>
            <version>1.0.0.Final-redhat-1</version>
        </dependency>

        <!-- Target dependency for Java EE 7 server. -->
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <version>7.0</version>
            <scope>provided</scope>
        </dependency>

        <!-- Runtime dependencies.  -->
        <dependency>
            <groupId>org.keycloak</groupId>
            <artifactId>keycloak-core</artifactId>
            <version>3.4.1.Final</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.keycloak</groupId>
            <artifactId>keycloak-adapter-core</artifactId>
            <version>3.4.1.Final</version>
        </dependency>
        <dependency>
            <groupId>org.keycloak</groupId>
            <artifactId>keycloak-adapter-spi</artifactId>
            <version>3.4.1.Final</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.5.2.redhat-1</version>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.servlet</groupId>
            <artifactId>jboss-servlet-api_3.1_spec</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.wildfly.core</groupId>
            <artifactId>wildfly-server</artifactId>
            <version>3.0.10.Final-redhat-1</version>
        </dependency>
        <dependency>
            <groupId>org.wildfly</groupId>
            <artifactId>wildfly-feature-pack</artifactId>
            <version>11.0.0.Final</version>
            <type>pom</type>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>commons-beanutils</groupId>
            <artifactId>commons-beanutils</artifactId>
            <version>1.9.3</version>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.6</version>
        </dependency>

        <dependency>
            <groupId>org.primefaces</groupId>
            <artifactId>primefaces</artifactId>
            <version>6.1</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.primefaces.themes</groupId>
            <artifactId>all-themes</artifactId>
            <version>1.0.10</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.primefaces.extensions</groupId>
            <artifactId>primefaces-extensions</artifactId>
            <version>6.1.1</version>
        </dependency>

        <dependency>
            <groupId>org.omnifaces</groupId>
            <artifactId>omnifaces</artifactId>
            <version>2.6.4</version>
        </dependency>
        <dependency>
            <groupId>org.omnifaces</groupId>
            <artifactId>omnisettings</artifactId>
            <version>0.1</version>
        </dependency>
        <dependency>
            <groupId>org.omnifaces</groupId>
            <artifactId>omniutils</artifactId>
            <version>0.5</version>
        </dependency>
        <dependency>
            <groupId>org.omnifaces</groupId>
            <artifactId>omnipersistence</artifactId>
            <version>0.3</version>
        </dependency>
        <dependency>
            <groupId>org.omnifaces</groupId>
            <artifactId>optimusfaces</artifactId>
            <version>0.4</version>
        </dependency>

        <dependency>
            <groupId>org.infinispan</groupId>
            <artifactId>infinispan-core</artifactId>
            <version>8.2.8.Final</version>
        </dependency>

        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>42.1.4</version>
        </dependency>

        <dependency>
            <groupId>org.jboss.weld</groupId>
            <artifactId>weld-api</artifactId>
            <version>2.4.SP1</version>
        </dependency>
        <dependency>
            <groupId>org.jboss.weld</groupId>
            <artifactId>weld-core-impl</artifactId>
            <version>2.4.3.Final</version>
        </dependency>

        <dependency>
            <groupId>org.atmosphere</groupId>
            <artifactId>atmosphere-runtime</artifactId>
            <version>2.4.14</version>
        </dependency>

        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api</artifactId>
            <version>2.9.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>2.9.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-web</artifactId>
            <version>2.9.1</version>
        </dependency>

        <dependency>
            <groupId>joda-time</groupId>
            <artifactId>joda-time</artifactId>
            <version>2.9.9</version>
        </dependency>


        <!-- Test dependencies. -->
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.11</version>
            <scope>test</scope>
        </dependency>
    </dependencies>


    <!-- Build settings -->
    <build>
        <finalName>${project.artifactId}</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-archetype-plugin</artifactId>
                <version>3.0.1</version>
            </plugin>
        </plugins>
    </build>
</project>
my web.xml的内容如下所示:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.1"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">

    <!-- Application information -->
    <display-name>MyApp</display-name>
    <description>MyApp description.</description>


    <!-- App Security -->
    <security-constraint>
        <web-resource-collection>
            <web-resource-name>myapp</web-resource-name>
            <url-pattern>/*</url-pattern>
        </web-resource-collection>
        <auth-constraint>
            <role-name>user</role-name>
        </auth-constraint>
    </security-constraint>

    <login-config>
        <auth-method>KEYCLOAK</auth-method>
        <realm-name>MyRealm</realm-name>
    </login-config>

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


    <!-- context params -->
    <!-- Save State On Client -->
    <context-param>
        <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
        <param-value>client</param-value>
    </context-param>

    <!-- enable development mode -->
    <context-param>
        <description>
            Development version of MyApp
        </description>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
    </context-param>
    <context-param>
        <param-name>org.jboss.weld.development</param-name>
        <param-value>true</param-value>
    </context-param>

    <!-- convert to local timezone -->
    <context-param>
        <param-name>javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE</param-name>
        <param-value>true</param-value>
    </context-param>

    <!-- PrimeFaces setup -->
    <context-param>
        <param-name>primefaces.THEME</param-name>
        <param-value>bootstrap</param-value>
    </context-param>
    <context-param>
        <param-name>primefaces.FONT_AWESOME</param-name>
        <param-value>true</param-value>
    </context-param>

    <!-- log4j -->
    <context-param>
        <param-name>log4jContextName</param-name>
        <param-value>myapp</param-value>
    </context-param>


    <!-- Faces Servlet -->
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
        <url-pattern>*.xhtml</url-pattern>
    </servlet-mapping>


    <!-- Welcome File -->
    <welcome-file-list>
        <welcome-file>index.xhtml</welcome-file>
    </welcome-file-list>

</web-app>
subsystem xmlns="urn:jboss:domain:keycloak:1.1">
          <secure-deployment name="myapp.war">
            <realm>MyRealm</realm>
            <auth-server-url>http://localhost:62223/auth</auth-server-url>
            <ssl-required>EXTERNAL</ssl-required>
            <resource>myapp</resource>
            <credential name="secret">ce0984f0-c6ef-4808-bfd4-342480437051</credential>
            <use-resource-role-mappings>true</use-resource-role-mappings>
          </secure-deployment>
        </subsystem>

MyApp
我的应用程序描述。
myapp
/*
这将允许我读取用户的角色,并根据角色部分呈现UI和菜单

请让我知道,如果你需要任何其他有关上述信息

衷心的感谢

编辑:添加了KeyClope客户端设置选项卡的屏幕截图


您是否为Java应用程序正确配置了领域客户端?客户端配置中的web源是什么?@Dino嗨,Dino,我的web源有一个条目,是“”@Dino我将值更改为*和+,如果有帮助的话,还包括此选项卡的屏幕截图。看起来不错。我建议您首先检查您尝试登录的用户的角色。“禁止”可能是由这个引起的。@Dino,谢谢你。
subsystem xmlns="urn:jboss:domain:keycloak:1.1">
          <secure-deployment name="myapp.war">
            <realm>MyRealm</realm>
            <auth-server-url>http://localhost:62223/auth</auth-server-url>
            <ssl-required>EXTERNAL</ssl-required>
            <resource>myapp</resource>
            <credential name="secret">ce0984f0-c6ef-4808-bfd4-342480437051</credential>
            <use-resource-role-mappings>true</use-resource-role-mappings>
          </secure-deployment>
        </subsystem>