"Your time is limited, so don't waste it living someone else's life"

Tag Archives: grails

How to customize GUI base on user role with spring security

To restrict user from seeing one or more parts on any page you can use a function of spring security that check user login ‘s role. Snippet below is an example of the granted authority checking:

<sec:ifAnyGranted roles="ROLE_ADMIN">
    <li><g:link class="create" action="create">
            <g:message code="default.new.label" args="[entityName]" />

The code restrict user from access a button with user role to only ADMIN. If we pre-define the role hierarchy of roles in system, we just only specify one role, otherwise you have to declare all the roles that can see the inside elements.


How to create a tree main menu in grails

Build the GSP page contain the menu with one div tag named mainMenu

    <div id="spsLogo" role="banner">
        <a href="http://tranhoangminh.vn"><asset:image src="sps_logo.png" alt="Code Snippet" /></a>
        <div class="mainMenu">
                <li><a href="${createLink(uri: '/')}" style="text-decoration: none;"> Home</a></li>
                <li><a href="#">Resource </a>
                        <li><a href="${createLink(action:'index', controller:'customer')}" style="text-decoration: none">Customer</a></li>
                        <li><a href="${createLink(action:'index', controller:'project')}" style="text-decoration: none">Project</a></li>
                        <li><a href="${createLink(action:'index', controller:'document')}" style="text-decoration: none">Document</a></li>
                        <li><a href="${createLink(action:'index', controller:'contact')}" style="text-decoration: none">Contact</a></li>
                <li><a href="${createLink(action:'index', controller:'Search')}">Search</a></li>
                <li><a href="#">Manager</a>
                        <li><a href="${createLink(action:'viewUser', controller:'User')}" style="text-decoration: none">Add User </a></li>
                        <li><a href="${createLink(action:'viewRole', controller:'User')}" style="text-decoration: none">Manager Role </a></li>
    <g:layoutBody />

    <div class="footer" role="contentinfo">
        <small>&copy; Copyright 2014 CRM | Powered by &nbsp;<a>SPS VietNam</a></small>
    <div id="spinner" class="spinner" style="display: none;">
        <g:message code="spinner.alt" default="Loading&hellip;" />

Read more of this post

Configure spring security with ldap authentication and local system roles in grails

Add plugins Add plugins of Spring security and ldap in BuildConfig

plugins {
        compile ":spring-security-core:2.0-RC4"
        compile ":spring-security-ldap:2.0-RC2"

Configure spring security
Configure spring security and LDAP authentication in Config
Read more of this post

%d bloggers like this: