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

Authentication fixes for the SDK #19354

Merged
merged 48 commits into from
Sep 4, 2023
Merged

Authentication fixes for the SDK #19354

merged 48 commits into from
Sep 4, 2023

Conversation

br41nslug
Copy link
Member

@br41nslug br41nslug commented Aug 4, 2023

Same-origin cookies:

  • This is what fetch does out of the box

Cross-origin cookies:

  • You'll want to set credentials: 'include' on the appropriate composables to send cookies with all requests on that composable
    const client = createDirectus(URL)
      .with(authentication('json', { autoRefresh: false, credentials: 'include' }))
      .with(graphql({ credentials: 'include' }))
      .with(rest({ credentials: 'include' }))
  • Or on specific REST requests using the withOptions helper
    const result = await client.request(withOptions(
      readItems('some-collection'),
      { credentials: 'include' }
    ))

Note: Make sure to double check your CORS and CSP settings when working with cross-origin cookies.

@changeset-bot
Copy link

changeset-bot bot commented Aug 4, 2023

🦋 Changeset detected

Latest commit: 30bad9d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
docs Patch
@directus/sdk Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@javiercornejo

This comment was marked as resolved.

@Jon1VK

This comment was marked as resolved.

@br41nslug

This comment was marked as resolved.

Copy link
Member

@paescuj paescuj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good , besides the little comment 👍

sdk/src/auth/types.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@azrikahar azrikahar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR LGTM! Just a quick question regarding the breaking-changes.md, do we need to mention/include the renaming of asSearch to withSearch as well?

@br41nslug
Copy link
Member Author

PR LGTM! Just a quick question regarding the breaking-changes.md, do we need to mention/include the renaming of asSearch to withSearch as well?

Yes we do, nice catch

br41nslug and others added 2 commits September 4, 2023 17:29
Co-authored-by: Pascal Jufer <pascal-jufer@bluewin.ch>
Co-authored-by: Pascal Jufer <pascal-jufer@bluewin.ch>
@paescuj paescuj merged commit 6c95cfb into main Sep 4, 2023
7 checks passed
@paescuj paescuj deleted the sdk-fixes-4 branch September 4, 2023 15:39
@github-actions github-actions bot added this to the Next Release milestone Sep 4, 2023
@br41nslug br41nslug mentioned this pull request Sep 20, 2023
br-rafaelbarros pushed a commit to personal-forks/directus-source that referenced this pull request Nov 7, 2023
Co-authored-by: Pascal Jufer <pascal-jufer@bluewin.ch>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SDK 11: It's impossible to include credentials with AuthenticationClient methods
6 participants