Warum geht es nicht (Spring Security)?
Hallo,ich mache derzeit bei einem Kurs über Udemy mit und lerne dabei Spring Security. Leider ist der Kurs für Spring Security 6. Aber ich verwende die neuste Version, da dies ja irgendwie sinn macht damit anzufangen, anstatt die ältere Version zu lernen. Nun wollte ich wie im Kurs die SecurityConfig einstellen also mit SecurityFilterChain. Auch in den Docs für die neuste version sieht alles aus wie bei mir jetzt. Aber es möchte einfach nicht funktionieren. Ich werde bei allen Endpunkten nach einem Login gefragt, obwohl ich für 2 Endpunkte “permitAll()” verwende
So sieht meine Configuration aus:
In Postman kommt Unauthorized. Im Webbrowser wird nach Logindaten gefragt.
Warum geht es nur bei mir nicht… Hilfe bitte 🙁
I could not reproduce your problem so far, so I would suggest you go the same way as I go.
Open now http://localhost:8080/contactwill Contact returned. Other URLs go to a login page. This also applies to the moment /notices, because this URL is not yet mapped to any page/controller.
I am not an expert for Java and Spring Security, but in the route mapping examples I found, I have always seen that not requestMatchers(), but antMatchers() was used. You could try that.
The antMatcher– Method is obsolete. It has already been removed in version 6.