opk

package
v0.0.0-...-10b22ae Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2023 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetEnvironmentVariable

func GetEnvironmentVariable(e string) (string, error)

func GetOIDCPublicKey

func GetOIDCPublicKey(issueUrl string, kid string) (*rsa.PublicKey, error)

func NewKeyPair

func NewKeyPair() (*rsa.PrivateKey, error)

func PemToPub

func PemToPub(pemBytes []byte) (crypto.PublicKey, error)

func PrettyPrintOpenPubKey

func PrettyPrintOpenPubKey(key *OpenPubKey)

func PrivToPem

func PrivToPem(priv *rsa.PrivateKey) string

func PubToPem

func PubToPem(pub crypto.PublicKey) ([]byte, error)

func QuitOnErr

func QuitOnErr(e error)

func SHA256

func SHA256(things ...[]byte) []byte

func SHA512

func SHA512(things ...[]byte) []byte

func VerifyOIDCSignature

func VerifyOIDCSignature(sigWrapper OPKSignature, payloadStr string, provider OIDCProvider, ids *[]Identity) error

func VerifyOPK

func VerifyOPK(jwt *OpenPubKey, provider OIDCProvider, ids *[]Identity) error

Types

type ActionsJWT

type ActionsJWT struct {
	Count       int
	Value       string
	ParsedToken *jwt.Token
}

func GetActionsToken

func GetActionsToken(audience string) (*ActionsJWT, error)

func (*ActionsJWT) Parse

func (j *ActionsJWT) Parse()

func (*ActionsJWT) PrettyPrintClaims

func (j *ActionsJWT) PrettyPrintClaims() string

type ActionsOIDCClient

type ActionsOIDCClient struct {
	// the url to fetch the jwt
	TokenRequestURL string
	// the audience for the jwt
	Audience string
	// the token used to retrieve the jwt, not the jwt
	RequestToken string
}

func DefaultOIDCClient

func DefaultOIDCClient(audience string) ActionsOIDCClient

func NewActionsOIDCClient

func NewActionsOIDCClient(tokenURL string, audience string, token string) (ActionsOIDCClient, error)

construct a new ActionsOIDCClient

func (*ActionsOIDCClient) BuildTokenURL

func (c *ActionsOIDCClient) BuildTokenURL() error

this function uses an ActionsOIDCClient to build the complete URL to request a jwt

func (*ActionsOIDCClient) GetJWT

func (c *ActionsOIDCClient) GetJWT() (*ActionsJWT, error)

retrieve an actions oidc token

type CIC

type CIC struct {
	Algorithm   string `json:"alg"`
	PublicKey   []byte `json:"pub"`
	RandomNoise []byte `json:"rz"`
}

func NewCIC

func NewCIC(alg string, pub, noise []byte) *CIC

func Sign

func Sign(payload *[]byte, provider OIDCProvider) (signature.SignerVerifier, *CIC, error)

func VerifyOPKSignature

func VerifyOPKSignature(sigWrapper OPKSignature, payload string) (*CIC, error)

func (*CIC) Hash

func (c *CIC) Hash() string

type Claims

type Claims struct {
	Audience string `json:"aud"`
}

type GetOIDCToken

type GetOIDCToken func(audience string) (*ActionsJWT, error)

type GitHubOIDCProvider

type GitHubOIDCProvider struct {
}

func (*GitHubOIDCProvider) GetJWT

func (p *GitHubOIDCProvider) GetJWT(claims *Claims) (*ActionsJWT, error)

func (*GitHubOIDCProvider) GetPublicKey

func (p *GitHubOIDCProvider) GetPublicKey(issueUrl string, kid string) (*rsa.PublicKey, error)

type Identity

type Identity struct {
	Subject string `json:"subject"`
	Issuer  string `json:"issuer"`
}

type OIDCProvider

type OIDCProvider interface {
	GetJWT(*Claims) (*ActionsJWT, error)
	GetPublicKey(string, string) (*rsa.PublicKey, error)
}

type OPKSignature

type OPKSignature struct {
	Protected string `json:"protected"`
	Signature string `json:"signature"`
}

type OpenPubKey

type OpenPubKey struct {
	Payload    string         `json:"payload"`
	Signatures []OPKSignature `json:"signatures"`
}

func NewOpenPubKey

func NewOpenPubKey(jwt *ActionsJWT, sv signature.SignerVerifier, cic *CIC) *OpenPubKey

func SignedOpenPubKey

func SignedOpenPubKey(payload *[]byte, provider OIDCProvider) (*OpenPubKey, error)

Jump to

Keyboard shortcuts

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