csh_auth

package module
v0.0.0-...-c9d95f6 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2020 License: MIT Imports: 9 Imported by: 1

README

csh-auth

An @ComputerScienceHouse authentication wrapper for Gin.

Usage

  1. Create a CSHAuth Struct
csh := csh_auth.CSHAuth{}
  1. Initialize your CSHAuth object
csh.Init(
    /* oidc_client_id */,       // The OIDC client ID
    /* oidc_client_secret */,   // The OIDC client Secret
    /* jwt_secret */,           // I just used a random sequence of > 16 characters
    /* state */,                // I just used a random sequence of > 16 characters
    /* server_host */,          // The domain your application will run from
    /* redirect_uri */,         // The OIDC redirect URI
    /* auth_uri */,             // The relative path for your authentication endpoint
)
  1. Add required CSHAuth endpoints
r.GET("/auth/login", csh.AuthRequest) // This endpoint should match auth_uri
r.GET("/auth/redir", csh.AuthCallback) // This endpoint should match the relative portion of redirect_uri
r.Get("/auth/logout", csh.AuthLogout)
  1. Add endpoints to be behind authentication
r.Get("/hidden/prize", csh.AuthWrapper(endpoint_hidden_prize))

Documentation

Index

Constants

View Source
const AuthKey = "cshauth"
View Source
const CookieName = "Auth"
View Source
const ProviderURI = "https://sso.csh.rit.edu/auth/realms/csh"

Variables

This section is empty.

Functions

This section is empty.

Types

type CSHAuth

type CSHAuth struct {
	// contains filtered or unexported fields
}

func (*CSHAuth) AuthCallback

func (auth *CSHAuth) AuthCallback(c *gin.Context)

func (*CSHAuth) AuthLogout

func (auth *CSHAuth) AuthLogout(c *gin.Context)

func (*CSHAuth) AuthRequest

func (auth *CSHAuth) AuthRequest(c *gin.Context)

func (*CSHAuth) AuthWrapper

func (auth *CSHAuth) AuthWrapper(page gin.HandlerFunc) gin.HandlerFunc

func (*CSHAuth) Init

func (auth *CSHAuth) Init(clientID, clientSecret, secret, state, server_host, redirect_uri, auth_uri string)

type CSHClaims

type CSHClaims struct {
	Token    string      `json:"token"`
	UserInfo CSHUserInfo `"json:user_info"`
	jwt.StandardClaims
}

type CSHUserInfo

type CSHUserInfo struct {
	Subject       string `json:"uuid"`
	Profile       string `json:"profile"`
	Email         string `json:"email"`
	EmailVerified bool   `json:"email_verified"`
	// contains filtered or unexported fields
	Username string `json:"preferred_username"`
	FullName string `json:"name"`
}

Jump to

Keyboard shortcuts

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