Skip to content
This repository has been archived by the owner on Mar 31, 2022. It is now read-only.

Authentication hooks #31

Closed
alexbudarov opened this issue Nov 23, 2020 · 1 comment
Closed

Authentication hooks #31

alexbudarov opened this issue Nov 23, 2020 · 1 comment
Assignees
Milestone

Comments

@alexbudarov
Copy link

alexbudarov commented Nov 23, 2020

CUBA had the following authentication-related hooks:
https://doc.cuba-platform.com/manual-7.2/login.html#login_events

Let's take a look what analogues we provide in Jmix.

  • UserSubstitutedEvent - user substitution feature isn't yet implemented in Jmix
  • AuthenticationSuccessEvent - org.springframework.security.authentication.event.AuthenticationSuccessEvent
  • AuthenticationFailureEvent - org.springframework.security.authentication.event.AbstractAuthenticationFailureEvent
  • UserLoggedOutEvent - org.springframework.security.authentication.event.LogoutSuccessEvent

No analogues in spring-security for:

  • BeforeAuthenticationEvent and BeforeLoginEvent - useful hook to prevent logging in before asking providers.
  • AfterAuthenticationEvent and AfterLoginEvent - These listeners are triggered for both positive and negative result. Not sure if they are useful. For preventing login with already loaded from DB user AuthenticationSuccessEvent can be used.
  • UserLoggedInEvent - reliably "successully logged in" event. Can be used for various reaction in business apps. The only analogue I see is io.jmix.sessions.events.JmixSessionCreatedEvent from jmix-sessions.

According to https://stackoverflow.com/a/34298831/2032468, AuthenticationSuccessEvent doesn't always mean successful login.

Also as I see by Baeldung's example: https://www.baeldung.com/spring-security-restrict-authentication-by-geography

the standard spring security's way for pre/post authentication hooks are these methods:
org.springframework.security.authentication.dao.AbstractUserDetailsAuthenticationProvider#setPreAuthenticationChecks
org.springframework.security.authentication.dao.AbstractUserDetailsAuthenticationProvider#setPostAuthenticationChecks

So it looks like we need to provide a way of specifying preAuthenticationChecks / postAuthenticationChecks in a project without overriding the whole io.jmix.security.authentication.SecuredAuthenticationProvider.

@knstvk knstvk added this to the 1.0.0 milestone Mar 18, 2021
@knstvk knstvk changed the title Some CUBA authentication hooks aren't available in Jmix Authentication hooks Mar 19, 2021
@andreysubbotin
Copy link
Contributor

andreysubbotin commented Apr 21, 2021

CUBA events sequences: https://doc.cuba-platform.com/manual-7.2/login.html
CUBA Events mapping:

  • AuthenticationSuccessEvent. The event is fired after the user is successfully authenticated. Mapped to AuthenticationSuccessEvent
  • AuthenticationFailureEvent. The event is fired if the user authentication failed. Mapped to AbstractAuthenticationFailureEvent
  • BeforeLoginEvent/BeforeAuthenticationEvent. The event is fired before login/authentication procedure. No direct analogs. Use pre/post custom UserDetailsChecker that fires PreAuthenticationCheckEvent/PostAuthenticationCheckEvent events
  • AfterLoginEvent/AfterAuthenticationEvent. The event is fired after the user is logged in or login failed. No direct analogs.
  • UserLoggedInEvent. The event is published after the user is logged in and the user session is completely
    initialized and stored in user sessions storage. No direct analogs. Use Spring Security InteractiveAuthenticationSuccessEvent that is fired from BackendUI/RememberMe service after authentication by login/password or remember me token. Fire the event when the user authenticates through REST.

andreysubbotin pushed a commit that referenced this issue Apr 25, 2021
andreysubbotin pushed a commit to jmix-framework/jmix that referenced this issue Apr 25, 2021
andreysubbotin pushed a commit to jmix-projects/jmix-bom that referenced this issue Apr 25, 2021
andreysubbotin pushed a commit to jmix-framework/jmix that referenced this issue Apr 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants