github

package
v1.21.6 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const Name = "github"

Variables

This section is empty.

Functions

This section is empty.

Types

type Provider

type Provider struct {
	*generic.Provider
	// contains filtered or unexported fields
}

func NewProvider

func NewProvider(ctx context.Context, conf config.Config, httpClient *http.Client) (*Provider, error)

func (*Provider) CheckUser

func (p *Provider) CheckUser(
	ctx context.Context, state state.State, userData types.UserData, tokens *oidc.Tokens[*idtoken.Claims],
) error

CheckUser implements the github.com/JustARegularUsername/openvpn-auth-oauth2/internal/oauth2.Provider interface. It checks if mets specific GitHub related conditions.

func (*Provider) GetName

func (p *Provider) GetName() string

func (*Provider) GetProviderConfig

func (p *Provider) GetProviderConfig(conf config.Config) (types.ProviderConfig, error)

GetProviderConfig implements the github.com/JustARegularUsername/openvpn-auth-oauth2/internal/oauth2.Provider interface. It returns the OAuth2 GitHub endpoints.GitHub, since GitHub does not support OIDC discovery.

func (*Provider) GetRefreshToken

func (p *Provider) GetRefreshToken(tokens *oidc.Tokens[*idtoken.Claims]) string

GetRefreshToken returns the oauth2.Token.AccessToken of the user, since it does not expire. OAuth2 App on GitHub doesn't provide a refresh token.

func (*Provider) GetUser

func (p *Provider) GetUser(ctx context.Context, _ *slog.Logger, tokens *oidc.Tokens[*idtoken.Claims]) (types.UserData, error)

func (*Provider) Refresh

func (p *Provider) Refresh(_ context.Context, _ *slog.Logger, _ rp.RelyingParty, refreshToken string) (*oidc.Tokens[*idtoken.Claims], error)

Refresh use the oauth2.Token.AccessToken from initial authentication and call the REST API if the user is still present inside the required groups.

func (*Provider) RevokeRefreshToken

func (p *Provider) RevokeRefreshToken(_ context.Context, _ *slog.Logger, _ rp.RelyingParty, _ string) error

Jump to

Keyboard shortcuts

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