Want authenticate user (new user) from other sites

Describe the issue/error/question

Hi.
I have created different workflows and have to invite multiple users, for this I have configure SMTP setup and its working fine.

But there are multiple users on my site and want that each user can create his own workflow. As they are already logged-in/signed-up to my site, with these login details I want to authenticate them to n8n. They don’t have to specifically signup or login on n8n, Through this they can play around on workflows

Information on your n8n setup

  • n8n version: 0.194.0
  • Database you’re using (default: SQLite):
  • Running n8n with the execution process [own(default)]:
  • Running n8n via [Docker]:

Hey @Ammar_Afzal,

Welcome to the community :tada:

Just to double check are these users signing into your site first and you want them to also be able to access n8n using the same details / user session?

It sounds like you might want the JWT option to authenticate your users but it also sounds like you might need an embed license as well depending on what your site is doing and what you are allowing users to do.

I don’t have any examples for using JWT auth but you can find the environment options that would need be set here: Environment variables - n8n Documentation

Thanks @Jon for reply. Yes they are already signed up. and exactly I want JWT option for authentication. but I don’t know how I can achieve this maybe.

@Jon I have added following environment variables

  # - N8N_JWT_AUTH_ACTIVE=true
  # - N8N_JWT_AUTH_HEADER=Authorization
  # - N8N_JWT_AUTH_HEADER_VALUE_PREFIX=Bearer
  # - N8N_JWKS_URI=https://n8n.eu.auth0.com/.well-known/jwks.json

But now when I am trying to authenticate it shows me error ( invalid token ).

Can you assist me that, from where I can get the JWT token of logged in user in n8n?
Thanks

Hey @Ammar_Afzal,

From what I understand we should try to get the token from N8N_JWT_AUTH_HEADER so looking at your config there (assuming you commented them out when it didn’t work) you should have a header called Authorization set with a value of Bearer xxxxxx

Hi @Jon Thank you for your response.

I am testing it through postman and attaching screenshot of request. Is this correct way. if not can you help me out.

On browser I am getting this error.

image

yes i have commented them out when it did not work.

Hey @Ammar_Afzal,

The JWT implementation is one of those things where we don’t have any examples for like Tom mentioned yesterday on the other post.

What you have looks to be right to me but I am not sure why the token is coming back as being invalid. Does it maybe not need the n8n-auth part?

To work it out I will need to set aside some time to do some proper testing which I am probably not going to be able to do this week.

Looking at the PR quickly though there are other options that can also be set which are below, Have you tried setting them all to match your environment? I suspect if you are using the user management feature of n8n this will also fail.

N8N_JWT_AUTH_ACTIVE=true 
N8N_JWT_AUTH_HEADER=Authorization 
N8N_JWKS_URI="https://acme.auth0.com/.well-known/jwks.json" 
N8N_JWT_AUTH_HEADER_VALUE_PREFIX=Bearer 
N8N_JWT_ISSUER="https://acme.auth0.com/" 
N8N_JWT_NAMESPACE="https://api.acme.com" 
N8N_JWT_ALLOWED_TENANT_KEY=tenantId 
N8N_JWT_ALLOWED_TENANT=my-acme-tenant