Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

129
Visualizações
What is the strategy on implementing a jwt auto login?

I'm new to jwt authorisation. Where I come from is just user and password authorisation without jwt. Now, that I learned the basics of jwt, I want to use is and here is my question:

In my login component, I collect email and password and of correct, I send a signed JWT to the user. I store that token with js-cookie. (I hope until here are no issues).

Now in my _app.js (I'm using nextjs) I think, if there is a component that requires data, I just built the app, as there was no login. Only thing I'd change, if the data fetch does not succeed, I'd send the user to the login screen. With that, the user would be auto logged in, as long he has the cookie and neither the cookie, nor the token, do expire.

Or is there a better approach?

Edit after reading the comments: In the mean time I added Auth0 login to my app. I disabled all sign ups and created the user in the Auth0 database. The downside for me is, that the setup of the app now takes longer, as I need to configure another third-party. But fair enough, when this increases the security.

But now my questions changes: Can I stop using JWT now, because I can trust the user, that is logged in? I'd say no, because the API is an open API without JWT protection, so anyhow my question did not really change?!

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You should not try to issue your own tokens, instead use a openid-connect certified token service (like KeyCloak, AzureAd, Auth0, Ping , IdentityServer...)

Secondly you should try to avoid storing tokens in a cookie or even in the browser. A video discussing the security issue is the one below that I can highly recommend:

alert‘OAuth 2 0’; // The impact of XSS on OAuth 2 0 in SPAs

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda