Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4547246
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T16:04:00+00:00 2026-05-21T16:04:00+00:00

i m new to Grails and using some Shiro security. I have made a

  • 0

i m new to Grails and using some Shiro security.
I have made a little site with login page and if login successful it redirects me to another loggedin page.

now i want to implement Shiro Security. I have run that plugin and quick start app of Shiro on new Grails Project.

what i want to achieve is that how can i implement my security on my own pages using the Quick Start Files and code. Please guide. a little. which files should i use from that quick start and what changing should i made. ?

waiting for some positive response 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T16:04:01+00:00Added an answer on May 21, 2026 at 4:04 pm

    let’s first start with a fresh app:

    grails create-app ShiroDemo
    

    now install shiroby adding it to the plugins section of BuildConfig.groovy:

    plugins {
    compile “:shiro:1.1.4”
    }

    we need the auth controller and the wildcard-realm:

    grails create-auth-controller
    grails create-wildcard-realm
    

    now let’s create a dummy user with the needed role and permissions in bootstrap.groovy:

    import org.apache.shiro.crypto.hash.Sha256Hash
    class BootStrap {
        def init = { servletContext ->
            def roleUser = new ShiroRole(name:'USER')
            roleUser.addToPermissions('auth:*')
            roleUser.addToPermissions('controller:action')
            roleUser.save(flush:true, failOnError: true)
            def testUser = new ShiroUser(username:'kermit',passwordHash:new Sha256Hash("password").toHex())
            testUser.addToRoles(roleUser)
            testUser.save(flush:true, failOnError: true)
        }
        def destroy = {
        }
    }
    

    Take a look at the role.User.addToPermissions lines. Here you grant permissions to your controllers and actions. If the role is missing a permission, a user will be redirected to the access denied page. You’ll find a good description of how to specify permissions on the shiro plugin page: http://www.grails.org/plugin/shiro
    You’ll have to add more permissions for the rest of your application functionality.
    You can add those permission also directly to the user – sometimes useful for testing or if you don’t want to setup a new role for something special.

    btw: make sure to use the sha256hash and not the sha1hash which will not work with the current shiro version.

    last thing we have to do is create the /conf/SecurityFilters.groovy class:

    class SecurityFilters {
        def filters = {
            all(uri: "/**") {
                before = {
                    // Ignore direct views (e.g. the default main index page).
                    if (!controllerName) return true
    
                    // Access control by convention. 
                    accessControl() 
                } 
            } 
        } 
    }
    

    This will install access control for all controllers but not direct views (our index page).

    Now give it a try and run your project:

    grails run-app
    

    hope that helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to grails, coming from Django. Using test driven development, I am
I have problems getting data from grails using extjs. My Grails controller code is:
I have a simple grails file upload app. I am using transferTo to save
I have a grails project that contains a few domain objects. I am using
I have been working on the project where application is using grails 1.2.2.... Now
I am very new to grails.I am doing one sample project for image uploading
I'm new to grails. I'd like to give it a whirl by implementing a
New to javascript/jquery and having a hard time with using this or $(this) to
I'm using Grails 1.1 beta2. I need to import a large amount of data
Im building a Grails app that will have multiple similar websites (each it's own

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.