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

How to implement in forms? #145

Open
xkpx64 opened this issue May 6, 2021 · 5 comments
Open

How to implement in forms? #145

xkpx64 opened this issue May 6, 2021 · 5 comments

Comments

@xkpx64
Copy link

xkpx64 commented May 6, 2021

I didn't see anywhere how to implement this only in forms ? I read the whole doc And check the src
found this ob_handler but this only rewrite body to add noscript and in bottom 2 hiddenfields?

// TODO: statically rewrite all forms as well so that if a form is submitted
            // before the js has worked on, it will still have token to send
            // @priority: medium @labels: important @assign: mebjas
            // @deadline: 1 week```
@xkpx64 xkpx64 closed this as completed May 6, 2021
@xkpx64 xkpx64 reopened this May 7, 2021
@xkpx64 xkpx64 changed the title How to implement only in forms? How to implement in forms? May 7, 2021
@xkpx64
Copy link
Author

xkpx64 commented May 7, 2021

Also why there isn't option for SameSite lax/strict setup in cookie

@xkpx64
Copy link
Author

xkpx64 commented May 7, 2021

For everyone who want samesame in cookie settings and httponly
in csfrpCookieConfig.php add

if (isset($cfg['httponly'])) {
                    $this->httponly = (bool) $cfg['httponly'];
                }
				if (isset($cfg['samesite']) && $cfg['samesite']) {
                    $this->samesite = $cfg['samesite'];
                } 

and in csfrpprotector.php find setcookie

setcookie(
				self::$config['CSRFP_TOKEN'], 
				$token, 
				[
					'expires' => time() + self::$cookieConfig->expire,
					'path' => self::$cookieConfig->path,
					'domain' => self::$cookieConfig->domain, 
					'secure' => (bool) self::$cookieConfig->secure,
					'httponly' => (bool) self::$cookieConfig->httponly,
					'samesite' => self::$cookieConfig->samesite,
				]
			);

Now in config.php you can add this two fields in cookieConfig array

"cookieConfig" => array(
		"httponly" => true, 
		"samesite" => 'Lax' # None || Lax  || Strict
    ),

@akashmmcode
Copy link

can someone help me with a guide on how to implement it in forms?

@CassadyCampos
Copy link

What came out of this?
Is there something set up for forms or is it a manual process?

@CassadyCampos
Copy link

Ah nevermind. I see that it is set up to inject a hidden input field containing the CSRF token in the forms.

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

No branches or pull requests

3 participants