token

package
v0.0.0-...-1305305 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LOGGER = logging.MustGetLogger("middlewares")

LOGGER for logging

Functions

func CheckerApprove

func CheckerApprove(requestID string, iIDFromHeader string, userID string, level string) (bool, error)

CheckerApprove : After authorization, this is used for approving the request (internal) and making changes in firebase approvals node.

func ExtractJWTClaims

func ExtractJWTClaims(tokenStr string, r *http.Request) (jwt.MapClaims, bool)

ExtractJWTClaims : parses (decodes) jwt token using secret and returns claims if successful

func HasEndpoint

func HasEndpoint(claims jwt.MapClaims, enpTarget string) bool

HasEndpoint : check if requested endpoint is included in endpoint array

func HasIP

func HasIP(claims jwt.MapClaims, remoteAddrs []string) bool

HasIP : check if the request ip address is included in token ip array

func IsForParticipant

func IsForParticipant(claims jwt.MapClaims) bool

IsForParticipant : if service is not a singleton then check if the token participant matches the participant id per the env var

func MakerRequest

func MakerRequest(participantID string, institutionID string, path string, method string, level string, userID string) (string, error)

* MakerRequest : After authorization, write the request to firebase in approvals (participant_approvals/super_approvals) node *@param{ w: http response writer, r: http request, level: string , userID: string }

Types

type MakerRequestData

type MakerRequestData struct {
	RequestUserID string `json:"uid_request,omitempty"`
	ApproveUserID string `json:"uid_approve"`
	InstitutionID string `json:"iid,omitempty"`
	ParticipantID string `json:"pid,omitempty"`
	Status        string `json:"status,omitempty"`
	Endpoint      string `json:"endpoint,omitempty"`
	Method        string `json:"method,omitempty"`
	Timestamp     int64  `json:"timestamp_request,omitempty"`
}

MakerRequestData is a json-serializable type. This is the data structure that gets committed to firebase. The ApproveUserId is added from the beginning since altering types later is not possible.

Jump to

Keyboard shortcuts

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