Skip to content

[Enhancement request] IP of the user making the authentication #18294

@patpatpat123

Description

@patpatpat123

Context

Hello,

I would like to reach out with a small question.
I did ask the same in Stack Overflow, but the question was closed, as they mentioned this is not an issue, there is no stack trace to paste, etc.
Therefore, could you please help me not be a ping pong ball between Stack Overflow and GitHub?
If I can get two minutes of your time.

There is a function in Spring Security that provides remote address.

        final Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        final WebAuthenticationDetails webAuthenticationDetails = (WebAuthenticationDetails) authentication.getDetails();
        final var remoteadress = webAuthenticationDetails.getRemoteAddress();

I think it is working, as I do get an IP.
I was wondering what IP I get?

Let us say the auth server is deployed in the US.
I have a first user Alice, who logs in from France
Another second user, Bob, logged in from Australia.

From the code above, the remote address is the IP of the user who is authenticating ( I get Alice's and Bob's IPs, one IP from France, another from Australia).

Or the server on which the user is authenticating. (The IP of the US one)

Is there a way to get it otherwise with Spring Security?
Thank you

Expected Behavior

I would like to get the IP of the user who is performing the auth.

Current Behavior

Not sure, hence the question

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions