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

  • SEARCH
  • Home
  • 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 8444489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:24:26+00:00 2026-06-10T09:24:26+00:00

Using simple filters for login & security in my grails application. now i need

  • 0

Using simple filters for login & security in my grails application.
now i need to connect to db – test1 using different login credential depending on logged in user role. if Admin logged in get write permission so different login & if user role logs in then read only.
How to implement it with filters??

DataSource.groovy

 environments {
 development {

/*IF LOGIN 'ADMIN' - SHOULD CONNECT USING THIS
 dataSource {
           username = 'admin'
           password = 'Guard1an'
           url = "jdbc:jtds:sqlserver://test1:1433;
           MVCC=TRUE"
           dbCreate = 'update'
       }
/*IF LOGIN 'USER' - SHOULD CONNECT USING THIS*/

 dataSource {           
              dbCreate = "update" // one of 'create', 'create-drop','update'
              username = 'user'
              password = 'tesoyear'
              url = "jdbc:jtds:sqlserver://test1:1433;
        }
dataSource_wldb1 {
            username = 'gdx'
            password = 'pinoil'
            url = "jdbc:jtds:sqlserver://wldb:1433/IVR_GUARDIAN"
            dbCreate = 'update'
    }
}

SecuirityFilter.groovy

   class SecurityFilters {
   def filters = {
   loginCheck(controller: 'load', action: '*') {
       before = {
          if (!session.user && !actionName.equals('login')) {
              flash.message = "User is not Logged in.Please login "
              redirect(controller:'user', action: 'index')
              return false
           }
       }
    }

  }
}
  • 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-06-10T09:24:27+00:00Added an answer on June 10, 2026 at 9:24 am

    If you want to secure controllers, it should be enough (and better) to use @Secured annotation. This allows you to secure whole controller or single method by specifing required user role(s). Check http://blog.springsource.org/2010/08/11/simplified-spring-security-with-grails/ for more details. Below there is also an example.

    If you are going to need more sophisticated security, check spring-security-acl plugin, which allow to grant permissions for specific database objects.

    package org.example
    
    import grails.plugins.springsecurity.Secured
    
    class PostController {
    
        @Secured(['ROLE_USER'])
        def followAjax = { ... }
    
        @Secured(['ROLE_USER', 'IS_AUTHENTICATED_FULLY'])
        def addPostAjax = { ... }
    
        def global = { ... }
    
        @Secured(['ROLE_USER'])
        def timeline = { ... }
    
        @Secured(['IS_AUTHENTICATED_REMEMBERED'])
        def personal = { ... }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Simple table: create table Items ( Price money null ) Now I need to
So i'm using a simple Zend_Auth mechanism to ensure my users login before they
i am trying to integrate spring security with struts1.2 (using LDAP) in a simple
I am using enumerator-0.4.10, and I need to distribute processing of different parts of
I have developed a simple Apache-Axis java web service using Eclipse IDE and now
I am creating a simple web application using servlets and JSP. I am implementing
I'm using QTreeView and two QSortFilterProxyModel-based filters. I need to fetch list of currently
Using simple type like class A { public int X, Y; } with object
Using simple field width specifier, the columns are 'thinner' when the string includes 'European'
im using simple vector push_back to object of Type A and getting this error

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.