• Stars
    star
    439
  • Rank 99,247 (Top 2 %)
  • Language
    Java
  • License
    GNU General Publi...
  • Created over 6 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Secures REST APIs with Spring Security and JWT Token based Authentication

spring-webmvc-jwt-sample

build

What is this?

This is a sample project demos how to use JWT token based authentication to protect the RESTful APIs in a Spring WebMVC application.

If you are interested in the new variant built with the Spring WebFlux stack, check spring-reactive-jwt-sample for more details.

Guide

Check the step-by-step GUIDE to get the detailed explanation of the example codes.

The original codes were written in Spring Boot 2.0, there are some slightly difference in the main/master branch due to the changes brought in the latest Spring Boot 3.0.

Prerequisites

Make sure you have installed the following software.

  • Java 17
  • Apache Maven 3.6.x
  • Docker

Build

Clone the source codes from Github.

git clone https://github.com/hantsy/spring-webmvc-jwt-sample

Open a terminal, and switch to the root folder of the project, and run the following command to build the whole project.

docker-compose up postgres // start up a postgres
mvn clean install // build the project

Run the application.

mvn spring-boot:run
// or from command line after building
java -jar target/xxx.jar

Contribution

Any suggestions are welcome, filing an issue or submitting a PR is also highly recommended.

More Repositories

1

spring-reactive-sample

Spring 5 Reactive playground
Java
1,228
star
2

nestjs-rest-sample

NestJS RESTful APIs Sample
TypeScript
328
star
3

angularjs-springmvc-sample-boot

A RESTful sample using Spring Boot, Spring MVC, Spring Data and Angular/Bootstrap.
Java
314
star
4

spring-microservice-sample

Spring Boot based Mircoservice sample
Java
298
star
5

angularjs-springmvc-sample

A RESTful sample using AnguarJS/Bootstrap as frontend and Spring MVC as REST API producer
Java
291
star
6

angular-spring-reactive-sample

RESTful API demos with Spring 5 WebFlux, Spring Boot 2, Spring Data Mongo, Spring Security, Spring Session and Angular (upgraded to v13)
TypeScript
224
star
7

spring-reactive-jwt-sample

Secures REST APIs with Spring Security and JWT Token-based Authentication powered by Spring Reactive stack
Java
161
star
8

spring-r2dbc-sample

Code samples for demonstrating R2dbc, Spring R2dbc, and Spring Data R2dbc.
Java
154
star
9

angularjs-cakephp-sample

A RESTful sample using AnguarJS/Bootstrap as frontend and CakePHP as REST API producer.
PHP
113
star
10

spring-puzzles

Code samples for tips, problem-resolving methods, patterns in Spring development
Java
79
star
11

spring-graphql-sample

Spring GraphQL examples using Netflix DGS, GraphQL Java and Spring GraphQL
Java
76
star
12

jakartaee9-starter-boilerplate

Jakarta EE 9 starter boilerplate project
Java
69
star
13

angularjs-grails-sample

A RESTful sample using AngularJS/Bootstrap as frontend and Grails as REST API producer
JavaScript
65
star
14

spring4-sandbox

Sample codes to demonstrate new features of Spring 4.x
Java
59
star
15

jakartaee8-starter-boilerplate

A boilerplate project for starting a Jakarta EE 8 application in seconds
Java
59
star
16

quarkus-sandbox

Quarkus playground
HTML
58
star
17

keycloak-springsecurity5-sample

Spring Security 5 OAuth2 Client/OIDC integration with Keycloak sample
Java
56
star
18

awesome-javaee8

Awesome Java EE 8 resource checklist
52
star
19

spring-kotlin-coroutines-sample

Spring Kotlin Coroutines sample
Kotlin
51
star
20

ee8-sandbox

Java EE 8/Jakarta EE 8 sandbox
Java
49
star
21

ee7-sandbox

Java EE 7 sandbox
Java
40
star
22

spring-sandbox

Spring demo application
Java
39
star
23

rsocket-sample

RSocket sandbox
Java
37
star
24

angularjs-zf2-sample

A RESTful sample using AngularJS/Bootstrap as frontend and Zend2 Framework as REST API producer
PHP
37
star
25

spring6-sandbox

Spring 6 and Spring Boot 3 playground
Java
34
star
26

symfony-rest-sample

Symfony REST Example
PHP
30
star
27

javaee8-jsf-sample

A Java EE 8 sample application
Java
29
star
28

javaee8-jaxrs-sample

RESTful APIs Demo built with Java EE 8 and JAXRS 2.1
Java
29
star
29

jakartaee-faces-sample

Jakarta EE 10 Faces Example
Java
27
star
30

angular-spring-rsocket-sample

Demo for using Angular and Spring RSocket together
TypeScript
26
star
31

vertx-sandbox

Eclipse Vertx playground
Java
24
star
32

spring-reactive-kotlin-sample

Spring 5 Webflux Demo built with Kotlin.
Kotlin
21
star
33

spring-native-example

Spring Native example application
Java
20
star
34

jakartaee9-servlet-starter-boilerplate

A Jakarta EE starter project boilerplate for Jakarta Servlet 5.0 (aligned with Jakarta EE 9) Container
Java
18
star
35

jakartaee-mvc-sample

Jakarta EE 10 MVC sample
Java
17
star
36

angular2-sample

Angular 2 sample with Angular CLI, TypeScript, Angular 2, Bootstrap 4, RxJS, JWT, Firebase/AngularFire2
TypeScript
17
star
37

ee7-jaxrs-sample

Building RESTful APIs with Java EE 7 and JAXRS
Java
17
star
38

javaee8-by-example-gitbook

A developer's notes for Java EE 8 upgrade
16
star
39

spring-webmvc-functional-sample

Spring MVC functional sample
Java
16
star
40

nestjs-graphql-sample

NestJS GraphQL Example
TypeScript
13
star
41

angular-spring-sse-sample

Demo for using Angular and Spring WebFlux Server Sent Events together
TypeScript
13
star
42

angular-spring-websocket-sample

Demo for using Angular and Spring Reactive WebSocket together
TypeScript
13
star
43

jakartaee-rest-sample

Jakarta EE 10 Rest Sample
Java
12
star
44

java-sandbox

The sandbox for playing the new features introduced in the next generation of Java.
Java
11
star
45

building-restful-apis-with-springmvc-gitbook

Gitbook source of Building RESTful APIs with Spring MVC
11
star
46

jakartaee10-sandbox

Jakarta EE 10 sandbox
Java
10
star
47

helidon-sandbox

Playground of helidon framework
Java
9
star
48

spring-reactive-microservice-sample

Spring Microservice Demo built with Spring 5 newly introduced Reactive stack
Java
9
star
49

spring-cloud-sample

Wires up Microservice with Spring Cloud
Java
9
star
50

spring-security-auth0-sample

Spring Security 5 with OAuth2/OIDC and Auth0 integration example
TypeScript
8
star
51

code-challenges

Code challenges in learning new languages, frameworks, engineering tools, architectures, software design patterns, etc.
Java
8
star
52

angular-es6-sample

AngularJS 1.5+ sample with ECMAScript 2015/ES6, Bootstrap 4 and Webpack
JavaScript
8
star
53

devops-sandbox

DevOps sandbox
Shell
7
star
54

spring-kotlin-dsl-sample

Spring Kotlin DSL, Spring Fu (Jafu, Kofu) demos
Kotlin
6
star
55

maven-archetype-jakartaee9

Maven archetype for Jakarta EE 9
Java
6
star
56

cargotracker-regapp

Cargotracker RegisterApp Client written in JavaFX
Java
5
star
57

seam3-sandbox

Seam 3 Sandbox to demostrate seam3 feature or reproduce my issues
HTML
5
star
58

nestjs-graphql-prisma-sample

Nestjs GraphQL Prisma Example
TypeScript
4
star
59

quarkus-auth0-sample

Secures Quarkus applications with OAuth2/Oidc and Auth0
Java
4
star
60

urlshortener-kotlin

Kotlin
3
star
61

reactor-examples

Reactor/ReactiveStreams sandbox
Java
3
star
62

angular-spring-book

Fullstack development with Angular and Spring(Boot)
Java
3
star
63

micronaut-sandbox

Micronaut playground
Java
3
star
64

angular2-material-sample

Angular 2 sample with Angular CLI, Angular 2 Material etc
TypeScript
3
star
65

click4nb

A NetBeans IDE plugin which provide basic support for the Apache Click framework
Java
3
star
66

angular2-firebase-sample

Angular 2 sample with Angular CLI, AngularFire2, Firebase etc
TypeScript
2
star
67

hantsy

it's me
2
star
68

hantsy.github.io

Personal website
HTML
2
star
69

jakartaee10-starter-boilerplate

Jakarta EE 10 Stater Boilerplate for starting a Jakarta EE 10 project
Java
2
star
70

react-spring-mongo-kotlin

React, Spring Boot, Spring Data Mongo, Kotlin Coroutines Example
Kotlin
1
star
71

nodejs-sandbox

NodeJS sandbox
HTML
1
star
72

contracts-git

Contracts for https://github.com/hantsy/spring-cloud-sample/tree/master/contract-producer-rest-git
Groovy
1
star
73

spring-security-reactive-auth0-sample

Spring Security Reactive and OAuth2(Auth0) Resource Example
Kotlin
1
star
74

kotlin-coroutines-examples

Kotlin Coroutines playground
Kotlin
1
star
75

angular-sandbox

Angular playground for Angular 2+
TypeScript
1
star