{"id":13538707,"url":"https://github.com/tinmegali/Oauth2-Stateless-Authentication-with-Spring-and-JWT-Token","last_synced_at":"2025-04-02T05:31:43.263Z","repository":{"id":75887407,"uuid":"94943682","full_name":"tinmegali/Oauth2-Stateless-Authentication-with-Spring-and-JWT-Token","owner":"tinmegali","description":"Oauth2 Stateless Authentication with Spring and JWT Token","archived":false,"fork":false,"pushed_at":"2018-10-02T08:50:57.000Z","size":545,"stargazers_count":109,"open_issues_count":2,"forks_count":46,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-11-03T03:31:57.788Z","etag":null,"topics":["h2-database","oauth2","spring-boot","spring-security","spring-security-oauth2"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tinmegali.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-06-20T23:32:36.000Z","updated_at":"2024-08-08T11:29:14.000Z","dependencies_parsed_at":"2023-07-11T23:46:06.623Z","dependency_job_id":null,"html_url":"https://github.com/tinmegali/Oauth2-Stateless-Authentication-with-Spring-and-JWT-Token","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinmegali%2FOauth2-Stateless-Authentication-with-Spring-and-JWT-Token","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinmegali%2FOauth2-Stateless-Authentication-with-Spring-and-JWT-Token/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinmegali%2FOauth2-Stateless-Authentication-with-Spring-and-JWT-Token/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinmegali%2FOauth2-Stateless-Authentication-with-Spring-and-JWT-Token/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tinmegali","download_url":"https://codeload.github.com/tinmegali/Oauth2-Stateless-Authentication-with-Spring-and-JWT-Token/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246763805,"owners_count":20829795,"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":["h2-database","oauth2","spring-boot","spring-security","spring-security-oauth2"],"created_at":"2024-08-01T09:01:15.008Z","updated_at":"2025-04-02T05:31:38.890Z","avatar_url":"https://github.com/tinmegali.png","language":"Java","funding_links":[],"categories":["Java"],"sub_categories":[],"readme":"\u003ch1\u003e\nOauth2 Stateless Authentication with Spring and JWT Token\n\u003c/h1\u003e\n\u003cp\u003e\nThis project uses \u003cem\u003eSpring Security\u003c/em\u003e to authenticate and protect some Rest resources.\n It uses \u003ccode\u003ewithAuthorizationServerConfigurerAdapter\u003c/code\u003e, \u003ccode\u003eResourceServerConfigurerAdapter\u003c/code\u003e\n  and \u003ccode\u003eWebSecurityConfigurerAdapter\u003c/code\u003e combined with \u003ccode\u003e@PreAuthorize\u003c/code\u003e to configure the security.\n  It also uses an \u003cem\u003eH2 embeded database\u003c/em\u003e to authenticate the users.\n\u003c/p\u003e\n\n\u003ch4\u003eArticle on the project\u003c/h4\u003e\n\u003ca href=\"http://www.tinmegali.com/en/2017/06/25/oauth2-using-spring/\"\u003eUSING SPRING OAUTH2 TO SECURE REST\u003c/a\u003e\n\n\u003ch4\u003eExternal references\u003c/h4\u003e\nThis project was inspired by all these references.\n\u003cli\u003e \u003ca href=\"http://www.baeldung.com/spring-security-oauth-jwt\"\u003eUsing JWT with Spring Security OAuth\u003c/a\u003e\n\u003cli\u003e \u003ca href=\"https://sdqali.in/blog/2016/07/13/jwt-authentication-with-spring-web---part-5/\"\u003eJWT authentication with Spring Web\u003c/a\u003e\n\u003cli\u003e \u003ca href=\"http://www.svlada.com/jwt-token-authentication-with-spring-boot/#jwt-authentication\"\u003eJWT Authentication Tutorial: An example using Spring Boot\u003c/a\u003e\n\u003cli\u003e \u003ca href=\"http://sgdev-blog.blogspot.com.br/2016/04/spring-oauth2-with-jwt-sample.html\"\u003eSpring Oauth2 with JWT Sample\u003c/a\u003e\n\u003cli\u003e \u003ca href=\"http://www.swisspush.org/security/2016/10/17/oauth2-in-depth-introduction-for-enterprises\"\u003eOAuth2 in depth: A step-by-step introduction for enterprises\u003c/a\u003e\n\u003cli\u003e \u003ca href=\"https://github.com/gdong42/spring-auth-example\"\u003espring-auth-example\u003c/a\u003e\n\n\u003ch4\u003eTo Build and Run\u003c/h4\u003e\nGo to the cloned directory and run \u003ccode\u003emvn spring-boot:run\u003c/code\u003e or build with your chosen IDE.\n\n\u003ch4\u003eCurl Commands\u003c/h4\u003e\nYou should install \u003ca href=\"https://stedolan.github.io/jq/\"\u003e./JQ\u003c/a\u003e before running these Curl commands.\n\u003cdiv\u003e\n\u003cstrong\u003eTo get a new token\u003c/strong\u003e \u003cbr/\u003e\n\u003ccode\u003e\ncurl trusted-app:secret@localhost:8080/oauth/token -d \"grant_type=password\u0026username=user\u0026password=password\" | jq\n\u003c/code\u003e\n\n\u003cbr/\u003e\n\u003cstrong\u003eTo get a refresh token\u003c/strong\u003e\u003cbr/\u003e\n\u003ccode\u003e\ncurl trusted-app:secret@localhost:8080/oauth/token -d \"grant_type=access_token\u0026access_tokem=[ACCESS_TOKEN]\" | jq\n\u003c/code\u003e\n\n\n\u003cbr/\u003e\n\u003cstrong\u003eTo access a protected resource\u003c/strong\u003e\u003cbr/\u003e\n\u003ccode\u003e\ncurl -H \"Authorization: Bearer [ACCESS_TOKEN]\" localhost:8080/api/hello\n\u003c/code\u003e\n\u003c/div\u003e\n\n\u003cp\u003e\n\u003cstrong\u003eRegister new Account\u003c/strong\u003e\u003cbr/\u003e\n\u003ccode\u003e\ncurl -H \"Authorization: Bearer $(curl register-app:secret@localhost:8080/oauth/token -d \"grant_type=client_credentials\u0026client_id=register-app\" | jq --raw-output .\"access_token\")\" localhost:8080/api/register -H \"Content-Type: application/json\" -d '{\"username\":\"new-user\",\"password\":\"password\",\"firstName\":\"First\",\"lastName\":\"Last\",\"email\":\"email@email.com\"}' | jq\n\u003c/code\u003e\n\u003c/p\u003e\n\n\u003cdiv\u003e\n\u003cp\u003e\n\u003cstrong\u003eCurl sample commands\u003c/strong\u003e\n\u003cem\u003eapi/me\u003c/em\u003e\n\u003ccode\u003e\ncurl -H \"Authorization: Bearer $(curl trusted-app:secret@localhost:8080/oauth/token -d \"grant_type=password\u0026username=user\u0026password=password\" | jq --raw-output .\"access_token\")\" localhost:8080/api/me | jq\n\u003c/code\u003e\n\u003c/p\u003e\n\u003c/div\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftinmegali%2FOauth2-Stateless-Authentication-with-Spring-and-JWT-Token","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftinmegali%2FOauth2-Stateless-Authentication-with-Spring-and-JWT-Token","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftinmegali%2FOauth2-Stateless-Authentication-with-Spring-and-JWT-Token/lists"}