auth-serivce-payment

module
v0.0.0-...-7ec3620 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2024 License: MIT

README ΒΆ

Auth Service for Payment

Welcome to the Auth Service for Payment! πŸŽ‰ This microservice provides a robust and secure authentication system tailored specifically for payment processing applications.

πŸš€ Features

  • User Registration: Effortlessly register new users with secure password hashing.
  • Token Generation: Generate access and refresh tokens to maintain user sessions seamlessly.
  • User Management: Easily manage user information with functionalities for checking existing usernames and emails.
  • Secure: Employs industry-standard security practices to keep user data safe.
  • gRPC Communication: Efficient and high-performance communication using gRPC.

πŸ› οΈ Technologies Used

  • Golang: A powerful programming language for building efficient and reliable applications.
  • gRPC: A modern open-source high-performance RPC framework.
  • Bcrypt: For secure password hashing.
  • MySQL: A robust relational database for data storage.

πŸ“¦ Installation

  1. Clone the repository:
    git clone https://github.com/yourusername/auth-service-payment.git
    cd auth-service-payment
    
  2. Install dependencies:
    go mod tidy
    
  3. Set up your environment variables in a .env file based on the provided template.
  4. Run the application:
    go run main.go
    

Folder Structure

auth-service/
β”œβ”€β”€ cmd/
β”‚   └── auth/
β”‚       └── main.go              # Entry point for the auth service
β”œβ”€β”€ internal/
β”‚   β”œβ”€β”€ config/                   # Configuration files (e.g., for environment variables)
β”‚   β”‚   β”œβ”€β”€ config_test.go
β”‚   β”‚   β”œβ”€β”€ mysql.go
β”‚   β”‚   └── config.go
β”‚   β”œβ”€β”€ handler/                  # HTTP/gRPC handlers
β”‚   β”‚   └── auth_handler.go       # Handlers for authentication-related endpoints
β”‚   β”œβ”€β”€ middleware/               # Middleware functions (e.g., authentication, logging)
β”‚   β”‚   └── auth_middleware.go
β”‚   β”œβ”€β”€ model/                    # Data models (e.g., User struct)
β”‚   β”‚   └── user.go
β”‚   β”œβ”€β”€ repository/               # Repository pattern for database interactions
β”‚   β”‚   β”œβ”€β”€ auth_repository_impl.go
β”‚   β”‚   β”œβ”€β”€ auth_repository.go
β”‚   β”‚   └── auth_repository_test.go
β”‚   β”œβ”€β”€ service/                  # Business logic and service layer
β”‚   β”‚   β”œβ”€β”€ auth_service_impl.go
β”‚   β”‚   β”œβ”€β”€ auth_service_test.go
β”‚   β”‚   └── auth_service.go       # Logic for handling authentication
β”‚   └── utils/                    # Utility functions (e.g., token generation, validation)
β”‚       β”œβ”€β”€ global.go
β”‚       β”œβ”€β”€ password_utils.go
β”‚       β”œβ”€β”€ utils_test.go
β”‚       └── token.go
β”œβ”€β”€ mocks/                         # Integration tests (optional)
β”‚   β”œβ”€β”€ mock_config.go
β”‚   β”œβ”€β”€ mock_database.go
β”‚   β”œβ”€β”€ mock_hashpassword.go
β”‚   β”œβ”€β”€ mock_repository.go
β”‚   └── mock_token.go
β”œβ”€β”€ .env                          # Environment variables (optional)
β”œβ”€β”€ .gitignore                    
β”œβ”€β”€ coverage.html                    
β”œβ”€β”€ coverage.out                    
β”œβ”€β”€ LICENSE                    
β”œβ”€β”€ readme.md                    
β”œβ”€β”€ go.mod                        # Go module file
└── go.sum    

🌟 Usage

This service exposes several gRPC endpoints for managing user authentication. Here's a brief overview:

  • RegisterUser: Register a new user and receive access and refresh tokens.
  • LoginUser: Authenticate an existing user and retrieve tokens.
  • RefreshToken: Refresh user access tokens seamlessly.

πŸ§ͺ Testing

To ensure code quality and functionality, unit tests are implemented using github.com/stretchr/testify. Run the tests with:

    go test -coverprofile=coverage.out ./... && go tool cover -html=coverage.out -o coverage.html

🀝 Contributing

We welcome contributions! Please fork the repository and submit a pull request with your changes.

  1. Fork it!
  2. Create your feature branch (git checkout -b feature/MyFeature)
  3. Commit your changes (git commit -m 'Add some feature')
  4. Push to the branch (git push origin feature/MyFeature)
  5. Open a pull request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ“« Contact

For any inquiries or feedback, please reach out to fajaramaulanadev@gmail.com.

Directories ΒΆ

Path Synopsis
cmd
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL