Giter VIP home page Giter VIP logo

jwtappdemo's Introduction

JwtAppDemo

Добавить тестового пользователя, который может логиниться, то есть получить токен по имени пользователя username (password - test)

INSERT INTO users VALUES
(1, 'tony', '[email protected]', 'tony', 'montana', '$2a$04$r9rQ13FJevYTFl10KVyTDOBIi5UuVb8tTfcevI.B/Qw0lVksesere', '2020-07-14T10:56:51', '2020-07-14T10:56:51', 'ACTIVE');

Добавить роли

INSERT INTO roles VALUES
(1, 'ROLE_USER', '2020-07-14T10:56:51', '2020-07-14T10:56:51', 'ACTIVE'),
(2, 'ROLE_ADMIN', '2020-07-14T10:56:51', '2020-07-14T10:56:51', 'ACTIVE');

Добавить роли пользователя и админа для tony

INSERT INTO user_roles VALUES (1, 1), (1, 2);

Получить токен можно отправив запрос POST http://loaclhost:8085/api/v1/auth/login c телом {"username": "tony", "password": "test"}

Запросить информацию по пользователю GET http://localhost:8085/api/v1/admin/users/1 c хедером Authentication: Bearer_{jwtToken}

Добавить просто пользователя (не админа)

INSERT INTO users VALUES
(2, 'testuser', '[email protected]', 'simpleuser', 'test', '$2a$04$r9rQ13FJevYTFl10KVyTDOBIi5UuVb8tTfcevI.B/Qw0lVksesere', '2020-07-15T10:00:00', '2020-07-15T10:00:00', 'ACTIVE');

INSERT INTO user_roles VALUES (2, 1);

testuser после получения токена api/v1/auth/login может смотреть пользователей через /api/v1/users/{id} и не может через api/v1/admin/users/{id} из-за настроек в SecurityConfig

jwtappdemo's People

Contributors

tral909 avatar dependabot[bot] 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.