Git Product home page Git Product logo

Comments (13)

ericraskin avatar ericraskin commented on August 12, 2024 1

I have a simple example. No special coding:

  1. BuildConfig.groovy - added
// Security and Security-UI
compile ":spring-security-core:2.0-RC5"
compile ":spring-security-ui:1.0-RC2"
  1. Config.groovy changes:
// Added by the Spring Security Core plugin:
grails.plugin.springsecurity.userLookup.userDomainClassName = 'com.paslists.User'
grails.plugin.springsecurity.userLookup.authorityJoinClassName = 'com.paslists.UserRole'
grails.plugin.springsecurity.authority.className = 'com.paslists.Role'
grails.plugin.springsecurity.logout.postOnly = false
grails.plugin.springsecurity.controllerAnnotations.staticRules = [
        '/':                ['permitAll'],
        '/index':           ['permitAll'],
        '/index.gsp':       ['permitAll'],
        '/assets/**':       ['permitAll'],
        '/**/js/**':        ['permitAll'],
        '/**/css/**':       ['permitAll'],
        '/**/images/**':    ['permitAll'],
        '/**/favicon.ico':  ['permitAll'],
        '/dbconsole/**':    ['ROLE_ADMIN'],
        '/plugins/**':      ['ROLE_USER'],
        '/user/**':         ['ROLE_ADMIN'],
        '/role/**':         ['ROLE_ADMIN'],
        '/securityInfo/**':     ['ROLE_ADMIN'],
        '/registationCode/**':  ['ROLE_ADMIN']
]
  1. BootStrap.groovy:
import com.paslists.*

class BootStrap {

    def init = { servletContext ->
        def adminRole = Role.findOrSaveWhere(authority:'ROLE_ADMIN')
        def user = User.findOrSaveWhere(username:'admin',password:'password')
        if (!user.authorities.contains(adminRole)) {
                UserRole.create(user,adminRole,true)
        }
    }
    def destroy = {
    }
}

I run (grails run-app) and click on the grails.plugin.springsecurity.ui.UserController link. I get asked for a username and password, (admin/password from BootStrap.groovy) then it goes back to the home page. It never loads the /user/search page. Trying to directly execute /user/search also does nothing.

I don't know if this is related to my "real" problem or not, but clearly the UI does not display. In my "real" app, at least I get the UI screen. I must be doing something dumb...

security-ui-bug.zip

from grails-spring-security-ui.

ddelponte avatar ddelponte commented on August 12, 2024

Thanks for reporting this issue!

What information can I give you to help determine what is going wrong?

The best thing you could do is provide a bare-bones sample app that duplicates the problem as well as the steps needed to reproduce (and/or a test).

You may either attach the sample app to this ticket as a zip file or provide a link to where the code is available (i.e. github, bitbucket, etc.)

from grails-spring-security-ui.

ericraskin avatar ericraskin commented on August 12, 2024

