• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

Spring Security 404 While Redirecting To Login Page

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would like to give my current project code:

Current Spring Security Config


Current Controller:


I expect that, if I  am not authenticated and I hit localhost:1111/preferences, I am redirected to localhost:1111/login. This happens but the screen shows a 404 !... what could be happening ?...
 
Saloon Keeper
Posts: 14661
330
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When you disable your security config and browse to /preferences, do you also get a 404 or is your preferences page shown?

What kind of Spring application are you building? Are you using Spring boot? Please show us your application configuration.
 
AgustinC Cardeilhac Banus
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is a psring boot application. When I browse to /preferences, I am redirected to /login but the page shown is a 404 page.

 
AgustinC Cardeilhac Banus
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is a small video I made... 404 Login Page
The /preferences is not shown...
 
Stephan van Hulst
Saloon Keeper
Posts: 14661
330
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What I meant was, what happens when you DON'T require authorization on the /preferences URL?

Can you show us your SpringBootApplication?

Please also tell us what package your application class and your controller class are in.
 
AgustinC Cardeilhac Banus
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know where you are going... If I remove the "haveAuthority" from the /preferences and apply a permitAll, I get a 404... Then you could be thinking.. The controllear beant maybe be not included inside the app context but I double checked and it seems fine for me:
Project Structure
I must be missing something really silly...
Another thing, I made a void method annotated with @PostCOnstruct and debug, and the execution went in... So I guess its included !
 
AgustinC Cardeilhac Banus
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I added a logging into the DispatcherServlet and it shows this:


I added this iside the controller:


This is because I saw the app was requesting a "/" (dont know why) and there was a handler for that. When I hit /preferences, instead of redirecting to /login it stays in /preferences but it show the "form" view (Which has the login form). When I try to login with good credentials, it redirects to /home but the page shown is the same as the login form. I am kinda lost...
 
AgustinC Cardeilhac Banus
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you want, we can make a google meet... I would really appreciate !
 
reply
    Bookmark Topic Watch Topic
  • New Topic