Taglib for Jakarta Faces (JSF) that enables conditional rendering of components based on Quarkus Security roles, inspired by the Spring Security JSF taglibs.
Add the dependency to your pom.xml
:
<dependency>
<groupId>br.com.redcyclone</groupId>
<artifactId>quarkus-security-taglib</artifactId>
<version>1.1.0</version>
</dependency>
Example:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="jakarta.faces.html"
xmlns:sec="quarkus.security">
<h:body>
<sec:authorize role="admin">
<h:outputText value="Visible for users with the 'admin' role." />
</sec:authorize>
<br />
<sec:authorize anyRole="admin, technician">
<h:outputText value="Visible for users with either 'admin' or 'technician' roles." />
</sec:authorize>
<br />
<sec:authorize allRoles="admin, technician">
<h:outputText value="Visible for users with both the 'admin' and 'technician' roles." />
</sec:authorize>
</h:body>
</html>
No extra configuration is required. The taglib uses the roles contained in the SecurityIdentity
instance.