Skip to content

Prog-Academy-projects/JavaPro_HW14_SprSecGoogle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JavaPro Homework 14: Spring Security with Google OAuth2

Java Spring Boot Build License

🔒 A Java Spring Boot application demonstrating Google OAuth2 authentication integration.


📋 Project Description

This project implements user authentication via Google accounts using OAuth2 in a Spring Boot application.
After a successful login, users can access protected resources within the app.


🛠️ Technologies Used

  • Java 17
  • Spring Boot 3.2
  • Spring Security
  • Spring Security OAuth2 Client
  • Maven
  • Google OAuth2 API

🚀 Quick Start

  1. Clone the repository

    git clone https://github.com/IvashDima/JavaPro_HW14_SprSecGoogle.git 
    
  2. Navigate to the project directory:

    cd JavaPro_HW14_SprSecGoogle
    
  3. Configure OAuth2 credentials Create a project in Google Cloud Console, configure OAuth2 Client credentials, and update src/main/resources/application.properties:

    spring.security.oauth2.client.registration.google.client-id=your-google-client-id
    spring.security.oauth2.client.registration.google.client-secret=your-google-client-secret
    spring.security.oauth2.client.registration.google.scope=openid,email,profile

⚠️ Important: Set your Authorized redirect URIs in Google Cloud Console correctly. Example: http://localhost:8080/login/oauth2/code/google

  1. Build and Run

    mvn spring-boot:run 
    
  2. Access the application Open your browser and navigate to:

    http://localhost:8886/
    
    

You will be redirected to the Google login page.

📂 Project Structure

  src/
  └── main/
     ├── java/
     │    └── org/example/springsecurity/
     │         ├── controllers/       # Controllers handling HTTP requests
     │         ├── config/            # OAuth2 security configuration
     │         └── SpringSecurityApplication.java  # Main application class
     ├── resources/
     │     └── application.properties  # Application configuration
     └── webapp/WEB-INF/pages          # JSTL templates

📌 Important Notes

Google might require OAuth2 consent screen verification for apps requesting sensitive scopes.

Always protect sensitive information (like client secret) in production (use environment variables, vaults, etc.).

This project is educational and focuses on OAuth2 integration basics.

👨‍💻 Author

Name: Dmytro Ivashchenko

Email: dnytsyk@gmail.com

📝 License

This project is provided for educational purposes only and does not have a specific license. Feel free to use and adapt it for your learning and personal projects!

About

Task to the lesson 14 of Java Pro course

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages