utility

package
v0.0.0-...-3c86364 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2024 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecryptStringWithRsaKey

func DecryptStringWithRsaKey(encryptedBase64 string, keyFile string) (*string, error)

DecryptStringWithRsaKey decrypts the encrypted string encoded in base64 standard encoding, and returns the decrypted string.

func EncryptStringWithRsaKey

func EncryptStringWithRsaKey(plaintext string, keyFile string) (*string, error)

EncryptStringWithRsaKey encrypts the `plaintext` with the asymetric key, and returns the encrypted data represented in the base64 standard encoding.

func GetCollections

func GetCollections(cfg RdrGatewayConfig, ctype, project string) ([]string, error)

GetCollections return a list of collName of the RDR collections with type `ctype` and associated with project number `project`.

func GetDacOfProject

func GetDacOfProject(number string) string

GetDacOfProject returns the corresponding DAC of the project `number` from the internal cache.

func GetOAuth2Token

func GetOAuth2Token(clientID, clientSecret, authURL string, scopes []string) (*oauth2.Token, error)

func NewHTTPSClient

func NewHTTPSClient(timeout time.Duration, insecure bool) (client *http.Client)

NewHTTPSClient initiates a new HTTPS client with timeout and skip certificate verification when `insecure` flag is set to `true`.

func OAuth2HttpClient

func OAuth2HttpClient(ctx context.Context, clientID, clientSecret, authURL string, scopes []string) (*http.Client, error)

OAuth2HttpClient returns a HTTP client wrapped with HTTP round tripper for Oauth token. It has lifetime within the `ctx`.

func SetDacCache

func SetDacCache(dacs map[string]string)

func UnmarshalFromResponseBody

func UnmarshalFromResponseBody(response *http.Response, i interface{}) error

UnmarshalFromResponseBody unmarshals data from the `response.Body` stream into a struct `i`. The `response.Body` is also closed after calling this function.

func UpdatePpmDacs

func UpdatePpmDacs(
	ctx context.Context,
	cfg PpmFormConfig,
	every time.Duration,
	sdacs map[string]string,
)

UpdatePpmDacs runs an blocking loop within the lifetime of the context. For `every` duration in this loop, it updates the internal cache for DACs of the DCC OU registered in the online PPM form.

A list of static DACs `sdacs` will take precedence over the DACs retrieved from the online PPM form.

Types

type PpmFormConfig

type PpmFormConfig struct {
	AuthURL      string
	ClientID     string
	ClientSecret string
	ApiEndpoint  string
}

type PpmProjectCollection

type PpmProjectCollection struct {
	CollID  string `json:"id"`
	OU      string `json:"organizationalUnit"`
	Project string `json:"project"`
}

type RdrGatewayConfig

type RdrGatewayConfig struct {
	ApiEndpoint string
}

Jump to

Keyboard shortcuts

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