---
title: "Discussion on \"JWT authentication, The right way.\" | Hashnode"
description: "Discussion on \"JWT authentication, The right way.\". I've seen a lot of articles talking about the famous JWTs (JSON web tokens) and how to use them in your software application, but they don't really talk about how to secure them from popular web attacks like XSS (cross site scripting) or even the pop..."
url: "https://hashnode.com/posts/jwt-authentication-the-right-way/62f2df91408d676b1b58b2fb"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [JWT authentication, The right way.](https://vic3.hashnode.dev/jwt-authentication-the-right-way?utm_source=hashnode&utm_medium=feed)

I've seen a lot of articles talking about the famous JWTs (JSON web tokens) and how to use them in your software application, but they don't really talk about how to secure them from popular web attacks like XSS (cross site scripting) or even the pop...

Aug 9, 2022 · 6 min read · vic3.hashnode.dev  
Read the article

-   [#hacking](https://hashnode.com/tag/hacking)
-   [#javascript](https://hashnode.com/tag/javascript)
-   [#authentication](https://hashnode.com/tag/authentication)
-   [#web-development](https://hashnode.com/tag/web-development)

## Written by

[Vic okeke](https://hashnode.com/@vic3)

@vic3 · Nigeria

  
[View profile](https://hashnode.com/@vic3)

Your favourite software developer

Hey, I'm Vic Okeke, a software developer and niche blogger with a deep passion for programming and writing. I've been working in the software development industry for several years and have honed my skills in various programming languages and technologies. Through my extensive experience, I've become an expert in developing complex software applications and systems, working with teams to deliver high-quality solutions that meet business needs. In addition to my software development work, I have a keen interest in niche blogging. I started my blog as a way to document my experiences in the industry and share my knowledge with others who are just starting their journey in software development. Through my blog, I share insights and tips on programming, software engineering, and other topics that are relevant to the industry. As a passionate and dedicated software developer, I'm always looking for ways to improve my skills and stay up-to-date with the latest developments in the field. I'm committed to continuous learning and am constantly exploring new tools and techniques to improve my work. In this blog, I'll be sharing my expertise in software development, as well as my experiences and insights on niche blogging. Whether you're an experienced developer looking to expand your knowledge or a beginner just starting out, my blog is a valuable resource that you won't want to miss.

## Responses 2

Markdown supported · ⌘↵ to post

[Amolo](https://hashnode.com/@amolo)

[Aug 10, 2022](https://hashnode.com/posts/jwt-authentication-the-right-way/62f2df91408d676b1b58b2fb/comment/62f4294531be20833796e0e4)

Great article!

[Vic okeke](https://hashnode.com/@vic3)

[Aug 11, 2022](https://hashnode.com/posts/jwt-authentication-the-right-way/62f2df91408d676b1b58b2fb/comment/62f4294531be20833796e0e4#reply-62f4e64831be20833796f77d)

Thank you

[Osinachi Chukwujama](https://hashnode.com/@Vicradon)

[Aug 10, 2022](https://hashnode.com/posts/jwt-authentication-the-right-way/62f2df91408d676b1b58b2fb/comment/62f3973e445b4c80c2b8bdc6)

Nice article man. I have one question.

What if I'm building a payment service like Paystack and I need to allow a different users access my API? How can I enforce CORS in such a case?

[Vic okeke](https://hashnode.com/@vic3)

[Aug 10, 2022](https://hashnode.com/posts/jwt-authentication-the-right-way/62f2df91408d676b1b58b2fb/comment/62f3973e445b4c80c2b8bdc6#reply-62f39c1d8902bf81fe536b4d)

Yeah, you can request for their domains while they sign-up for your API, then store in a database, you then fetch all domains into an array/list is an accepted format in the cors origin option

[Amolo](https://hashnode.com/@amolo)

[Aug 10, 2022](https://hashnode.com/posts/jwt-authentication-the-right-way/62f2df91408d676b1b58b2fb/comment/62f3973e445b4c80c2b8bdc6#reply-62f4293631be20833796e0dc)

Additionally, such APIs don't restrict which "origin" calls them. You probably want to pass the JWT as a header or something in that line.
