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

Conditional lifetime of the trust device cookie #250

Open
sdespont opened this issue Sep 30, 2024 · 1 comment
Open

Conditional lifetime of the trust device cookie #250

sdespont opened this issue Sep 30, 2024 · 1 comment
Labels

Comments

@sdespont
Copy link
Contributor

Hello,

I would like to use different lifetimes for trusted device cookies for the user or administrator.

In a custom trusted device manager, would it be possible to set different lifetimes based on custom conditions?

# config/packages/scheb_2fa.yaml
scheb_two_factor:
    trusted_device:
        manager: acme.custom_trusted_device_manager  # Use a custom trusted device manager
@scheb
Copy link
Owner

scheb commented Oct 5, 2024

Yes, this is possible, but then you need to write the cookie logic yourself. The standard implementation is built for a single configured cookie lifetime.

The standard implementation that comes with the bundle can be found in these three files:
https://github.com/scheb/2fa/blob/7.x/src/trusted-device/Security/TwoFactor/Trusted/TrustedDeviceManager.php
https://github.com/scheb/2fa/blob/7.x/src/trusted-device/Security/TwoFactor/Trusted/TrustedDeviceTokenStorage.php
https://github.com/scheb/2fa/blob/7.x/src/trusted-device/Security/TwoFactor/Trusted/TrustedCookieResponseListener.php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants