Git Product home page Git Product logo

sdvillaruziii / jwt-spring-boot-angular-scaffolding Goto Github PK

View Code? Open in Web Editor NEW

This project forked from little-pinecone/jwt-spring-boot-angular-scaffolding

0.0 0.0 0.0 977 KB

Java 11, Spring Boot and Angular multi-module project secured with JWT that builds as a single jar.

Home Page: https://keepgrowing.in/java/springboot/securing-your-spring-boot-and-angular-app-with-jwt-1-introduction/

License: The Unlicense

Java 57.32% JavaScript 2.46% TypeScript 35.38% HTML 4.58% CSS 0.27%

jwt-spring-boot-angular-scaffolding's Introduction

jwt-spring-boot-angular-scaffolding

keep growing logo

This project is a multi-module application, using Spring Boot for the backend and Angular for the frontend. The project can be built into a single jar file using Maven. You can also run the modules separately during development.

The backend and frontend are secured with JSON Web Token.

To learn how to set up a project like this one, check out the following posts:

Getting Started

To clone the repository, run in the command line:

$ git clone https://github.com/little-pinecone/jwt-spring-boot-angular-scaffolding.git

You can build the application with:

$ mvn clean install

Sign up request

You need to create a test user:

sign up request screenshot

  • path: http://localhost:8080/api/users

  • body:

{
    "userCredentials": {
        "username": "user",
        "password": "test"
    }
}

Add CSRF token to requests from Postman

  • Copy this code to the Tests tab for the mutable requests:
var xsrfCookie = postman.getResponseCookie("XSRF-TOKEN");
pm.globals.set('csrftoken', xsrfCookie.value);

add csrf to postman screenshot

  • Add the X-XSRF-TOKEN header that will use the {{csrftoken}} variable:

add csrf to postman screenshot

Overview and technical features

  • The project currently serves a login page and hard-coded pastry data returned from the API.
  • It allows registering new users, handles login requests.
  • It serves data from the API to authenticated and authorized users.
  • The user experience is enhanced thanks to the AuthGuard implementation.

Running tests

Run all backend tests with the following command in the root directory:

$ mvn test

Run all frontend tests with the following command in the frontend/src/main/angular directory:

$ ng test

Running in production

Set the target url in frontend/src/main/angular/src/proxy.conf.json to the path for the right environment. Add the "changeOrigin": true option if your backend is not running on localhost (Angular proxy documentation).

Override the default TokenProperties values. E.g. to override the expiration time of tokens you can add security.jwt.expiration=your_value to the application.properties file.

Built With

Screenshots

login page cookies

jwt-spring-boot-angular-scaffolding's People

Contributors

little-pinecone avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.