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

Support csrf tokens for the post endpoints #21

Open
mihaita-tinta opened this issue Sep 3, 2021 · 0 comments
Open

Support csrf tokens for the post endpoints #21

mihaita-tinta opened this issue Sep 3, 2021 · 0 comments

Comments

@mihaita-tinta
Copy link
Owner

mihaita-tinta commented Sep 3, 2021

We can customize the csrf repo to expose the token and send it from the browser:

http.csrf().csrfTokenRepository(withHttpOnlyFalse())

The fetch options should include the header with the cookie value:

<script type="module">

  let registrationElement = document.querySelector('webauthn-registration');
  registrationElement.registrationStartUrl = "/registration/start";
  registrationElement.registrationStartUrl = "/registration/finish";
  const csrf = ('; '+document.cookie).split(`; XSRF-TOKEN=`).pop().split(';')[0];
  console.log('headers:', registrationElement.fetchOptions);
  registrationElement.fetchOptions = {
    ...registrationElement.fetchOptions,
    headers: {
      ...registrationElement.fetchOptions.headers,
      'X-XSRF-TOKEN': csrf
    }
  };
//...
</script>
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

1 participant