auth

package module
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: May 8, 2021 License: GPL-3.0 Imports: 18 Imported by: 1

README

Auth

This application is an extension to iiitr-services/Server

Auth package implements authentication layer for user login

Currently supported methods

	- Google OAuth 			(for students)

This extension assumes these environment variables to be available (besides from main Server)

	- GOOGLE_CLIENT_ID			- For Google OAuth
	- GOOGLE_CLIENT_SECRET		- For Google OAuth
	- DOMAIN					- For cookie formation
	- JWT_SIGNING_KEY			- For JWT formation

Documentation

Overview

* This application is an extension to iiitr-services/Server

Auth package implements authentication layer for user login.

Currently supported methods

  • Google OAuth (for students)

This extension assumes these environment variables to be available (besides from main Server)

  • GOOGLE_CLIENT_ID - For Google OAuth
  • GOOGLE_CLIENT_SECRET - For Google OAuth
  • DOMAIN - For cookie formation
  • JWT_SIGNING_KEY - For JWT formation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateJWTToken

func GenerateJWTToken(stu Student) (string, error)

GenerateJWTToken generated a JWT for student authentication signed in from OAuth.

func GetClaims

func GetClaims(token string) (jwt.MapClaims, error)

GetClaims returns claims from a jwt token

func Handler

func Handler(r *mux.Router, database *gorm.DB)

Handler for handling auth endpoints and extension activation

func Redirect

func Redirect(w http.ResponseWriter, r *http.Request) bool

func VerifyJWT

func VerifyJWT(token string, key string) bool

VerifyJWT verify user using jwt token cookie.

Types

type Student

type Student struct {
	Name         string
	Email        string `gorm:"primary_key;index"`
	Rollnumber   string `gorm:"index"`
	AccessToken  string
	RefreshToken string
	Picture      string
}

Student struct (to be stored in database)

Jump to

Keyboard shortcuts

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