Keycloak long SSO sessions with social brokers (facebook, google)

I’d like users who are logged in via Facebook or Google to stay logged for months. Similarly, like “remember me” functionality when you’re logging in with username/password. However, that setting is not in use when logging in via facebook.

I was thinking that I could workaround it by creating custom authenticator and set it to execute as a postlogin flow, configured for the social login broker, this authenticator would set a custom persistent cookie.

Next, yet another authenticator plugged into the browser flow would verify the cookie, and if valid - authenticate user based on it.

The above would probably work OK. But, then there is another issue: how could I handle user logout? I mean:

how I could extend keycloak logout function so that it would reset also my cookie?