Skip to content

This project demonstrates a secure, token-based authentication system using Spring Boot, Kotlin, and JSON Web Tokens (JWT). It includes user registration, login, password reset, and account confirmation, ensuring best practices for security and scalability. The API is designed to be lightweight, running efficiently on a free-tier EC2 instance.

License

Notifications You must be signed in to change notification settings

Kenato254/spring-kotlin-authentication-demo

Repository files navigation

Spring Boot Kotlin Authentication API

Overview

This project demonstrates secure, token-based authentication built using Spring Boot, Kotlin, and JWT. The application is running on a free-tier EC2 instance, and it supports essential authentication operations such as user registration, login, password reset, and updating user information. Additionally, an Actuator server is available on port 8090 for monitoring and managing the application.

Features

  • User Registration: Register new users with email, password, and personal details.
  • Login: Authenticate users via email and password, and generate JWT tokens for secure access.
  • Password Reset: Send password reset tokens to user emails.
  • Update User Info: Modify user details using the user ID.
  • JWT-based Security: Protect API endpoints using JSON Web Tokens (JWT).
  • User Management: List all users, read individual user details, and delete users by ID.
  • Actuator Support: Monitor application health and performance using Spring Boot Actuator on port 8090.

API Endpoints

Authentication

  • Register User
    POST /auth/register
    Register a new user with the provided details.

  • Login User
    POST /auth/login
    Authenticate a user using email and password.

  • Forgot Password
    POST /auth/forgot-password
    Send a password reset token to the user’s email.

  • Reset Password
    POST /auth/reset-password
    Reset the password using the provided token.

  • Change Password
    POST /auth/change
    Change the password using the provided token.

User Management

  • List Users
    GET /auth/users
    Retrieve a list of all registered users.

  • Read User
    GET /auth/users/{id}
    Retrieve a user's details using their ID.

  • Update User
    PUT /auth/users/{id}update
    Update a user’s information by their ID.

  • Delete User
    DELETE /auth/users/{id}/delete
    Delete a user from the system using their ID.

Validate Account Changes

  • Validate Token
    GET /auth/validate-token?token={confirmationToken}
    Validates different operations that uses token validation.

Installation

Prerequisites

  • Java 21 or later
  • Kotlin
  • Gradle

Running the Project

  1. Clone the repository:
    git clone https://github.com/Kenato254/spring-kotlin-authentication-demo
  2. Navigate to the project directory:
    cd spring-kotlin-authentication-demo
  3. Build the project with Gradle:
    ./gradlew build
  4. Run the application:
    ./gradlew bootRun

The application will run locally at http://localhost:8080/api, and the Actuator endpoints will be accessible on http://localhost:8090.

API Documentation

The API is documented using OpenAPI/Swagger. After running the application, access the API documentation at:

http://localhost:8080/api/swagger-ui.html

License

This project is licensed under the MIT License.

Contact

For any issues or questions, reach out to:


Happy coding! 😊

About

This project demonstrates a secure, token-based authentication system using Spring Boot, Kotlin, and JSON Web Tokens (JWT). It includes user registration, login, password reset, and account confirmation, ensuring best practices for security and scalability. The API is designed to be lightweight, running efficiently on a free-tier EC2 instance.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published