Movatterモバイル変換


[0]ホーム

URL:


externalauth

package
v2.23.0Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2025 License:AGPL-3.0Imports:22Imported by:0

Details

Repository

github.com/coder/coder

Links

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

funcIsGithubDotComURLadded inv2.14.0

func IsGithubDotComURL(strstring)bool

IsGithubDotComURL returns true if the given URL is a github.com URL.

funcIsInvalidTokenErroradded inv2.13.0

func IsInvalidTokenError(errerror)bool

Types

typeAppInstallation

type AppInstallation struct {IDint// Login is the username of the installation.Loginstring// URL is a link to configure the app install.URLstring}

typeConfig

type Config struct {promoauth.InstrumentedOAuth2Config// ID is a unique identifier for the authenticator.IDstring// Type is the type of provider.Typestring// DeviceAuth is set if the provider uses the device flow.DeviceAuth *DeviceAuth// DisplayName is the name of the provider to display to the user.DisplayNamestring// DisplayIcon is the path to an image that will be displayed to the user.DisplayIconstring// ExtraTokenKeys is a list of extra properties to// store in the database returned from the token endpoint.//// e.g. Slack returns `authed_user` in the token which is// a payload that contains information about the authenticated// user.ExtraTokenKeys []string// NoRefresh stops Coder from using the refresh token// to renew the access token.//// Some organizations have security policies that require// re-authentication for every token.NoRefreshbool// ValidateURL ensures an access token is valid before// returning it to the user. If omitted, tokens will// not be validated before being returned.ValidateURLstring// Regex is a Regexp matched against URLs for// a Git clone. e.g. "Username for 'https://github.com':"// The regex would be `github\.com`..Regex *regexp.Regexp// AppInstallURL is for GitHub App's (and hopefully others eventually)// to provide a link to install the app. There's installation// of the application, and user authentication. It's possible// for the user to authenticate but the application to not.AppInstallURLstring// AppInstallationsURL is an API endpoint that returns a list of// installations for the user. This is used for GitHub Apps.AppInstallationsURLstring}

Config is used for authentication for Git operations.

funcConvertConfig

func ConvertConfig(instrument *promoauth.Factory, entries []codersdk.ExternalAuthConfig, accessURL *url.URL) ([]*Config,error)

ConvertConfig converts the SDK configuration entry formatto the parsed and ready-to-consume in coderd provider type.

func (*Config)AppInstallations

func (c *Config) AppInstallations(ctxcontext.Context, tokenstring) ([]codersdk.ExternalAuthAppInstallation,bool,error)

AppInstallations returns a list of app installations for the given token.If the provider does not support app installations, it returns nil.

func (*Config)GenerateTokenExtraadded inv2.3.0

func (c *Config) GenerateTokenExtra(token *oauth2.Token) (pqtype.NullRawMessage,error)

GenerateTokenExtra generates the extra token data to store in the database.

func (*Config)RefreshToken

func (c *Config) RefreshToken(ctxcontext.Context, dbdatabase.Store, externalAuthLinkdatabase.ExternalAuthLink) (database.ExternalAuthLink,error)

RefreshToken automatically refreshes the token if expired and permitted.If an error is returned, the token is either invalid, or an error occurred.Use 'IsInvalidTokenError(err)' to determine the difference.

func (*Config)ValidateToken

func (c *Config) ValidateToken(ctxcontext.Context, link *oauth2.Token) (bool, *codersdk.ExternalAuthUser,error)

ValidateToken ensures the Git token provided is valid!The user is optionally returned if the provider supports it.

typeDeviceAuth

type DeviceAuth struct {// Config is provided for the http client method.Configpromoauth.InstrumentedOAuth2ConfigClientIDstringTokenURLstringScopes   []stringCodeURLstring}

func (*DeviceAuth)AuthorizeDevice

func (c *DeviceAuth) AuthorizeDevice(ctxcontext.Context) (*codersdk.ExternalAuthDevice,error)

AuthorizeDevice begins the device authorization flow.See:https://tools.ietf.org/html/rfc8628#section-3.1

func (*DeviceAuth)ExchangeDeviceCode

func (c *DeviceAuth) ExchangeDeviceCode(ctxcontext.Context, deviceCodestring) (*oauth2.Token,error)

ExchangeDeviceCode exchanges a device code for an access token.The boolean returned indicates whether the device code is still pendingand the caller should try again.

typeExchangeDeviceCodeResponse

type ExchangeDeviceCodeResponse struct {AccessTokenstring `json:"access_token"`RefreshTokenstring `json:"refresh_token"`ExpiresInint    `json:"expires_in"`Errorstring `json:"error"`ErrorDescriptionstring `json:"error_description"`}

typeInvalidTokenErroradded inv2.13.0

type InvalidTokenErrorstring

InvalidTokenError is a case where the "RefreshToken" failed to completeas a result of invalid credentials. Error contains the reason of the failure.

func (InvalidTokenError)Erroradded inv2.13.0

func (eInvalidTokenError) Error()string

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp