githubapp

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package githubapp is a small web app that signs users in with GitHub, through the OAuth web flow of an OAuth app with PKCE, and reads their profile, repositories and issues with the GitHub REST API. It is the app under test of the GitHub end-to-end tests: it knows nothing about vlatte, only the base URLs of github.com and api.github.com it is given.

Index

Constants

View Source
const (
	StateCookie    = "oauth_state"
	VerifierCookie = "oauth_verifier"
	SessionCookie  = "session"
)

Cookies the app sets in the browser.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	// contains filtered or unexported fields
}

App is the web app. Its routes:

Its cookies are Secure: serve it over HTTPS.

  • GET /login sends the browser to GitHub to sign in, with a state and a PKCE code challenge (S256).
  • GET /callback is where GitHub sends it back. It checks the state, exchanges the code and the code verifier for a token, starts a session and sends the browser to /me.
  • GET /me, GET /repos and GET /repos/{owner}/{repo}/issues answer, as JSON, the user's login and name, the full names of their repositories and the titles of a repository's issues.

Without a session, the API routes answer 401. When GitHub refuses the token, the app ends the session and answers 401.

func New

func New(cfg Config) *App

New returns the app.

func (*App) ServeHTTP

func (app *App) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements http.Handler.

type Config

type Config struct {
	// AuthURL is the base URL of github.com, which serves the OAuth web flow.
	AuthURL string
	// APIURL is the base URL of api.github.com.
	APIURL string
	// ClientID and ClientSecret are the credentials of the OAuth app.
	ClientID     string
	ClientSecret string
	// RedirectURL is where GitHub sends the browser back to: the /callback route of this app.
	RedirectURL string
	// Scope is what the app asks the user to grant, such as "read:user repo".
	Scope string
}

Config is where GitHub is and who the app is to it.

Jump to

Keyboard shortcuts

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