Go-backend-test - Creating backend stuff & openid connect authentication stuff in golang

Go Backend Coding Practice

This is my practice repo to learn about creating backend stuff & openid connect authentication stuff in golang.

How to Start

  • install golang

  • $git clone https://github.com/coding-CEO/go-backend-test.git

  • create .env file in root directory and set following values,

      GOOGLE_OAUTH2_CLIENT_ID={YOUR CLIENT ID}
      GOOGLE_OAUTH2_CLIENT_SECRET={YOUR CLIENT SECRET}
    
  • $go run main.go

  • server should start now

How to Use

  1. start server
  2. call GET /googleGenerateUserOAuthCode API by setting request as mentioned in below API table from front-end, you will get google oauth url
  3. redirect front-end to that url
  4. perform google login
  5. google will redirct to specific url that you set in step 2
  6. call GET /googleVerifyUserOAuthCode by setting request as mentioned in below API table from front-end
  7. you will get JWT of your google account

Basic Design

This is the basic design of what I want to build.
Authenticate users of clients using single authentication-service-provider

Clients:        ┌>┌──>  a.com     b.in   c.org  <─────┐<┐
                │ │       ↓        ↓       ↓          │ │
This Repo:      │ └─ authentication-service-provider ─┘ │
                │     ↓           ↓          ↓          │
OAuth Servers:  └─ google.com  apple.com  facebook.com ─┘

API Routes

Route Type body output body req. cookie resp. cookie urlParams req. extras details
/verifyUser GET - - token - - - This will verify the token from cookie and pass to next handler function. otherwise redirect to a central login page
/googleGenerateUserOAuthCode GET - googleOAuthRedirectUrl - Set-Cookie:state={xyz}, Set-Cookie:nonce={xyz} targetRedirectUrl set {withCredentials: true} set verification cookies (state, nonce) and returns google oauth url(GOU) then front-end should redirect to GOU then GOU will automatically redirect to targetRedirectUrl where code(OAuth code) param will automatically get attached
/googleVerifyUserOAuthCode GET - {JWT: 'xyz'} state, nonce - state, code set {withCredentials: true} verify the state from params & cookie, then verify the code(OAuth code) in the params, then verify nonce from idToken, then generate JWT and return as JSON. (maybe perform user registration in database here)

Who's Next

  1. implement code_challenge stuff
  2. maybe change the flow to reduce effort on front-end side
  3. something else that will popup out of nowhere
Similar Resources

Provides an interactive prompt to connect to ECS Containers using the ECS ExecuteCommand API.

Provides an interactive prompt to connect to ECS Containers using the ECS ExecuteCommand API.

ecsgo Heavily inspired by incredibly useful gossm, this tool makes use of the new ECS ExecuteCommand API to connect to running ECS tasks. It provides

Dec 12, 2022

The OCI Service Operator for Kubernetes (OSOK) makes it easy to connect and manage OCI services from a cloud native application running in a Kubernetes environment.

OCI Service Operator for Kubernetes Introduction The OCI Service Operator for Kubernetes (OSOK) makes it easy to create, manage, and connect to Oracle

Sep 27, 2022

Quickly connect to your Kubernetes Cluster with Tailscale

tsk tsk is a quick and magical way to connect your Kubernetes cluster to your Tailscale Tailnet. Installation tsk requires you have Pulumi installed.

Dec 17, 2022

Connect, Subscribe and Publish over MQTT broker to check its status.

MQTT Blackbox Exporter Introduction In each probe it sends a message over MQTT broker and then wait for getting it over subscription. By measuring thi

Aug 27, 2022

Download your Fitbit weight history and connect to InfluxDB and Grafana

WemonFit Weight monitoring for Fitbit, using InfluxDB and Grafana Generating a new certificate openssl req -new -newkey rsa:2048 -nodes -keyout lo

Oct 22, 2022

Ydb-go-yc-metadata - Helpers to connect to YDB inside yandex-cloud using metadata service

ydb-go-yc-metadata helpers to connect to YDB inside yandex-cloud using metadata

Nov 28, 2022

MTLS - Golang mTLS example,mTLS using TLS do both side authentication & authorization

MTLS - Golang mTLS example,mTLS using TLS do both side authentication & authorization

mTLS Golang Example mTLS Golang Example 1. What is mutual TLS (mTLS)? 2. How doe

Dec 21, 2022

MTLS - Golang mTLS example,mTLS using TLS do both side authentication & authorization

MTLS - Golang mTLS example,mTLS using TLS do both side authentication & authorization

mTLS Golang Example mTLS Golang Example 1. What is mutual TLS (mTLS)? 2. How doe

Jan 1, 2022

Acropolis Backend is the Go backend for Acropolis - the central management system for Full Stack at Brown

Acropolis Backend is the Go backend for Acropolis - the central management system for Full Stack at Brown

Acropolis Backend Acropolis Backend is the Go backend for Acropolis — the centra

Dec 25, 2021
k6 extension to load test Apache Kafka with support for Avro messages and SASL Authentication

xk6-kafka This project is a k6 extension that can be used to load test Kafka, using a producer. Per each connection to Kafka, many messages can be sen

Dec 7, 2021
A best practices Go source project with unit-test and integration test, also use skaffold & helm to automate CI & CD at local to optimize development cycle

Dependencies Docker Go 1.17 MySQL 8.0.25 Bootstrap Run chmod +x start.sh if start.sh script does not have privileged to run Run ./start.sh --bootstrap

Apr 4, 2022
Test-at-scale - TAS - An intelligent test execution platform for engineering teams to achieve high development velocity
Test-at-scale - TAS - An intelligent test execution platform for engineering teams to achieve high development velocity

Test At Scale Test Smarter, Release Faster with test-at-scale. Status Table of c

Dec 22, 2022
Terraform provider to help with various AWS automation tasks (mostly all that stuff we cannot accomplish with the official AWS terraform provider)
Terraform provider to help with various AWS automation tasks (mostly all that stuff we cannot accomplish with the official AWS terraform provider)

terraform-provider-awsutils Terraform provider for performing various tasks that cannot be performed with the official AWS Terraform Provider from Has

Dec 8, 2022
Kubernetes Stuff

Kubernetes Stuff

Jan 11, 2022
Stuff to make standing up sigstore (esp. for testing) easier for e2e/integration testing.
Stuff to make standing up sigstore (esp. for testing) easier for e2e/integration testing.

sigstore-scaffolding This repository contains scaffolding to make standing up a full sigstore stack easier and automatable. Our focus is on running on

Dec 27, 2022
This is a CLI to help changing and doing stuff in Terraform Cloud.

Terraform Cloud Tool This is a CLI to help changing and doing stuff in Terraform Cloud. Terraform CLI Functions $ terraform-cloud-tool Terraform Cloud

Jul 27, 2022
First Go project. Backend hiring test for Array engineering.

BACKEND TEST 1 Submitted by: Mitchell Sullivan Intro This is basically my first-ever project in Go. As such, it's quite simple and bears little resemb

Jan 19, 2022
Taina backend Backend service With Golang

taina-backend Backend service Getting Started Essential steps to get your backend service deployed A helloworld example has been shipped with the temp

Nov 17, 2021
Oct 7, 2022