Code Monkey home page Code Monkey logo

springboot-vuejs-auth's Introduction

Spring boot + Vue.js auth sample

this is demo project for spring boot + vue.js with maven multi module.

  • backend : spring boot with OAuth2 server
  • frontend : vuejs with client app

Project structure

app@app:~/springboot-vuejs-auth$ tree ./ -L 2
./
├── backend         -> Server code
│   ├── pom.xml
│   ├── src
├── frontend        -> Vue.js code
│   ├── src
│   ├── pom.xml     
├── lombok.config
├── pom.xml         -> Maven parent pom

Getting access token from API(backend) by using POST MAN

http://localhost:3000/api/oauth/token

Authorization
- type : Basic Auth
- Username : myApp
- Password : pass

Body
x-www-form-urlencoded
username : user@email.com
password : user
grant_type : password

Api

Request Response
/api/home (with no token) Hello Anonymous!
/api/home (with token) Hello {email}!
/api/me (with no token) 401 error
/api/me (with token) {"email" : "[email protected]", "roles" : ["USER"]}

Getting started

  1. build frontend & running backend
$ git clone https://github.com/zacscoding/springboot-vuejs-auth.git
$ cd springboot-vuejs-auth
$ mvn clean install
$ java -jar backend/target/backend-1.0-SNAPSHOT.jar
OR
$ mvn --projects backend spring-boot:run

and then connect to http://localhost:3000/

  1. running respectively

backend with spring boot

$ cd backend
$ mvn spring-boot:run

frontend with webpack-dev-server

$ cd frontend
$ npm start

and then connect to http://localhost:8080/

Demos

  • home (with no sign in)

home_with_no_sign_in

  • home (with sign in)

home_with_sign_in

  • me (with sign in)

me with sign in

  • me (with no sign in)

=> then redirect to "/login?returnPath=me"

References

springboot-vuejs-auth's People

Contributors

zacscoding avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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