grails 2.4.2 geb I m being redirected to login page and authoties turn to ROLE_ANONYMOUS

57 views
Skip to first unread message

Chetan Khare

unread,
Feb 25, 2016, 3:35:28 AM2/25/16
to Grails Dev Discuss
**Hi
I am using geb with selenium 2.51 firefox and chrome driver
when a form is being posted and redirection is happening in the case discussed below then granted authorties turn to ROLE_ANONYMOUs
*

> Below stack trace will give a more appropriate picture

*

016-02-25 13:22:57,760 [http-bio-8080-exec-4] DEBUG web.FilterChainProxy  - /optOutList/index/1 at position 8 of 8 in additional filter chain; firing Filter: 'FilterSecurityInterceptor'
2016-02-25 13:22:57,761 [http-bio-8080-exec-4] DEBUG intercept.FilterSecurityInterceptor  - Secure object: FilterInvocation: URL: /optOutList/index/1; Attributes: [ROLE_BUZZ_BUILDER_ADMIN, ROLE_ORG_ADMIN]
2016-02-25 13:22:57,761 [http-bio-8080-exec-4] DEBUG intercept.FilterSecurityInterceptor  - Previously Authenticated: grails.plugin.springsecurity.authentication.GrailsAnonymousAuthenticationToken@dc4337e: Principal: org.springframework.security.core.userdetails.User@dc730200: Username: __grails.anonymous.user__; Password: [PROTECTED]; Enabled: false; AccountNonExpired: false; credentialsNonExpired: false; AccountNonLocked: false; Granted Authorities: ROLE_ANONYMOUS; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@957e: RemoteIpAddress: 127.0.0.1; SessionId: null; Granted Authorities: ROLE_ANONYMOUS
2016-02-25 13:22:57,761 [http-bio-8080-exec-4] DEBUG hierarchicalroles.RoleHierarchyImpl  - getReachableGrantedAuthorities() - From the roles [ROLE_ANONYMOUS] one can reach [ROLE_ANONYMOUS] in zero or more steps.
2016-02-25 13:22:57,763 [http-bio-8080-exec-4] DEBUG access.ExceptionTranslationFilter  - Access is denied (user is anonymous);




***

> This is config file part(Config.groovy)

***
// Added by the Spring Security Core plugin:

    grails.plugin.springsecurity.active = true
    grails.plugin.springsecurity.userLookup.userDomainClassName = 'com.buzzbuilderpro.backend.security.User'
    grails.plugin.springsecurity.userLookup.authorityJoinClassName = 'com.buzzbuilderpro.backend.security.UserRole'
    grails.plugin.springsecurity.authority.className = 'com.buzzbuilderpro.backend.security.Role'
    grails.plugin.springsecurity.logout.postOnly = false
    grails.plugins.springsecurity.useSecurityEventListener = true
    grails.plugins.springsecurity.logout.handlerNames =
      ['rememberMeServices',
       'securityContextLogoutHandler',
       'securityEventListener']
    //grails.plugins.springsecurity.password.algorithm = 'bcrypt'
    //grails.plugin.springsecurity.securityConfigType = "Annotation"
    grails.plugin.springsecurity.controllerAnnotations.staticRules = [
    //        '/**'            : ['permitAll'],
    '/'                  : ['permitAll'],
    '/index'             : ['permitAll'],
    '/index.gsp'         : ['permitAll'],
    '/assets/**'         : ['permitAll'],
    '/**/js/**'          : ['permitAll'],
    '/**/ckeditor/**'    : ['permitAll'],
    '/**/css/**'         : ['permitAll'],
    '/**/font-awesome/**': ['permitAll'],
    '/**/images/**'      : ['permitAll'],
    '/**/img/**'         : ['permitAll'],
    '/**/favicon.ico'    : ['permitAll'],
    '/userVerification/*': ['permitAll'],
    '/public/*'          : ['permitAll'],
    '/notifications/*'   : ['permitAll']
    ]

***

> This is the code for controller



***
   

     def index() {
            Organization organization = Organization.findById(params.id)
            List<BannedEmail> bannedEmails = BannedEmail.findAllByOrganization(organization)
            [bannedEmails: bannedEmails, organization: organization]
        }
        def addEmail() {
            Integer totalAddEmail = 0
            Organization organization = Organization.findById(params.organizationId)
            String emailAddresses = params.emailAddress
            List<String> emailList = emailAddresses.split("[\\s,\\n]+")
            emailList.each { email ->
                BannedEmail bannedEmail
                bannedEmail = BannedEmail.findByEmailAddress(email)
               ..................
                    if (bannedEmail.validate()) {
                        totalAddEmail++
                        bannedEmailService.save(bannedEmail)
                    }
                }
            .....................................................
            flash.message = "${totalAddEmail} email added in Opt-Out list"
            redirect(action: 'index', params: [id: organization.id])
        }



***

> This is build config (BuildConfig.groovy)

***


    gebVersion = '0.10.0'
    seleniumVersion = '2.50.0'
    dependencies {
        // runtime 'org.postgresql:postgresql:9.3-1101-jdbc41'
        test "org.grails:grails-datastore-test-support:1.0-grails-2.4"
        test("org.seleniumhq.selenium:selenium-firefox-driver:$seleniumVersion")
    //
    //    // You usually only need one of these, but this project uses both
        test "org.gebish:geb-spock:$gebVersion"
        test "org.gebish:geb-junit4:$gebVersion"
    //    test("org.seleniumhq.selenium:selenium-htmlunit-driver:2.0rc3") {
    //      exclude "xml-apis"
    //    }
        test "org.seleniumhq.selenium:selenium-chrome-driver:$seleniumVersion"
        compile 'org.apache.httpcomponents:httpcore:4.3'
        compile 'org.apache.httpcomponents:httpclient:4.3'
    }**




Reply all
Reply to author
Forward
0 new messages