Stuart Watt
Stuart Watt

Reputation: 5401

How to integrate node-oidc-provider with SvelteKit

I'm puzzled about how to integrate oidc-provider specifically with SvelteKit, and if anybody has any ideas, I'd love to hear them.

Fundamentally, this match comes with the way SvelteKit generates responses in a different way. Standard Node.js things like Express all use a middleware model which is passed both a request and a response. But SvelteKit doesn't do that, it processes a request and generates a response.

All is fine until you start working on displays for forms with oidc-provider, and attempt to use SvelteKit. Interactions require you to retrieve details using something like:

expressApp.get('/interaction/:uid', async (req, res) => {
  const details = await provider.interactionDetails(req, res);
  // ...
});

which, of course, you can'd trivially do in SvelteKit, on account of not having a response at all. Annoyingly, the integration all works pretty well until you start building your own user flows.

Maybe there's some magic technique to this, or maybe I just have to bail and abandon SvelteKit for the interactions (I can use them for everything else in the app). That seems a shame.

I'd guess that once I have committed to a given adapter I can hack the response into event locals in SvelteKit, and then retrieve it, but that'll only work in production, not development, which is less than ideal as a developer experience, since basically no authentication will ever work in development.

Upvotes: 1

Views: 58

Answers (0)

Related Questions