#Keycloak with NextJS frontend and express backend

17 messages ยท Page 1 of 1 (latest)

clear spruceBOT
#

๐Ÿ”Ž This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

๐Ÿ•ต๏ธ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

โœ… You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

wintry grail
#

Just my first thoughts is you should treat them as seperate entities in a way. Im assuming keycloak is some sort of auth library?

#

Its basically another part of the stack, its own standalone authentication pattern?

#

Gotcha, I just read their home page

#

So, keyCloak im assuming authenticates you and passes something over to nextjs and or express?

#

a saml response or something like that?

#

I kind of have a similar situation at work.

#

side node: key cloak looks really interesting, the skeleton of a robust authentication provider.

#

thats open source* which is most interesting part

#

Yeah it makes sense, really neat. So when you go to your nextjs site unauthenticated, do you redirect to keycloak to handle the auth?

#

Thats what I do. its a good idea ๐Ÿ™‚ When a user authenticates to a 'realm' inside of keycloak, does keycloak know where to send you back to?

#

We call them realms at work, idk what the right word is

wintry grail
#

So I have essentially the exact same setup in my internal application, I dont use any extensions inside of nextjs or express to make it work (mostly because there is no library for it)

#

So you need the express and nextjs instance to 'share' a authentication token yeah? Is the express instance only acessible THROUGH the nextjs site? Or will other services hit the express api independantly?

wintry grail
#

Once you do the redirect, you should just cut off the connection to keyCloak.

#

If a user is navigating to /int/blah/blah and they arent authed, use middleware to set a cookie go auth then check if they have a redirect cookie and send em on there merry way

#

Just my two cents