Documentation
¶
Index ¶
- Constants
- Variables
- func CurrentSystemToken(installationID string) (string, time.Time, error)
- func LoadSystemToken(ctx context.Context, tx *gorm.DB, encryptor crypto.Encryptor, ...) (string, time.Time, error)
- func RSAPublicKey(modulus, exponent string) (*rsa.PublicKey, error)
- func SetSystemTokenSource(source SystemTokenSource)
- func ShouldReplaceToken(currentExpiry, deliveredExpiry time.Time) bool
- func VerificationKeyfunc(ctx context.Context, jwksURL string) (jwtlib.Keyfunc, error)
- type Invocation
- type SystemTokenSource
Constants ¶
const ( // StaleAfter is how long SuperPlane waits for another Forge delivery // before it treats the cached system token as unusable. StaleAfter = 3 * time.Hour )
Variables ¶
var ErrReconnect = errors.New(reconnect)
ErrReconnect means the cached Forge token is missing, expired, or stale.
Functions ¶
func CurrentSystemToken ¶
CurrentSystemToken returns the cached bot token for one Forge installation.
func LoadSystemToken ¶
func LoadSystemToken(ctx context.Context, tx *gorm.DB, encryptor crypto.Encryptor, installationID string, now time.Time) (string, time.Time, error)
LoadSystemToken reads and decrypts the token stored for an installation.
func RSAPublicKey ¶
RSAPublicKey builds a verification key from a JWKS entry.
func SetSystemTokenSource ¶
func SetSystemTokenSource(source SystemTokenSource)
SetSystemTokenSource installs the process-wide reader for Forge system tokens. The Bitbucket integration calls it when a runner needs credentials.
func ShouldReplaceToken ¶
ShouldReplaceToken reports whether a newly delivered token expires later than the one already cached. A near-expiry token must not overwrite a longer-lived one.
Types ¶
type Invocation ¶
type Invocation struct {
AppID string
InstallationID string
APIBaseURL string
WorkspaceUUID string
InstallerAccountID string
EventType string
SystemToken string
SystemTokenExpires time.Time
}
Invocation is a verified Forge call to SuperPlane.
func ParseInvocation ¶
func ParseInvocation(fit, systemToken, expectedAppID string, keyfunc jwtlib.Keyfunc) (Invocation, error)
ParseInvocation verifies a Forge Invocation Token and reads the system token expiry. The system token itself stays opaque except for the exp claim, which Forge documents as the way to know how long the token remains valid.