{"id":30331902,"url":"https://github.com/ashrawan/spring-security-oauth-example","last_synced_at":"2025-08-18T03:40:27.914Z","repository":{"id":304525432,"uuid":"615946201","full_name":"ashrawan/Spring-Security-OAuth-Example","owner":"ashrawan","description":"Spring Security with OAuth2, and Custom JWT","archived":false,"fork":false,"pushed_at":"2025-07-13T17:10:17.000Z","size":131,"stargazers_count":15,"open_issues_count":1,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-13T18:23:57.902Z","etag":null,"topics":["jwt","oauth2-client","spring-security"],"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/ashrawan.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-03-19T06:26:59.000Z","updated_at":"2025-07-13T16:02:42.000Z","dependencies_parsed_at":"2025-07-13T18:34:28.976Z","dependency_job_id":null,"html_url":"https://github.com/ashrawan/Spring-Security-OAuth-Example","commit_stats":null,"previous_names":["ashrawan/spring-security-oauth-example"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/ashrawan/Spring-Security-OAuth-Example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashrawan%2FSpring-Security-OAuth-Example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashrawan%2FSpring-Security-OAuth-Example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashrawan%2FSpring-Security-OAuth-Example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashrawan%2FSpring-Security-OAuth-Example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ashrawan","download_url":"https://codeload.github.com/ashrawan/Spring-Security-OAuth-Example/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashrawan%2FSpring-Security-OAuth-Example/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270940626,"owners_count":24671679,"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","status":"online","status_checked_at":"2025-08-18T02:00:08.743Z","response_time":89,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["jwt","oauth2-client","spring-security"],"created_at":"2025-08-18T03:40:24.365Z","updated_at":"2025-08-18T03:40:27.888Z","avatar_url":"https://github.com/ashrawan.png","language":"Java","readme":"# Spring Security OAuth Example\n\nThis repository demonstrates how to combine OAuth2 logins with custom JWT support in a Spring Boot application. It includes sample configurations for Google, Facebook and GitHub authentication providers and a classic username/password flow with email verification.\n\n## Project Layout\n\n```\nsrc/\n  main/\n    java/com/demo/springcustomizedstarterexample\n      config/        -\u003e Spring configuration (security, beans, MVC)\n      controller/    -\u003e REST endpoints\n      entities/      -\u003e JPA entities\n      repository/    -\u003e Spring Data repositories\n      security/      -\u003e JWT and OAuth2 integration\n      services/      -\u003e Business and auth services\n      utils/         -\u003e Helpers and exceptions\n    resources/       -\u003e application.yml, mail templates\n  test/               -\u003e Basic context test\n```\n\nThe main entry point is `SpringCustomizedStarterExampleApplication`. Security is configured in `WebSecurityConfig` which sets up stateless JWT authentication, OAuth2 login flow and registers a custom filter that parses JWT tokens.\n\n## Key Features\n\n- OAuth2 login with Google, Facebook and GitHub\n- Custom JWT tokens issued on login or OAuth2 success\n- Email based registration, verification and password reset using Freemarker templates\n- Repository and service layers built with Spring Data JPA\n\n### Configuration Highlights\n\nSee `application.yml` for database, mail and OAuth client settings. Beans such as `PasswordEncoder` and `CorsConfigurationSource` are declared in the configuration classes under `config`.\n\n### Security Layer\n\n`JWTAuthenticationFilter` extracts tokens from the `Authorization` header. Tokens are created and validated by `JWTTokenProvider`. OAuth2 requests are handled by `CustomOAuth2UserService` along with success and failure handlers.\n\n### Email Templates\n\nWelcome, verification and password reset emails use Freemarker templates found in `src/main/resources/mail-templates`.\n\n## Getting Started\n\nEnsure you have a database (MySQL by default) and update OAuth credentials in `application.yml`. Run the application with:\n\n```bash\n./mvnw spring-boot:run\n```\n\n## Learn More\n\nTo dive deeper, explore:\n\n1. **Spring Security OAuth2** – how OAuth2 login integrates with JWT generation.\n2. **JWT best practices** – see how custom claims are added in `JWTTokenProvider`.\n3. **Freemarker templating** – customize the templates used by `EmailService`.\n4. **Spring Data JPA auditing** – entities extend an auditable base for automatic created/modified timestamps.\n\nThe project follows standard Spring Boot layering with controllers → services → repositories, so new contributors can start by experimenting with the authentication endpoints and browsing the configuration classes.\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fashrawan%2Fspring-security-oauth-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fashrawan%2Fspring-security-oauth-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fashrawan%2Fspring-security-oauth-example/lists"}