New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Need Spring security tag support for JSF/Facelets [SWF-1333] #521
Comments
bansi commented spend whole day trying to figure out why Spring Security Tags 2.0.2 were not working whereas the sampe Tutorial shipped with there disturbution works perfectly fine. After lots of debugging with Eclipse debugger, i figured out everything works perfect when i define Spring security tags works inside a JSP page. But if i define similar tags in Facelets xhtml file it doesnt work. Here is the snippet which works fine index.jsp <%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %> <html> Your Authentication Object is <sec:authentication property="principal.username"/> </p> Here is the snippet which doesnt work index.xhtml <?xml version="1.0" encoding="UTF-8"?> xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich" xmlns:s="http://myfaces.apache.org/sandbox" xmlns:t="http://myfaces.apache.org/tomahawk" xmlns:c="http://java.sun.com/jstl/core" xmlns:sec="http://www.springframework.org/security/tags"> <body> <ui:composition template="/WEB-INF/layout/layout.xhtml"> <ui:define name="title"> Admin - Manufacturer </ui:define> <ui:define name="content"> <f:view> <h:form id="manufacturerForm"> <ui:include src="messages.xhtml"/> <div> Your Authentication Object is <sec:authentication property="principal.username"/> </h3> Any pointers/suggestions greatly appreciated Regards Bansi |
marcin muras commented Yes it's true in facelets environment this tag doesn't works. It should be added in certainly but whats more facelets functions can be created. So we can use not only tags but also functions in EL expression. |
Claude Gex commented Crank has implemented the authorize tag as a facelet tag. See: http://code.google.com/p/krank/wiki/CrankSpringSecurityWebapp Regards |
Dominik Dorn commented Hi, I've created a simple jar file to easily integrate Spring Security and Facelets. You can even add it as maven dependency. If you are interested in this, take a look at Greetings, |
Rossen Stoyanchev commented Note that due to the package changes in Facelets between JSF 1.2 and JSF 2 you will need to register the Spring Security taglib by adding a springsecurity.taglib.xml appropriate for your version (details below). Also see the booking-faces sample, which contains the necessary configuration.
<?xml version="1.0"?> <context-param> A Spring Security Facelets tag library has been added with support for JSF 2 and JSF 1.2 environments. The library provides an <authorize> tag and also registers several authorization-related EL functions. The <authorize> tag is functionally equivalent to the JSP <authorize> tag described in the Spring Security documentation. It supports the following combinations of attributes:
All <authorize> tag attributes can be Unified EL expressions except the "access" attribute, which is expected to be a Spring EL expression. The "var" attribute can be used to store the result of the authorization for access in EL expressions in other parts of the view. Use the following to add the tag library to a view ("sec" is recommended but not required): Then use the <authorize> tag in the view: Note that in order to use Spring EL expressions you must add the "use-expressions" attribute in your Spring Security configuration: The Spring Security Facelets tag library also provides the following EL functions:
They can be used in any component attribute. For example: <h:panelGroup id="bookingsFragment" rendered="#{sec:areAllGranted('ROLE_USER, ROLE_SUPERVISOR')}"> This functionality will be available in Spring Web Flow 2.2.0.RC1. |
Vigil Bose opened SWF-1333 and commented
Since Spring security already has support for using "auth" tag inside JSP's and the similar one does not exist for supporting JSF/Facelets view technology. It is cumbersome to go with a third party acegi-jsf components and hack them to make it work with Spring security 2.0.2. It would definitely add a lot of value to provide support of using Spring security tag in JSF/Facelets view technology.
Issue Links:
("duplicates")
25 votes, 19 watchers
The text was updated successfully, but these errors were encountered: