Skip to content

TeachMe-CloudUS/teachme-auth-utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

teachme-auth-utils

teachme-auth-utils is a Java library providing JWT-based authentication utilities for microservices within the teachme platform. It includes classes and filters to validate JWTs, handle authorization, and simplify token-based security configurations in Spring Boot applications.

Features

  • JWT validation, including expiration checks and claim extraction
  • JwtAuthenticationFilter to secure specific API endpoints based on JWT presence and validity

Getting Started

Prerequisites

  • Java 17 or higher
  • Spring Boot 3.x

Installation

Add the library as a dependency in your project’s pom.xml:

<dependency>
    <groupId>us.cloud.teachme</groupId>
    <artifactId>teachme-auth-utils</artifactId>
    <version>0.0.3-SNAPSHOT</version>
</dependency>

Then, add the repository where the library is hosted in your pom.xml:

<repositories>
    <repository>
        <id>github</id>
        <url>https://maven.pkg.github.com/TeachMe-CloudUS/teachme-auth-utils</url>
    </repository>
</repositories>

Finally, add your GitHub username and a personal access token to your ~/.m2/settings.xml file:

<settings>
    <servers>
        <server>
            <id>github</id>
            <username>{GITHUB_USERNAME}</username>
            <password>{GITHUB_TOKEN}</password>
        </server>
    </servers>
</settings>

Configuration

To use the library, configure the following properties in application.properties:

# Secret key for Jwt validation
security.jwt.secret-key=SECRET_KEY

# Paths that require authentication
security.jwt.protected-paths=/api/protected/*

# Paths that don't require authentication
security.jwt.white-listed-paths=/api/public/*

Usage

To register AuthSecurityConfiguration, import AuthSecurityConfiguration in your Spring configuration:

package us.cloud.teachme.yourservice;

import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import us.cloud.teachme.authutils.config.AuthSecurityConfiguration;

@Configuration
@Import(AuthSecurityConfiguration.class)
public class SecurityConfig {

}

About

Java Spring Boot library providing a JWT-based authentication filter for the teachme platform.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages