Saltar al contenido

Flujo de Cliente OIDC para Autenticación de Usuarios

Implementa un cliente OpenID Connect (OIDC) para gestionar la autenticación de usuarios. Procesa códigos de autorización, intercambia tokens, obtiene información del usuario y sirve una página de bienvenida o un formulario de login. Soporta PKCE.

15 nodos 8 tipos conectado
Cargando workflow...

Nodos

Webhook Code HttpRequest RespondToWebhook If Html StickyNote Set

Herramientas

OpenID Connect HTTP Request Custom Code HTML Webhook

Detalles

ID
1997
Nodos
15
Conex.
Tipos
8

Pertenece a:

¿Qué hace este workflow?

Este workflow permite implementar un cliente OpenID Connect (OIDC) robusto directamente en n8n, ideal para cualquier aplicación o servicio que necesite gestionar la autenticación de usuarios. Se encarga de todo el flujo estándar OIDC, desde la recepción de códigos de autorización hasta el intercambio de tokens (tanto de acceso como de ID) y la obtención de información detallada del usuario. Además, soporta el estándar PKCE (Proof Key for Code Exchange) para una seguridad reforzada contra ataques de intercepción de códigos. Al procesar la lógica de autenticación dentro de n8n, puedes servir dinámicamente una página de bienvenida personalizada para usuarios autenticados o un formulario de login para nuevos accesos, ofreciendo una experiencia de usuario fluida y segura. Esto minimiza la complejidad de gestionar la autenticación en tu propia aplicación, liberando recursos de desarrollo y asegurando un proceso de login conforme a los estándares de seguridad modernos, mientras mantienes el control total sobre los datos de usuario.

¿Cómo funciona?

Este workflow usa 15 nodos conectados con 8 tipos diferentes: Webhook, Code, HttpRequest, RespondToWebhook, If y 3 más. La estructura está totalmente conectada — listo para importar.

¿Para quién es?

Diseñado para equipos de IT & DevOps. Nivel intermedio — necesitas familiaridad con n8n.

¿Lo quieres en tu empresa?

Lo implementamos por ti end-to-end: integración, deploy, mantenimiento y soporte. Consultoría B2B con Genai Sapiens.

Hablemos de tu proyecto

¿Quieres aprender a hacerlo?

Sprints de 30 días con companion IA + comunidad. Aprende n8n, automatización y agentes IA desde cero o nivel avanzado.

Ver formación Momentum

Workflows similares

\n \n"},"typeVersion":1},{"id":"12395c64-1c9d-4801-8229-57d982e4243f","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[120,460],"parameters":{"width":510,"height":207,"content":"In this set, you have to retrieve from your identity provider : \n- auth url\n- token url\n- userinfo url\n- the client id you created for this flow\n- scopes to use, at least \"openid\" scope\nif you do not want to use PKCE, you have to fill : \n- client_secret\n- redirect_uri (which is the webhook uri)"},"typeVersion":1},{"id":"25e934b5-fcd6-49e1-bb33-955b5f3f34ca","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[1640,480],"parameters":{"content":"At this point the user is authenticated, you have access to his profile from the user info result and you continue doing things"},"typeVersion":1},{"id":"9dab372a-3505-4be6-93bd-9e99fc71612c","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[460,980],"parameters":{"width":776,"height":336,"content":"## Quick setup with Keycloak\n1. Open your Keycloak\n2. Go to `Realm settings` and opn `OpenID Endpoint Configuration`\n3. This will opene a new tab. Copy out the `authorization_endpoint`, `token_endpoint` and the `userinfo_endpoint` and add it to the `Set variables` node\n4. Go go `Clients` and click `Create client`. In there pick a name of choice.\n5. Go to the next step, `Capability config`, disable `Client authentication`. Only `Standard flow` should be checked.\n6. Go to the next step `Login settings`. In there copy the Webhook URL of this workflow into the `Valid redirect URIs` field\n7. Enter the clientID to the `Set variables` node\n\nNow you can activate the workflow and visit the webhook URL to test. You can find a more detailed setup guid in the description.\n"},"typeVersion":1},{"id":"6e3afc62-52a9-402a-bde9-e8798d0fd4f6","name":"Set variables : auth, token, userinfo, client id, scope","type":"n8n-nodes-base.set","position":[320,680],"parameters":{"values":{"string":[{"name":"auth_endpoint","value":"Your value here"},{"name":"token_endpoint","value":"Your value here"},{"name":"userinfo_endpoint","value":"Your value here"},{"name":"client_id","value":"name of your client"},{"name":"scope","value":"openid"},{"name":"redirect_uri","value":"webhook uri"},{"name":"client_secret","value":"secret of your client"}],"boolean":[{"name":"PKCE","value":true}]},"options":{}},"typeVersion":2},{"id":"2d54c64a-ae45-480f-923f-63d6cb3fcdfc","name":"IF we have code in URI and not in PKCE mode","type":"n8n-nodes-base.if","position":[700,680],"parameters":{"conditions":{"string":[{"value1":"={{ $('Webhook').item.json.query.code }}","operation":"isNotEmpty"}],"boolean":[{"value1":"={{ $('Set variables : auth, token, userinfo, client id, scope').item.json.PKCE }}"}]}},"typeVersion":1},{"id":"99c8fa5d-3173-4371-9742-6014eca6e7fe","name":"get access_token from /token endpoint with code","type":"n8n-nodes-base.httpRequest","position":[940,640],"parameters":{"url":"={{ $('Set variables : auth, token, userinfo, client id, scope').item.json.token_endpoint }}","method":"POST","options":{},"sendBody":true,"contentType":"form-urlencoded","bodyParameters":{"parameters":[{"name":"grant_type","value":"authorization_code"},{"name":"client_id","value":"={{ $('Set variables : auth, token, userinfo, client id, scope').item.json.client_id }}"},{"name":"client_secret","value":"={{ $('Set variables : auth, token, userinfo, client id, scope').item.json.client_secret }}"},{"name":"code","value":"={{ $('Webhook').item.json.query.code }}"},{"name":"redirect_uri","value":"={{ $('Set variables : auth, token, userinfo, client id, scope').item.json.redirect_uri }}"}]}},"typeVersion":4.1}],"active":true,"pinData":{},"settings":{"executionOrder":"v1"},"versionId":"d91ac207-6f83-42cd-9c9f-326b8c53c160","connections":{"Code":{"main":[[{"node":"IF we have code in URI and not in PKCE mode","type":"main","index":0}]]},"Webhook":{"main":[[{"node":"Set variables : auth, token, userinfo, client id, scope","type":"main","index":0}]]},"user info":{"main":[[{"node":"IF user info ok","type":"main","index":0}]]},"login form":{"main":[[{"node":"send back login page","type":"main","index":0}]]},"Welcome page":{"main":[[{"node":"send back welcome page","type":"main","index":0}]]},"IF user info ok":{"main":[[{"node":"Welcome page","type":"main","index":0}],[{"node":"login form","type":"main","index":0}]]},"IF token is present":{"main":[[{"node":"user info","type":"main","index":0}],[{"node":"login form","type":"main","index":0}]]},"IF we have code in URI and not in PKCE mode":{"main":[[{"node":"get access_token from /token endpoint with code","type":"main","index":0}],[{"node":"IF token is present","type":"main","index":0}]]},"get access_token from /token endpoint with code":{"main":[[{"node":"user info","type":"main","index":0}]]},"Set variables : auth, token, userinfo, client id, scope":{"main":[[{"node":"Code","type":"main","index":0}]]}}}