Skip to content
  • Hjem
  • Seneste
  • Etiketter
  • Populære
  • Verden
  • Bruger
  • Grupper
Temaer
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Kollaps
FARVEL BIG TECH
  1. Forside
  2. Technical Support
  3. Integrating NodeBB Write API with Keycloak SSO – Handling express.sid and CSRF Tokens

Integrating NodeBB Write API with Keycloak SSO – Handling express.sid and CSRF Tokens

Planlagt Fastgjort Låst Flyttet Technical Support
1 Indlæg 1 Posters 0 Visninger
  • Ældste til nyeste
  • Nyeste til ældste
  • Most Votes
Svar
  • Svar som emne
Login for at svare
Denne tråd er blevet slettet. Kun brugere med emne behandlings privilegier kan se den.
  • B This user is from outside of this forum
    B This user is from outside of this forum
    balu@community.nodebb.org
    wrote sidst redigeret af
    #1

    Hi julian,
    Thank you for your earlier response, and apologies for the late follow-up.

    I was able to resolve the CORS issue using Nginx. Now, I’m focusing on integrating the NodeBB Write API with my React.js frontend, where authentication is handled by Keycloak for login and registration.

    I have a question regarding the express.sid cookie:

    After login, NodeBB normally generates express.sid and stores it in cookies.

    I attempted to use this session ID to fetch the CSRF token by calling /api/config, but it doesn’t seem to work as expected.

    My goals are:

    Successfully retrieve a valid CSRF token.

    Use this token to create topics or posts via the Write API.

    Ensure that once I have the session + token, I can securely access NodeBB APIs from my frontend.

    Could you please clarify the correct approach for:

    Retrieving and using the CSRF token with the express.sid.

    Authenticating API requests (e.g., creating topics or posts) when using Keycloak SSO instead of NodeBB’s built-in login.

    Possible Approaches I’m Exploring:

    API Call to Generate express.sid via Keycloak SSO

    After successful Keycloak login, exchange the Keycloak access token with NodeBB to generate a valid express.sid.

    Then, use that session cookie + CSRF token for Write API calls.

    Alternative Session Handling Method

    Use Keycloak JWT directly, and extend NodeBB’s authentication middleware to validate Keycloak-issued tokens instead of relying on express.sid.

    This way, CSRF handling might be bypassed or adapted, depending on whether requests are authenticated via JWT.

    Any guidance or best practices for choosing between these two approaches (or a better method) would be greatly appreciated.

    Thanks in advance!

    1 Reply Last reply
    1
    0
    • System shared this topic
    Svar
    • Svar som emne
    Login for at svare
    • Ældste til nyeste
    • Nyeste til ældste
    • Most Votes


    • Log ind

    • Har du ikke en konto? Tilmeld

    • Login or register to search.
    Powered by NodeBB Contributors
    Graciously hosted by data.coop
    • First post
      Last post
    0
    • Hjem
    • Seneste
    • Etiketter
    • Populære
    • Verden
    • Bruger
    • Grupper