auth

package
v1.2.5 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2024 License: GPL-3.0 Imports: 11 Imported by: 33

Documentation

Overview

auth package contains helper functions related to internal jwt and external oauth2 authentication.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateGithubAppClient added in v0.1.2

func CreateGithubAppClient(transportCtx context.Context, options *GithubAppOptions) (*github.Client, error)

CreateGithubAppClient creates a one time github app client from the provided app options. The client works for 10 minutes, afterwards the jwt expires and a new one must be created.

func CreateGithubWebhookClient added in v0.1.3

func CreateGithubWebhookClient(awsConfig aws.Config, transportCtx context.Context, githubSecretARN string) (*webhook.Webhook, error)

CreateGithubWebhookClient fetches the githubSecret containing "webhook_secret" from SecretsManager and creates a github app client. The calling instance needs to have IAM access to the action "secretsmanager:GetSecretValue" on the provided githubSecret.

func CreateJWT added in v0.1.1

func CreateJWT(options *JwtOptions, id, provider, username, avatarUrl string) (string, error)

CreateJWT generates a jwt token based on the input options.

func CreateOAuthOptions added in v0.1.1

func CreateOAuthOptions(awsConfig aws.Config, transportCtx context.Context, oauthSecretARN string, endpoint oauth2.Endpoint, redirectUri string, scopes []string) (*oauth2.Config, error)

CreateOAuthOptions fetches the oauthSecret containing "client_id" and "client_secret" from SecretsManager and constructs the oauth.Config. The calling instance needs to have IAM access to the action "secretsmanager:GetSecretValue" on the provided oauthSecretARN.

Types

type GithubAppOptions added in v1.2.5

type GithubAppOptions struct {
	AppId     string
	AppSecret *rsa.PrivateKey
}

func CreateGithubAppOptions added in v1.2.5

func CreateGithubAppOptions(awsConfig aws.Config, transportCtx context.Context, githubSecretARN string) (*GithubAppOptions, error)

CreateGithubAppOptions fetches the githubSecret containing "app_id" and "app_secret" from SecretsManager and creates github app options. The calling instance needs to have IAM access to the action "secretsmanager:GetSecretValue" on the provided githubSecret.

type JwtOptions added in v0.1.1

type JwtOptions struct {
	Secret string
	TTL    time.Duration
}

func CreateJwtOptions added in v0.1.1

func CreateJwtOptions(awsConfig aws.Config, transportCtx context.Context, jwtSecretARN string, ttl time.Duration) (*JwtOptions, error)

CreateJwtOptions fetches the jwtSecret containing "secret" from SecretsManager and constructs the auth.JwtOptions. The calling instance needs to have IAM access to the action "secretsmanager:GetSecretValue" on the provided jwtSecretARN.

type UserClaims added in v0.1.1

type UserClaims struct {
	Id        string `json:"id"`
	Provider  string `json:"provider"`
	Username  string `json:"username"`
	AvatarURL string `json:"avatar_url"`
	jwt.RegisteredClaims
}

func ParseJWT added in v0.1.1

func ParseJWT(options *JwtOptions, token string) (*UserClaims, error)

ParseJWT verifies the jwt string based on the provided options. It returns the user claims or an error if invalid.

Jump to

Keyboard shortcuts

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