Documentation
¶
Index ¶
- Variables
- func CheckOrgMembership(ctx context.Context, accessToken, org string) (bool, error)
- func ExchangeCodeForToken(ctx context.Context, clientID, clientSecret, code string) (string, error)
- func FromContextKey(ctx context.Context, claims *Claims) context.Context
- func GenerateOAuthState(secret []byte, sessionID string) (string, error)
- func GetUsername(ctx context.Context, accessToken string) (string, error)
- func GithubAuthURL(clientID, state, redirectURI string, isOrg bool) string
- func IssueSessionToken(secret []byte, username string) (string, error)
- func ValidateOAuthState(secret []byte, state string) (string, error)
- type Claims
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func CheckOrgMembership ¶
CheckOrgMembership returns true if the authenticated user belongs to the given organization.
func ExchangeCodeForToken ¶
ExchangeCodeForToken exchanges a GitHub OAuth code for an access token.
func GenerateOAuthState ¶
GenerateOAuthState creates a random nonce and signs it with the given secret, returning a state string suitable for use in the OAuth `state` parameter. The format is: base64url(nonce) + "." + base64url(HMAC-SHA256(nonce, secret))
func GetUsername ¶
GetUsername retrieves the authenticated GitHub user's login name.
func GithubAuthURL ¶
func IssueSessionToken ¶
IssueSessionToken creates a signed JWT session token for the given user. The token is valid for 24 hours.
Types ¶
type Claims ¶
type Claims struct {
jwt.RegisteredClaims
}
Claims is the custom JWT claims structure.
func ParseToken ¶
ParseToken parses and validates a signed JWT token, returning the claims.