Closed
Description
Describe the bug
Right now DefaultLoginPageGeneratingFilter#getLoginErrorMessage can return nullable exception message. This message passed to org.springframework.web.util.HtmlUtils#htmlEscape
with can not handle null
with results in exception in.. exception handling.
I think filter should have normal flow because:
- It is default filter for many applications
- Message is nullable attribute and there is always a chance to catch one with
null
message and there is really no valid way to enforce otherwise at this point
To Reproduce
Create an filter/user service that throws org.springframework.security.core.AuthenticationException
with null message.
java.lang.IllegalArgumentException: Input is required
at org.springframework.util.Assert.notNull(Assert.java:201)
at org.springframework.web.util.HtmlUtils.htmlEscape(HtmlUtils.java:83)
at org.springframework.web.util.HtmlUtils.htmlEscape(HtmlUtils.java:63)
at org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter.createError(DefaultLoginPageGeneratingFilter.java:372)
Expected behavior
Here should be some discussion:
- We already have default message: "Invalid credentials". IMHO it doesn't really fit
- We can show at least exception name ie:
exception.getClass().getSimpleName()
. It doesn't expose much but can provide some information - Utilize
org.springframework.context.MessageSourceAware
with some default message like "Unexpected error while performing login" andcode
for overriding it. Seems like commitment for future backward compatibility but possible.