Sorry for the delay. I am trying to create a sample app. I will post as soon as I manage it. :-(

from grails-spring-security-ui.

ddelponte avatar ddelponte commented on August 12, 2024

@ericraskin I've downloaded the project you zipped up (thanks!) and was unable to duplicate the problem.

The search button is working as expected.

Here's a demo of it working using the security-ui-bug.zip code:

https://drive.google.com/file/d/1siiEbR_95U3KXM4LH3WzyY-2TUQgCFD1/view?usp=sharing

Can you confirm that, when you click the search button, a POST request is being made to UserController.userSearch()?

from grails-spring-security-ui.

ericraskin avatar ericraskin commented on August 12, 2024

from grails-spring-security-ui.

ericraskin avatar ericraskin commented on August 12, 2024

I posted a video of what happens when I run the same app. Clearly I must be doing something wrong, but what?

My run command is the typical: grails run-app (username: admin, password: password)

https://drive.google.com/file/d/1J1D2WOeAYQsIbx-Z5LKpTmVxIK2kCvcp/view?usp=sharing

My environment is:

$ sdk list grails

================================================================================
Available Grails Versions
================================================================================
   * 3.3.5                3.2.3                3.1.2                3.0.4          
     3.3.4                3.2.2                3.1.16               3.0.3          
     3.3.3                3.2.13               3.1.15               3.0.2          
     3.3.2                3.2.12               3.1.14               3.0.17         
     3.3.1                3.2.11               3.1.13               3.0.16         
     3.3.0.RC1            3.2.10               3.1.12               3.0.15         
     3.3.0.M2             3.2.1                3.1.11               3.0.14         
     3.3.0.M1             3.2.0                3.1.10               3.0.13         
     3.3.0                3.1.9                3.1.1                3.0.12         
     3.2.9                3.1.8                3.1.0                3.0.11         
     3.2.8                3.1.7                3.0.9                3.0.10         
     3.2.7                3.1.6                3.0.8                3.0.1          
     3.2.6                3.1.5                3.0.7                3.0.0          
     3.2.5                3.1.4                3.0.6            > * 2.5.6          
     3.2.4                3.1.3                3.0.5              * 2.5.5          

================================================================================
+ - local version
* - installed
> - currently in use
================================================================================
$ sdk list groovy

================================================================================
Available Groovy Versions
================================================================================
     3.0.0-alpha-2        2.4.4                2.3.5                2.1.5          
     3.0.0-alpha-1        2.4.3              * 2.3.4                2.1.4          
     2.6.0-alpha-3        2.4.2                2.3.3                2.1.3          
     2.6.0-alpha-2    > * 2.4.15               2.3.2                2.1.2          
     2.6.0-alpha-1        2.4.14               2.3.11               2.1.1          
     2.5.0-rc-1           2.4.13               2.3.10               2.1.0          
     2.5.0-beta-3         2.4.12               2.3.1                2.0.8          
     2.5.0-beta-2         2.4.11               2.3.0                2.0.7          
     2.5.0-beta-1         2.4.10               2.2.2                2.0.6          
     2.5.0-alpha-1        2.4.1                2.2.1                2.0.5          
   * 2.4.9                2.4.0                2.2.0                2.0.4          
     2.4.8                2.3.9                2.1.9                2.0.3          
     2.4.7                2.3.8                2.1.8                2.0.2          
   * 2.4.6                2.3.7                2.1.7                2.0.1          
     2.4.5                2.3.6                2.1.6                2.0.0          

================================================================================
+ - local version
* - installed
> - currently in use
================================================================================

And I just rebooted my Ubuntu 16.04 LTS desktop as well, just in case.

from grails-spring-security-ui.

ddelponte avatar ddelponte commented on August 12, 2024

How do I confirm that the POST request is going through?

Use your IDE to place a breakpoint (or a println) in the UserController.userSearch() action and see if it gets hit when you click the search button. Bonus is you can then debug and step through the handling of the request to get an idea of where the issue is locally.

My environment is as follows:

macOS 10.13.4
grails-2.5.6
java 1.8.0_163
chrome

Other Ideas

  • have you examined /etc/hosts to see if that is affecting routing?
  • have you tried clearing the browser cache?
  • is the firewall interfering?
  • have you tried 127.0.0.1 instead of localhost?

from grails-spring-security-ui.

ericraskin avatar ericraskin commented on August 12, 2024

from grails-spring-security-ui.

ericraskin avatar ericraskin commented on August 12, 2024

from grails-spring-security-ui.

ddelponte avatar ddelponte commented on August 12, 2024

Very strange indeed.

My best guess is that the problem is related to either:

  1. the Ubuntu environment
  2. the version of Java

Those two things are the most obvious differences between your setup and mine but it could be something else ¯\_(ツ)_/¯

from grails-spring-security-ui.

ericraskin avatar ericraskin commented on August 12, 2024

from grails-spring-security-ui.

ddelponte avatar ddelponte commented on August 12, 2024

As I have no Ajax configuration in the setup, I find that very confusing.

This is normal behavior. The RequestHolderAuthenticationFilter will send the request to AjaxAwareAuthenticationSuccessHandler.

The code in AjaxAwareAuthenticationSuccessHandler will check if the request is an Ajax request. If not, it will call SavedRequestAwareAuthenticationSuccessHandler.onAuthenticationSuccess() which will check for the original requested URL.

You can debug the above mentioned code to dig into what's happening locally and why it is not using the target URL.

Would you happen to have a config file somewhere that is setting some or all of the following?:

grails.plugins.springsecurity.successHandler.alwaysUseDefault = true
grails.plugins.springsecurity.successHandler.alwaysUseDefaultTargetUrl = true
grails.plugins.springsecurity.successHandler.defaultTargetUrl = '/'

I'm wondering if the alwaysUseDefaultTargetUrl is set to true somewhere on your machine?

from grails-spring-security-ui.

ddelponte avatar ddelponte commented on August 12, 2024

Closing. Not a bug.

from grails-spring-security-ui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.