cmsauth

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

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

Go to latest
Published: Feb 24, 2023 License: MIT Imports: 19 Imported by: 6

README

cmsauth

Go CI build GoDoc Go Report Card

Perform authentication and authorization actions used in CMS experiment on web frontend.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TIMEOUT int

TIMEOUT defines timeout for net/url request

View Source
var TLSCertsRenewInterval time.Duration

TLSCertsRenewInterval controls interval to re-read TLS certs (in seconds)

View Source
var Token string

Token defines access token location

View Source
var Verbose int

Verbose defines verbosity level

Functions

func CertExpire

func CertExpire(certs []tls.Certificate) time.Time

CertExpire gets minimum certificate expire from list of certificates

func GetCricData

func GetCricData(rurl string, verbose bool) (map[string]CricEntry, error)

GetCricData downloads CRIC data

func GetCricDataByKey

func GetCricDataByKey(rurl, key string, verbose bool) (map[string]CricEntry, error)

GetCricDataByKey downloads CRIC data

func HttpClient

func HttpClient() *http.Client

HttpClient provides cert/token aware HTTP client

func ParseCric

func ParseCric(fname string, verbose bool) (map[string]CricEntry, error)

ParseCric allows to parse CRIC file and use cric Login as a key for cric entry map

func ParseCricByKey

func ParseCricByKey(fname, key string, verbose bool) (map[string]CricEntry, error)

ParseCricByKey allows to parse CRIC file use use provided key as a cric entry map

func ReadToken

func ReadToken(r string) string

ReadToken function to either read file content or return given string

func TlsCerts

func TlsCerts() ([]tls.Certificate, error)

TlsCerts returns X509 certificates

Types

type CMSAuth

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

CMSAuth is a generic type which holds auth. file and associated key

func (*CMSAuth) CheckAuthnAuthz

func (a *CMSAuth) CheckAuthnAuthz(header http.Header) bool

CheckAuthnAuthz function performs Authentication and Authorization

func (*CMSAuth) CheckCMSAuthz

func (a *CMSAuth) CheckCMSAuthz(header http.Header, role, group, site string) bool

CheckCMSAuthz function performs CMS Authorization based on provided role and group or site attributes

func (*CMSAuth) GetHmac

func (a *CMSAuth) GetHmac(r *http.Request, verbose bool) (string, error)

GetHmac calculates hmac value from request headers

func (*CMSAuth) Init

func (a *CMSAuth) Init(afile string)

Init method initializes CMSAuth auth file, i.e. read the key

func (*CMSAuth) SetCMSHeaders

func (a *CMSAuth) SetCMSHeaders(r *http.Request, userData map[string]interface{}, cricRecords CricRecords, verbose bool)

SetCMSHeaders sets HTTP headers for given http request based on on provider user and CRIC data

func (*CMSAuth) SetCMSHeadersByKey

func (a *CMSAuth) SetCMSHeadersByKey(r *http.Request, userData map[string]interface{}, cricRecords CricRecords, key, method string, verbose bool)

SetCMSHeadersByKey sets HTTP headers for given http request based on on provider user and CRIC data

type CricEntry

type CricEntry struct {
	DN    string              `json:"DN"`    // CRIC DN
	DNs   []string            `json:"DNs"`   // List of all DNs assigned to user
	ID    int64               `json:"ID"`    // CRIC ID
	Login string              `json:"LOGIN"` // CRIC Login name
	Name  string              `json:"NAME"`  // CRIC user name
	Roles map[string][]string `json:"ROLES"` // CRIC user roles
}

CricEntry represents structure in CRIC entry (used by CMS headers)

func GetCricEntries

func GetCricEntries(rurl string, verbose bool) ([]CricEntry, error)

GetCricEntries downloads CRIC data

func (*CricEntry) String

func (c *CricEntry) String() string

String returns string representation of CricEntry

type CricRecords

type CricRecords map[string]CricEntry

CricRecords defines type for CRIC records

type StringList

type StringList []string

StringList allows to sort string keys

func (StringList) Len

func (s StringList) Len() int

func (StringList) Less

func (s StringList) Less(i, j int) bool

func (StringList) Swap

func (s StringList) Swap(i, j int)

type TLSCertsManager

type TLSCertsManager struct {
	Certs  []tls.Certificate
	Expire time.Time
}

TLSCertsManager holds TLS certificates for the server

func (*TLSCertsManager) GetCerts

func (t *TLSCertsManager) GetCerts() ([]tls.Certificate, error)

GetCerts return fresh copy of certificates

Jump to

Keyboard shortcuts

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