Categorygithub.com/dmwm/auth-proxy-server
modulepackage
0.0.0-20241001120922-895ca34683ed
Repository: https://github.com/dmwm/auth-proxy-server.git
Documentation: pkg.go.dev

# README

auth-proxy-server

Go CI build Go Report Card

Go implementation of reverse proxy server with OAuth OIDC or x509 authentication. It provides CMS authentication headers based on CRIC information, and build-in rotate logs functionality.

For full details please refer to this document.

Building and runnign the code

The code can be build as following:

# to build
make
# or use go build command
go build -ldflags="-X main.version=`git rev-parse --short HEAD`"

To run the service we can choose either between CERN SSO OAuth2 OICD authentication or x509 one. In both cases, please provide CRIC file and/or URL.

# to run with CERN SSO OAuth OICD authentication
auth-proxy-server -config config.json

# to run with x509 authentication
auth-proxy-server -config config.json -useX509

Code organization

The code is implemented as the following modules:

Both server implementations (oauthProxyServer and x509ProxyServer) support /server end-point which can be used to update server settings, e.g. curl -X POST -H"Content-type: application/json" -d '{"verbose":true}' https://a.b.com/server

This codebase is based on different examples taken from:

# Packages

No description provided by the author

# Functions

IAMScim returns list of IAM users for given token.
IAMToken returns access token from IAM provider for given client ID/Secret fields.
IAMUsers returns IAM user map for given token.
InList helper function to check item in a list.
LetsEncryptServer provides HTTPs server with Let's encrypt for given domain names (hosts).
LogName return proper log name based on Config.LogName and either hostname or pod name (used in k8s environment).
PathMatched check if given path are matched with rurl.
RedirectRules provides redirect rules map by reading Config.Ingress items.
RedirectRulesFromFiles provides redirect rules map by reading Config.IngressFiles.
RootCAs returns cert pool of our root CAs.
Server starts APS server.
SetReferrer set HTTP Referrer/Referer HTTP headers.
Stack retuns string representation of the stack function calls.
VerifyPeerCertificate function provides custom verification of client's certificate, see details https://golang.org/pkg/crypto/tls/#example_Config_verifyPeerCertificate https://www.example-code.com/golang/cert.asp https://golang.org/pkg/crypto/x509/pkix/#Extension.

# Variables

AuthTokenURL holds url for token authentication.
CMSAuth structure to create CMS Auth headers.
Config variable represents configuration object.
Context for our requests.
DataIn represents total data (in bytes) going into APS.
DataOut represents total data (in bytes) going out from APS.
IAMRenewInterval represent renewal interval for IAMUsers.
MetricsLastUpdateTime keeps track of last update time of the metrics.
NumLogicalCores represents number of cores in our node.
NumPhysicalCores represents number of cores in our node.
OAuth2Config holds OAuth2 configuration.
RPS represents requests per second for a given server.
RPSLogical represents requests per second for a given server times number of logical CPU cores.
RPSPhysical represents requests per second for a given server times number of physical CPU cores.
StartTime of the server.
TotalDeleteRequests counts total number of DELETE requests received by the server.
TotalGetRequests counts total number of GET requests received by the server.
TotalHeadRequests counts total number of HEAD requests received by the server.
TotalOAuthDeleteRequests counts total number of DELETE requests received by the server.
TotalOAuthGetRequests counts total number of GET requests received by the server.
TotalOAuthHeadRequests counts total number of HEAD requests received by the server.
TotalOAuthPostRequests counts total number of POST requests received by the server.
TotalOAuthPutRequests counts total number of PUT requests received by the server.
TotalOAuthRequests counts total number of all requests received by the server.
TotalPostRequests counts total number of POST requests received by the server.
TotalPutRequests counts total number of PUT requests received by the server.
TotalX509DeleteRequests counts total number of DELETE requests received by the server.
TotalX509GetRequests counts total number of GET requests received by the server.
TotalX509HeadRequests counts total number of HEAD requests received by the server.
TotalX509PostRequests counts total number of POST requests received by the server.
TotalX509PutRequests counts total number of PUT requests received by the server.
TotalX509Requests counts total number of all requests received by the server.
Verifier is ID token verifier.

# Structs

Configuration stores server configuration parameters.
ErrorRecord represents our error.
GzipReader struct to handle GZip'ed content of HTTP requests.
IAMCertificate represents certificate structure.
IAMEmail represents email structure.
IAMGroup represents group structure.
IAMIndigoUser represents indigo user structure.
IAMLabel represents label structure.
IAMMeta represents meta structure.
IAMResponse represents IAM scim users response.
IAMTokenResponse.
IAMUser represents IAM user information used by auth proxy server.
IAMUserManager holds IAMUser info in its cache.
Ingress part of server configuration.
Mem structure keeps track of virtual/swap memory of the server.
Memory structure keeps track of server memory.
Metrics provide various metrics about our server.
PublicJWKS represents public structure of jwks keys.
PublicJWKSKey represents public jwks key.
Rule reperesents scitoken rule.
ScitokensClaims represent structure of scitokens claims.
ScitokensConfig represents configuration of scitokens service.
ServerSettings controls server parameters.
TokenResponse rerpresents structure of returned scitoken.

# Type aliases

IAMUserMap holds map of IAMUser based on their ID.