Spring Security(Third Edition)
上QQ阅读APP看书,第一时间看更新

Adding domain to the login page

Open up the login.html file and add a new input named domain, as follows:

    //src/main/resources/templates/login.html

...
<label for="username">Username</label>
<input type="text" id="username" name="username"/>
<label for="password">Password</label>
<input type="password" id="password" name="password"/>
<label for="domain">Domain</label>
<input type="text" id="domain" name="domain"/>

Now, a domain will be submitted when users attempt to log in. However, Spring Security is unaware of how to use that domain to create a DomainUsernamePasswordAuthenticationToken object and pass it into AuthenticationProvider. To fix this, we will need to create DomainUsernamePasswordAuthenticationFilter.