Git Product home page Git Product logo

smileshield's Introduction

SmileShield - Go Fiber OAuth and Mail Authentication

Welcome to SmileShield, a Go Fiber project for OAuth and mail authentication! SmileShield provides a secure and convenient way to handle user authentication in your applications.

Table of Contents

Installation

  1. Clone the repository:

    git clone https://github.com/your-username/smileshield.git
    cd smileshield
  2. Install dependencies:

    go get -u .
  3. Setup '.env':

    # POSTGRES_HOST=127.0.0.1
    # POSTGRES_USER=postgres
    # POSTGRES_PASSWORD=password123
    # POSTGRES_DB=golang-gorm
    # POSTGRES_PORT=6500
    
    PORT=8000
    CLIENT_ORIGIN='http://localhost:3000/'
    
    
    EMAIL_FROM='enter_email'
    SMTP_HOST='enter_host_name'
    SMTP_USER='enter_email_if_u_don't_know'
    SMTP_PASS='*******'
    SMTP_PORT='according_to_ur_provider'
    
    TOKEN_EXPIRED_IN=60m
    TOKEN_MAXAGE=60
    
    TOKEN_SECRET='my-ultra-secure-json-web-token-string'
    
    JWT_SECRET='my_ultra_secure_secret'
    JWT_EXPIRED_IN=60m
    JWT_MAXAGE=60
    
    #? google auth
    GOOGLE_OAUTH_CLIENT_ID='xyz...'
    GOOGLE_OAUTH_CLIENT_SECRET='secret....'
    GOOGLE_OAUTH_REDIRECT_URL='http://localhost:3000/api/auth/sessions/oauth/google'
    
    #? github auth
    GITHUB_OAUTH_CLIENT_ID='xyz...'
    GITHUB_OAUTH_CLIENT_SECRET='secret....'
    GITHUB_OAUTH_REDIRECT_URL='http://localhost:3000/api/auth/sessions/oauth/github'
    
    # ?stackoverflow auth
    STACKOVERFLOW_OAUTH_CLIENT_ID='xyz...'
    STACKOVERFLOW_CLIENT_SECRET='tsecret....'
    STACKOVERFLOW_REDIRECT_URL='http://localhost:3000/api/auth/sessions/oauth/stackoverflow' ```
    
  4. Run:

    go run main.go

Usage

Key dependencies and libraries powering SmileShield:

Validator (go-playground/validator/v10 v10.16.0):

  • Validates input data against specified criteria.

Fiber (gofiber/fiber/v2 v2.50.0):

  • Core web framework for handling HTTP requests and responses.

Fiber HTML Template Engine (gofiber/template/html/v2 v2.0.5):

  • Renders HTML views in the web application.

JWT Library (golang-jwt/jwt v3.2.2+incompatible, golang-jwt/jwt/v5 v5.0.0):

  • Manages JSON Web Tokens for user authentication.

UUID (google/uuid v1.4.0):

  • Generates and works with universally unique identifiers (UUIDs).

HTML to Text Converter (k3a/html2text v1.2.1):

  • Converts HTML to plain text.

Viper (spf13/viper v1.17.0):

  • Popular configuration management library for reading configuration files.

Random String Generator (thanhpk/randstr v1.0.6):

  • Generates random strings for various purposes.

Crypto (golang.org/x/crypto v0.14.0):

  • Part of the Go standard library, includes cryptographic primitives.

Email (gomail.v2 v2.0.0-20160411212932-81ebce5c23df):

  • Library for sending emails, crucial for applications involving email functionality.

GORM SQLite Driver (gorm.io/driver/sqlite v1.5.4):

  • SQLite driver for GORM, a powerful Object-Relational Mapping (ORM) library.

GORM (gorm.io/gorm v1.25.5):

  • Provides a flexible way to interact with databases.

Note:

  • Understand the licenses associated with these dependencies.
  • Keep dependencies up to date for security and feature improvements.
  • Refer to the project's documentation for specific use cases or configurations.

Features

OAuth Authentication:

  • Integrate seamlessly with popular OAuth providers for secure and efficient user authentication.

Mail Authentication:

  • Simplify user registration by incorporating email confirmation as part of the authentication process.

Flexible Configuration:

  • Easily customize settings to adapt SmileShield to your specific environment and requirements.

Endpoints

Example

User Registration

Navigate to the Registration Page:

Registration Page

Making a Call with Authorization Token

  1. Copy the JWT Token from the Login Response.

    JWT Token

  2. Make an Authenticated API Call:

    curl -X GET \
      https://api.example.com/user-profile \
      -H "Authorization: Bearer YOUR_JWT_TOKEN"
       

JWT Token

Google OAuth Configuration Steps

  1. Create OAuth Credentials:

    • Go to the Google Cloud Console.
    • Navigate to the "APIs & Services" > "Credentials" section.
    • Click on "Create Credentials" and choose "OAuth client ID."
    • Configure the consent screen and application type (Web application for this example).
    • Set the authorized redirect URI(s) for your application.
  2. Retrieve Client ID and Client Secret:

    • Once the OAuth client is created, note the generated Client ID and Client Secret.
  3. Update SmileShield Configuration:

    • Open your .env file.

    • Add the Google OAuth Client ID and Client Secret:

      GOOGLE_OAUTH_CLIENT_ID=your_google_oauth_client_id
      GOOGLE_OAUTH_CLIENT_SECRET=your_google_oauth_client_secret

Google OAuth

Replace placeholders like your_google_oauth_client_id and your_google_oauth_client_secret with your actual Google OAuth credentials. The animated GIF shows the process of updating the configuration in your .env file for Google OAuth.

GitHub OAuth Configuration Steps

  1. Create OAuth Credentials:

    • Go to GitHub Developer Settings.
    • Create a new OAuth App.
    • Configure the application details and set the authorization callback URL(s) for your application.
  2. Retrieve Client ID and Client Secret:

    • Once the OAuth App is created, note the generated Client ID and Client Secret.
  3. Update SmileShield Configuration:

    • Open your .env file.

    • Add the GitHub OAuth Client ID and Client Secret:

      GITHUB_OAUTH_CLIENT_ID=your_github_oauth_client_id
      GITHUB_OAUTH_CLIENT_SECRET=your_github_oauth_client_secret

GitHub OAuth

Replace placeholders like your_github_oauth_client_id and your_github_oauth_client_secret with your actual GitHub OAuth credentials. The animated GIF shows the process of updating the configuration in your .env file for GitHub OAuth.

Contributing

Contributions are welcome! We appreciate your interest in improving SmileShield. Whether you want to report a bug, suggest a feature, or contribute code, here's how you can get involved:

Bug Reports and Feature Requests

If you encounter a bug or have a feature request, please open an issue on the GitHub Issues page. Provide as much detail as possible, including steps to reproduce the issue or a clear description of the new feature.

Pull Requests

  1. Fork the repository and create your branch from main.

    git checkout -b your-branch-name
  2. Make your changes, test thoroughly, and ensure your code adheres to the project's coding standards.

  3. Commit your changes with descriptive commit messages.

    git commit -m "Your descriptive commit message"
  4. Push your changes to your fork.

    git push origin your-branch-name
  5. Open a pull request to the main branch of the original repository.

Stack Overflow OAuth

We're currently working on adding Stack Overflow OAuth to SmileShield! If you're interested in contributing to this specific feature, follow the general contribution steps mentioned above. When working on the Stack Overflow OAuth integration, please ensure that your changes align with the project's goals and coding standards.

Getting Help

If you have questions or need help, feel free to reach out on our Discussions page.

Thank you for your contribution! ๐Ÿš€

License

MIT License Copyright (c) 2024 Ashutosh Anand.

smileshield's People

Contributors

loopassembly avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.