Class PendingIdentityLinks
java.lang.Object
com.irurueta.authserver.authorization.api.web.social.PendingIdentityLinks
Keeps the link marker (
PendingIdentityLink) of the explicit link flow: the identities page records it in the
session before sending the browser to the provider, and the user services consume it when the provider sends the
user back. The marker is used once and only within LIFETIME, only for the provider it names and only while
the session is still signed in as the account that asked; otherwise the sign-in goes on as an ordinary one. When
the marker is consumed, the authentication of the session is kept in a request attribute, so the success handler can
put it back: linking never switches the session to another principal.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ClockSource of the current time.static final DurationHow long a link marker stays usable.(package private) static final StringRequest attribute of the authentication the session had when the marker was consumed.(package private) static final StringSession attribute of the marker. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbegin(jakarta.servlet.http.HttpSession session, IdentityProvider provider, UUID userId, String username) Records that the next sign-in with a provider links its identity to the signed-in account.consume(IdentityProvider provider) Consumes the marker of the current request, if it is usable for a sign-in with a provider.Optional<org.springframework.security.core.Authentication> linkedBy(jakarta.servlet.http.HttpServletRequest request) Finds the authentication a request had when it linked an identity.
-
Field Details
-
LIFETIME
How long a link marker stays usable. -
SESSION_ATTRIBUTE
Session attribute of the marker. -
LINKED_ATTRIBUTE
Request attribute of the authentication the session had when the marker was consumed. -
clock
Source of the current time.
-
-
Constructor Details
-
PendingIdentityLinks
public PendingIdentityLinks()
-
-
Method Details
-
begin
public void begin(jakarta.servlet.http.HttpSession session, IdentityProvider provider, UUID userId, String username) Records that the next sign-in with a provider links its identity to the signed-in account.- Parameters:
session- the session of the signed-in user.provider- the provider of the identity to link.userId- identifier of the signed-in account.username- name of the signed-in account.
-
consume
Consumes the marker of the current request, if it is usable for a sign-in with a provider. The marker is removed whether or not it is usable.- Parameters:
provider- the provider the user just signed in with.- Returns:
- the marker, or empty when there is none, it expired, it names another provider or the session is no longer signed in as the account that asked.
-
linkedBy
public Optional<org.springframework.security.core.Authentication> linkedBy(jakarta.servlet.http.HttpServletRequest request) Finds the authentication a request had when it linked an identity.- Parameters:
request- the request of the provider's answer.- Returns:
- the authentication to keep, or empty when the request was not a link.
-