Giter Club home page Giter Club logo

ieti-lab8's Introduction

2.2 Spring Boot Secure API

Goals

  • Implement a secure API using the JSON Web Token open standard (RFC 7519).
  • Consume the API from a React JS application.

Part 1: Implement the API

  1. Clone this repository. Compile and run the Spring Boot project.

  2. Verify that authentication works by issuing the following command from the console:

This only works in Java 8 If Java 11 is used, I get this error

Java11Error

With Java 8

Java8Fix

  1. Open the following url and try to understand the message you get from the server:

http://localhost:8080/api/test

Test1

Then try to locate the code fragment where the exception is thrown.

  1. Comment the line 13 @Bean on the SpringBootSecureApiApplication class. Re-run the project and go to the endpoint again:

http://localhost:8080/api/test

Test2

Why do you think it works now? Discuss your findings with your classmates.

  • Works because the security for the path api/* was disabled
  1. Implement the logic to verify the user's credentials on the UserController and the UserServiceImpl classes.

Security1

Security2

  1. Add the TaskController and services implemented on the previous lab. Ensure the endpoints are exposed under the /api path.

  2. Verify that your implementation secures all the exposed methods under the /api path in your API.

endpoint

Part 2: Consume the API from ReactJS project

Done

Implement an API call in the Login View
  1. Make a first request to the API to authenticate on the method componentDidMount():

axiosLogin

Done

Make other calls to your API

AxiosPost

Done

ieti-lab8's People

Contributors

sancarbar avatar jualme avatar

Watchers

James Cloos avatar  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.