auth

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package auth provides functions that link up and communicate with Luminus authentication server.

Index

Constants

View Source
const AUTH_METHOD = "FormsAuthentication"
View Source
const CLIENT_ID = "E10493A3B1024F14BDC7D0D8B9F649E9-234390"
View Source
const CODE_URL = "" /* 295-byte string literal not displayed */
View Source
const CONTENT_TYPE = "application/x-www-form-urlencoded"
View Source
const CREDENTIALS_FILE_NAME = lominus.CREDENTIALS_FILE_NAME
View Source
const EXPIRY_HOURS = 1
View Source
const GRANT_TYPE = "authorization_code"
View Source
const JWT_URL = "https://luminus.nus.edu.sg/v2/api/login/adfstoken"
View Source
const POST = "POST"
View Source
const REDIRECT_URI = "https://luminus.nus.edu.sg/auth/callback"
View Source
const RESOURCE = "sg_edu_nus_oauth"
View Source
const USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:94.0) Gecko/20100101 Firefox/94.0"

Variables

This section is empty.

Functions

func RetrieveJwtToken

func RetrieveJwtToken(credentials Credentials, save bool) (string, error)

RetrieveJwtToken takes in the user's Credentials and return a JWT token issued by Luminus authentication server.

func SaveCredentials

func SaveCredentials(credentialsPath string, credentials Credentials) error

SaveCredentials saves the user's Credentials for future authentications or renewals of JWT data.

Types

type Credentials

type Credentials struct {
	Username string
	Password string
}

Credentials struct is the datapack that describes the user's credentials.

func LoadCredentials

func LoadCredentials(credentialsPath string) (Credentials, error)

LoadCredentials loads the user's Credentials data from local storage.

type JsonResponse

type JsonResponse struct {
	AccessToken string `json:"access_token"`
	TokenType   string `json:"token_type"`
	ExpiresIn   int    `json:"expires_in"`
}

JsonResponse struct is the datapack for containing API authentication response raw data.

type JwtData

type JwtData struct {
	JwtToken string
	Expiry   int64
}

JwtData struct is the datapack that describes the user's JWT data.

func LoadJwtData

func LoadJwtData(jwtPath string) (JwtData, error)

LoadJwtData loads the user's JWT data from local storage.

func (JwtData) IsExpired

func (jwtData JwtData) IsExpired() bool

IsExpired is a util function that checks if the user's JWT data has expired.

type JwtExpiredError

type JwtExpiredError struct{}

JwtExpiredError struct contains the JwtExpiredError which will be thrown when the JWT data has expired.

func (*JwtExpiredError) Error

func (e *JwtExpiredError) Error() string

JwtExpiredError error to be thrown when the JWT data has expired.

Jump to

Keyboard shortcuts

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