Skip to content

A lightweight Java library for creating, signing, and validating JSON Web Tokens (JWT). Designed as a reusable dependency for backend services that require authentication and secure token handling.

Notifications You must be signed in to change notification settings

tysker/jwt_security_dependency

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🔐 JWT Token Dependency

A lightweight Java library for creating, signing, and validating JSON Web Tokens (JWT).
Designed as a reusable dependency for backend services that require authentication and secure token handling.


🧰 Tech Stack

Java JWT Maven


📌 Overview

This module provides:

  • 🔑 JWT token generation
  • 🔍 Token validation and signature verification
  • 🕒 Support for expiration times
  • 🧪 Small and dependency-friendly design
  • 🔄 Easy integration in Javalin, Spring, Ktor, or any backend service

Perfect for microservices, standalone Java apps, or students learning authentication mechanics.


🚀 Installation

Maven

<dependency>
    <groupId>com.yourname</groupId>
    <artifactId>jwt-token-dependency</artifactId>
    <version>1.0.0</version>
</dependency>

(Replace groupId/artifactId/version with your actual values.)

Gradle

implementation 'com.yourname:jwt-token-dependency:1.0.0'

✨ Usage

▶️ Create a Token

JwtService jwt = new JwtService("super-secret-key", 30 * 60 * 1000);

String token = jwt.createToken("user123");
System.out.println(token);

▶️ Validate a Token

JwtService jwt = new JwtService("super-secret-key", 30 * 60 * 1000);

boolean isValid = jwt.validateToken(token);

if (isValid) {
    String userId = jwt.getSubject(token);
    System.out.println("Authenticated user: " + userId);
}

🎛️ Configuration Options

Setting Description
SECRET_KEY The signing key used to sign tokens
TOKEN_EXPIRE_TIME Expiration time in milliseconds
ISSUER (Optional) token issuer identity

🧱 Architecture Diagram (ASCII)

               +------------------------+
               |     Your Backend       |
               |  (Javalin / Spring)    |
               +-----------+------------+
                           |
                           | uses
                           v
               +------------------------+
               |  JWT Token Dependency  |
               |  - createToken()       |
               |  - validateToken()     |
               |  - getSubject()        |
               +-----------+------------+
                           |
                           | generates / validates
                           v
                  +-----------------+
                  |     JWT Token   |
                  |   (signed JWT)  |
                  +-----------------+

🧪 Testing

If the project includes tests:

mvn test

📦 Packaging

To publish locally:

mvn clean install

To publish to Maven Central or a private repository, add your distributionManagement settings.


📜 License

MIT License (or whatever license you choose).


🙌 Contributing

Pull requests are welcome. Feel free to open issues for bug reports or feature requests.

About

A lightweight Java library for creating, signing, and validating JSON Web Tokens (JWT). Designed as a reusable dependency for backend services that require authentication and secure token handling.

Topics

Resources

Stars

Watchers

Forks

Packages