Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support extensions of WebAuthenticationDetails when using Jackson serialization #10564

Closed
danwashusen opened this issue Nov 29, 2021 · 2 comments · Fixed by #10830
Closed

Support extensions of WebAuthenticationDetails when using Jackson serialization #10564

danwashusen opened this issue Nov 29, 2021 · 2 comments · Fixed by #10830
Assignees
Labels
in: web An issue in web modules (web, webmvc) type: enhancement A general enhancement
Milestone

Comments

@danwashusen
Copy link

danwashusen commented Nov 29, 2021

Expected Behavior

Allow custom extensions of WebAuthenticationDetails to be deserialized by Jackson.

Current Behavior

The current public constructor on WebAuthenticationDetails expects a HttpServletRequest, which is not available at the time of deserialization.

Context

We use a custom extension of WebAuthenticationDetails (e.g. ExWebAuthenticationDetails) along with a custom AbstractUserDetailsAuthenticationProvider to set it up. This all works great, except we are unable to deserialize ExWebAuthenticationDetails using Jackson because the only accessible constructor expects a HttpServletRequest.

It seems like this has been considered because WebAuthenticationDetails has a private constructor specifically for Jackson, but we can't use it because it's private:

private WebAuthenticationDetails(final String remoteAddress, final String sessionId) {

At the moment our options are to create a mock implementing of HttpServletRequest that satisfies the constructor usage, or alternativaly copy the entire WebAuthenticationDetails class into our codebase... :/

Thanks!

@danwashusen danwashusen added status: waiting-for-triage An issue we've not yet triaged type: enhancement A general enhancement labels Nov 29, 2021
@jzheaux
Copy link
Contributor

jzheaux commented Dec 13, 2021

Thanks for the context, @danwashusen. I think it's reasonable to make the constructor public at this point.

To make it public, I think we should change the HttpServletRequest constructor to call it. Also, for consistency with the rest of Spring Security, the now-public constructor should remove the final keywords from the constructor parameters.

Can you submit a PR along those lines?

@jzheaux jzheaux self-assigned this Dec 13, 2021
@jzheaux jzheaux added in: web An issue in web modules (web, webmvc) and removed status: waiting-for-triage An issue we've not yet triaged labels Dec 13, 2021
@jzheaux
Copy link
Contributor

jzheaux commented Jan 3, 2022

I hope you had a nice holiday, @danwashusen! Are you interested in submitting a PR to address this issue?

@jzheaux jzheaux added the status: ideal-for-contribution An issue that we actively are looking for someone to help us with label Jan 14, 2022
@jzheaux jzheaux removed their assignment Jan 14, 2022
@jzheaux jzheaux self-assigned this Feb 15, 2022
@jzheaux jzheaux removed the status: ideal-for-contribution An issue that we actively are looking for someone to help us with label Feb 15, 2022
@jzheaux jzheaux added this to the 5.7.0-M2 milestone Feb 15, 2022
jzheaux added a commit that referenced this issue Feb 15, 2022
jzheaux added a commit that referenced this issue Feb 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web An issue in web modules (web, webmvc) type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants