{"id":26580102,"url":"https://github.com/kuldeepsingh99/authorization-authentication","last_synced_at":"2025-10-28T13:10:05.558Z","repository":{"id":210589593,"uuid":"112717747","full_name":"kuldeepsingh99/authorization-authentication","owner":"kuldeepsingh99","description":"Spring Token based authorization and authentication with spring boot and spring serurity","archived":false,"fork":false,"pushed_at":"2019-06-10T15:21:04.000Z","size":55,"stargazers_count":11,"open_issues_count":1,"forks_count":7,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-12-03T22:22:06.071Z","etag":null,"topics":["authentication","authorization","jwt","microservices","oauth","spring","spring-authorization","spring-boot","spring-security","token"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kuldeepsingh99.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-12-01T08:58:53.000Z","updated_at":"2023-12-03T22:22:08.482Z","dependencies_parsed_at":"2023-12-03T22:22:08.270Z","dependency_job_id":"1c55bacc-67bc-47d5-b964-4a853384a638","html_url":"https://github.com/kuldeepsingh99/authorization-authentication","commit_stats":null,"previous_names":["kuldeepsingh99/authorization-authentication"],"tags_count":0,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kuldeepsingh99%2Fauthorization-authentication","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kuldeepsingh99%2Fauthorization-authentication/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kuldeepsingh99%2Fauthorization-authentication/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kuldeepsingh99%2Fauthorization-authentication/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kuldeepsingh99","download_url":"https://codeload.github.com/kuldeepsingh99/authorization-authentication/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245066496,"owners_count":20555402,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["authentication","authorization","jwt","microservices","oauth","spring","spring-authorization","spring-boot","spring-security","token"],"created_at":"2025-03-23T06:30:25.770Z","updated_at":"2025-10-28T13:10:00.520Z","avatar_url":"https://github.com/kuldeepsingh99.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JWT Token based authorization and authentication mechanism with spring boot and spring security\n\nThis example can be used to develop Authorization Server and Microservice using JWT Token. This example explains how Authentication and Authorization works. It has two maven project \"Auth\" and \"Customer\". Both the project shares a common secret key.\n\n## Flow\n1. Client authenticate login credentials with Auth Service, if the login credentials are correct it will generate JWT Token and send it back to the client in header as well as in the response, so we are taking care of Authencation.\n\n2. The same JWT token we need to send in every request to access microservices, each microservice will validate the token and it also takes care of Authorization.\n\n![alt text](https://github.com/kuldeepsingh99/authorization-authentication/blob/master/images/AuthFlow.png \"Auth Flow\")\n\n# Auth:- service features #\n\nThis service validates the user credentials and generates JWT token\n\n1. Login Service (generating JWT Token) \n2. Refresh Service (generating new JWT Token)\n3. Registration Service ( Adding new User)\n\n# Customer:-  Project features #\n\nThis service validates JWT token and also takes care of Authentication\n\n## Steps to Install ##\n\n1. Execute tables.sql in MYSQL DB, it will create Database and two tables.\n2. Import both the maven project to eclipse or any other tool.\n3. Run mvn clean install one by one on both the projects.\n4. In Auth Project run this file **com.portal.auto.SpringBootWebApplication.java**  (it will start the server in 8080 port)\n5. In Customer Project run this file **com.portal.auto.CustomerApplication.java** (it will start the server in 9090 port)\n\n# End Points #\n\n### Register ###\n\nPOST /register HTTP/1.1\nHost: localhost:8080\nContent-Type: application/json\nCache-Control: no-cache\nPostman-Token: 6c4fb8a3-8eae-c3b7-7cfb-3afa56d1acd5\n\n**{\"name\":\"hello\",\"password\":\"123456\",\"confirmPassword\":\"123456\"}**\n\nIn the respose you will get Sucess or Failure JSON Message.\n\nEx.\n{\n  \"flag\": \"success\",\n  \"role\": null,\n  \"message\": \"User Registered Successfully, please login to continue\"\n}\n\nAfter Registration you will notice that It will create a record in users table with default ROLE and it will also create two records in usertoken table with two different usertype (WEB, ANDRIOD). \n\n**Note:- We need to store token for different devices seperately, we can modify this flow if we need.**  \n \n### Login ###\n\nPOST /login HTTP/1.1\nHost: localhost:8080\nContent-Type: application/json\nCache-Control: no-cache\nPostman-Token: 6e8ba103-3a95-83c3-7a95-694ec2cbfa12\n\n**{\"username\":\"hello\",\"password\":\"123456\",\"userType\":\"WEB\"}**\n\nResponse\n{\n    \"flag\": \"success\",\n    \"role\": \"ROLE_USER\",\n    \"message\": \"eyJhbGciOiJIUzUxMiJ9.eyJqdGkiOiI2ZTdjMmU1ZmI0MjY0NDc5YjY2ZmUyOGVhOWUyMDZiZiIsInN1YiI6ImFwb3N0ZWsiLCJpYXQiOjE1MTIxMTcyNTMsImV4cCI6MTUxMjExNzMxMywiaXNzIjoia3VsZGVlcC5jb20iLCJyb2xlIjoiUk9MRV9VU0VSIn0.e-Qdw5H8FpWpN7cNrZxDt7XS7hjL8CH7w9gExxEJzeHNSKYL9RTafWcGO9yhXB3-R3xjKMjmq2gva0fXMJIOOg\"\n}\n\nIt will return the access token on the response message as well in the header also.\n\n### Refresh ### \n\nPOST /refresh HTTP/1.1\nHost: localhost:8080\nContent-Type: application/json\nCache-Control: no-cache\nPostman-Token: 79508fec-630b-c5fb-3a11-3fd65105f1d0\n\n{\"username\":\"hello\",\"token\":\"eyJhbGciOiJIUzUxMiJ9.eyJqdGkiOiIxZDk4NGI2MTJmYjc0ZDg0YjBjZDEyM2ZlNzIzMDQ0NCIsInN1YiI6ImFkbWluIiwiaWF0IjoxNTEyMTE2MTk1LCJleHAiOjE1MTIxMTYyNTUsImlzcyI6Imt1bGRlZXAuY29tIiwicm9sZSI6IkFETUlOIn0.Ni6c9I12_QI634quXMl_OE1buucV92yLv5tj4bXL-j5KfMk68K3z4r7Q1pHQedMKPllWOvL0Ixw71JH0PWj9Hw\",\"userType\":\"WEB\"}\n\nHere we need to send the current token along with the user, else you won’t be able to get new token.\n\n\n\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkuldeepsingh99%2Fauthorization-authentication","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkuldeepsingh99%2Fauthorization-authentication","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkuldeepsingh99%2Fauthorization-authentication/lists"}