helper

package
v0.2.49 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2023 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultTokenClaims = map[string]interface{}{
		"iss":   "https://dummy.ega.nbis.se",
		"sub":   "dummy",
		"exp":   time.Now().Add(time.Hour * 2).Unix(),
		"pilot": "dummy-pilot",
	}

	WrongUserClaims = map[string]interface{}{
		"sub":   "c5773f41d17d27bd53b1e6794aedc32d7906e779@elixir-europe.org",
		"aud":   "15137645-3153-4d49-9ddb-594027cd4ca7",
		"azp":   "15137645-3153-4d49-9ddb-594027cd4ca7",
		"scope": "ga4gh_passport_v1 openid",
		"iss":   "https://dummy.ega.nbis.se",
		"iat":   time.Now().Unix(),
		"exp":   time.Now().Add(time.Hour * 2).Unix(),
		"jti":   "5e6c6d24-42eb-408e-ba20-203904e388a1",
	}

	ExpiredClaims = map[string]interface{}{
		"sub":   "dummy",
		"aud":   "15137645-3153-4d49-9ddb-594027cd4ca7",
		"azp":   "15137645-3153-4d49-9ddb-594027cd4ca7",
		"scope": "ga4gh_passport_v1 openid",
		"iss":   "https://dummy.ega.nbis.se",
		"exp":   time.Now().Add(-time.Hour * 2).Unix(),
		"iat":   time.Now().Unix(),
		"jti":   "5e6c6d24-42eb-408e-ba20-203904e388a1",
	}

	NonValidClaims = map[string]interface{}{
		"sub":   "c5773f41d17d27bd53b1e6794aedc32d7906e779@elixir-europe.org",
		"aud":   "15137645-3153-4d49-9ddb-594027cd4ca7",
		"azp":   "15137645-3153-4d49-9ddb-594027cd4ca7",
		"scope": "ga4gh_passport_v1 openid",
		"iss":   "https://dummy.ega.nbis.se",
		"exp":   time.Now().Add(time.Hour * 2).Unix(),
		"iat":   time.Now().Add(time.Hour * 2).Unix(),
		"jti":   "5e6c6d24-42eb-408e-ba20-203904e388a1",
	}

	WrongTokenAlgClaims = map[string]interface{}{
		"iss":       "Online JWT Builder",
		"iat":       time.Now().Unix(),
		"exp":       time.Now().Add(time.Hour * 2).Unix(),
		"aud":       "4e9416a7-3515-447a-b848-d4ac7a57f",
		"sub":       "pleasefix@snurre-in-the-house.org",
		"auth_time": "1632207224",
		"jti":       "cc847f9c-7608-4b4f-9c6f-6e734813355f",
	}
)

Global variables for test token creation

Functions

func CreateECToken

func CreateECToken(key *ecdsa.PrivateKey, headerAlg, headerType string, tokenClaims map[string]interface{}) (string, error)

CreateECToken creates an EC token

func CreateECkeys

func CreateECkeys(prPath, pubPath string) error

CreateECkeys creates the EC key pair

func CreateHSToken

func CreateHSToken(key []byte, headerAlg, headerType string, tokenClaims map[string]interface{}) (string, error)

CreateHSToken creates an HS token

func CreateRSAToken

func CreateRSAToken(key *rsa.PrivateKey, headerAlg, headerType string, tokenClaims map[string]interface{}) (string, error)

CreateRSAToken creates an RSA token

func CreateRSAkeys

func CreateRSAkeys(prPath, pubPath string) error

CreateRSAkeys creates the RSA key pair

func FormatUploadFilePath added in v0.2.29

func FormatUploadFilePath(filePath string) (string, error)

FormatUploadFilePath ensures that path separators are "/", and returns error if the filepath contains a disallowed character matched with regex

func MakeCerts added in v0.1.126

func MakeCerts(outDir string)

func MakeFolder

func MakeFolder(path string) (string, string, error)

MakeFolder creates a folder and subfolders for the keys pair Returns the two paths

func ParsePrivateECKey

func ParsePrivateECKey(path, keyName string) (*ecdsa.PrivateKey, error)

ParsePrivateECKey reads and parses the EC private key

func ParsePrivateRSAKey

func ParsePrivateRSAKey(path, keyName string) (*rsa.PrivateKey, error)

ParsePrivateRSAKey reads and parses the RSA private key

func TLScertToFile added in v0.1.126

func TLScertToFile(filename string, derBytes []byte) error

func TLSkeyToFile added in v0.1.126

func TLSkeyToFile(filename string, key *ecdsa.PrivateKey) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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