Skip to content

Conversation

@nirtamir2
Copy link

@nirtamir2 nirtamir2 commented Apr 5, 2024

This PR export cookieOptions, cookieName and encryptSession from WorkOS.
The motivation to do it is for people who try to implement the authentication themself and need to copy the code from this repository (that may change in the future). Also, I need to install iron-session as a dependency in my project if I implement it myself.

Alternatively, I could create a function that sets the cookie like the SDK instead of writing this code the codebase:

        const session = await encryptSession({ accessToken, refreshToken, user, impersonator });
        cookies().set(cookieName, session, cookieOptions);

Notes:

I still haven't organized everything properly with my implementation, but it seems like I need to export those parts from the SDK to implement it. Feel free to change or block this PR if you feel it's wrong :)

@nirtamir2 nirtamir2 changed the title export cookieName from workos export cookieName, cookieOptions and encryptSession Apr 5, 2024
@PaulAsjes
Copy link
Contributor

Thanks for the PR! We're going to discuss a bit internally on what the best course of action here is. We're thinking in particular on how we can make some high-level abstractions to make this easier on you.

@gabrielalmeida
Copy link

High-level abstractions would be great but just exporting those would make the library useful to anyone migrating from other session management implementations, right now it assumes you don't have a previous one in place.

We are doing the same copy/paste + iron-session dependency to properly migrate our users from their previous sessions.

@PaulAsjes
Copy link
Contributor

Higher level abstractions now exist in the Node SDK: https://workos.com/docs/reference/user-management/session-helpers

@PaulAsjes PaulAsjes closed this Sep 26, 2024
ajworkos pushed a commit to ajworkos/authkit-nextjs that referenced this pull request Aug 29, 2025
upgrade authkit-nextjs dep and add minimal permissions example
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants