Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is spring security default login page code located?

Where is the default login page generated in Spring Security 4 when you use the simplest of configurations?

<http>
...
    <form-login/>
</http>

I am using this basic sample web application for Spring Security.

Is almost the same as this question Where is the default login page for the spring security core plugin? but for Java.

like image 639
lmiguelmh Avatar asked Feb 22 '16 15:02

lmiguelmh


People also ask

Does Spring Security use default login form?

Spring security secures all HTTP endpoints by default. A user has to login in a default HTTP form. To enable Spring Boot security, we add spring-boot-starter-security to the dependencies.

Which is the default login file in spring boot?

By default, Spring Boot will only log to the console and will not write log files. If you want to write log files in addition to the console output you need to set a logging. file or logging. path property (for example in your application.

What is the default username and password for Spring Security?

As of Spring Security version 5.7. 1, the default username is user and the password is randomly generated and displayed in the console (e.g. 8e557245-73e2-4286-969a-ff57fe326336 ).


1 Answers

It is generated from this class org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter :

private String generateLoginPageHtml(HttpServletRequest request, boolean loginError, boolean logoutSuccess) {
    String errorMsg = "none";

    [...]

    StringBuilder sb = new StringBuilder();

    sb.append("<html><head><title>Login Page</title></head>");

    if (formLoginEnabled) {
        sb.append("<body onload='document.f.").append(usernameParameter).append(".focus();'>\n");
    }

    [...]
like image 183
Arnaud Denoyelle Avatar answered Oct 03 '22 02:10

Arnaud Denoyelle