github

package
v0.1.35 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package github provides a GitHub-specific identity provider adapter that resolves GitHub user identities and organization memberships for use with the RBAC system.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoPrimaryEmail = errors.New("no primary verified email found")

ErrNoPrimaryEmail is returned when no primary verified email is found.

Functions

This section is empty.

Types

type Client

type Client interface {
	// GetUser returns the authenticated user.
	GetUser(ctx context.Context) (*github.User, error)
	// ListEmails returns the authenticated user's email addresses.
	ListEmails(ctx context.Context) ([]*github.UserEmail, error)
	// ListOrgs returns the organizations the authenticated user belongs to.
	ListOrgs(ctx context.Context) ([]*github.Organization, error)
}

Client abstracts the GitHub API calls needed by the identity provider.

type ClientFactory

type ClientFactory func(ctx context.Context, accessToken string) Client

ClientFactory creates a GitHub API client from an OAuth access token. This abstraction enables testing without real HTTP calls.

type IdentityProvider

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

IdentityProvider implements userport.IdentityProviderUsecase for GitHub.

func NewIdentityProvider

func NewIdentityProvider(
	clientFactory ClientFactory,
	logger *slog.Logger,
) *IdentityProvider

NewIdentityProvider creates a new GitHub identity provider.

func (*IdentityProvider) ListOrganizations

func (p *IdentityProvider) ListOrganizations(
	ctx context.Context,
	accessToken string,
) ([]string, error)

ListOrganizations implements userport.IdentityProviderUsecase.

func (*IdentityProvider) ProviderName

func (p *IdentityProvider) ProviderName() string

ProviderName implements userport.IdentityProviderUsecase.

func (*IdentityProvider) ResolveIdentity

func (p *IdentityProvider) ResolveIdentity(
	ctx context.Context,
	accessToken string,
) (*usermodel.ExternalIdentity, error)

ResolveIdentity implements userport.IdentityProviderUsecase.

Jump to

Keyboard shortcuts

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