Documentation ¶
Index ¶
- Constants
- Variables
- func DoBrowserDance(config *ClientAppConfiguration) (string, string, error)
- func DoOOBDance(config *ClientAppConfiguration) (string, string, error)
- func FetchCerts(config *ClientAppConfiguration, idToken string, sshDir string, ...) error
- func ProcessClient(config *ClientAppConfiguration) error
- func Reauthorize(config *ClientAppConfiguration, path string) error
- func ReplaceSectionOfFile(name string, path string, lines []string, perm os.FileMode, ...) error
- func SafeSave(path string, contents []byte, perm os.FileMode) error
- func SaveCreds(path string, creds *CachedCreds) error
- func ValidateMachineIsSuitable(config *ClientAppConfiguration) error
- type CachedCreds
- type ClientAppConfiguration
- type IDTokenClaims
- type IDTokenValidator
- type OIDCIDTokenValidator
- type OOIDClient
Constants ¶
const ( RedirectOOB = "urn:ietf:wg:oauth:2.0:oob" RedirectLocalhost = "http://localhost" )
Variables ¶
var ( ErrUserDenied = errors.New("User clicked deny.") ErrWrongKeyFileType = errors.New("Wrong key file type.") ErrWrongCertType = errors.New("Wrong cert file type.") )
var ( ErrUnexpectedAlgorithm = errors.New("ErrUnexpectedAlgorithm") ErrMissingKeyID = errors.New("ErrMissingKeyID") ErrMissingCertificate = errors.New("ErrMissingCertificate") ErrUnexpectedServerResponse = errors.New("ErrUnexpectedServerResponse") ErrCertificateNotValid = errors.New("ErrCertificateNotValid") )
var (
ErrInvalidIDToken = errors.New("ErrInvalidIDToken")
)
Functions ¶
func DoBrowserDance ¶
func DoBrowserDance(config *ClientAppConfiguration) (string, string, error)
Try to launch a browser, redirect to local server etc etc Return code, redirect URI, error
func DoOOBDance ¶
func DoOOBDance(config *ClientAppConfiguration) (string, string, error)
func FetchCerts ¶
func FetchCerts(config *ClientAppConfiguration, idToken string, sshDir string, homePathToSSHDir string) error
sshDir is the absolute path homePathToSSHDir is the path to use inside of a config file, this should contain a ~ rather than be absolute as it allows this .ssh dir to be mounted as a volume inside of Docker and work well.
func ProcessClient ¶
func ProcessClient(config *ClientAppConfiguration) error
func Reauthorize ¶
func Reauthorize(config *ClientAppConfiguration, path string) error
Prompt user to
func ReplaceSectionOfFile ¶
func ReplaceSectionOfFile(name string, path string, lines []string, perm os.FileMode, messageIfChanged string) error
Deletes section with name:
# AUTOGENERATED:BEGIN:name ... # AUTOGENERATED:END:name
and adds new section at end with same.
func SaveCreds ¶
func SaveCreds(path string, creds *CachedCreds) error
func ValidateMachineIsSuitable ¶
func ValidateMachineIsSuitable(config *ClientAppConfiguration) error
We can use this to soft-enforce only giving certificates out if reasonable precautions are in place in the client device, e.g. enforce full disk encryption with machine passcode.
Types ¶
type CachedCreds ¶
type CachedCreds struct { AccessToken string `json:"access_token"` TokenType string `json:"token_type"` IDToken string `json:"id_token"` RefreshToken string `json:"refresh_token"` }
func LoadCreds ¶
func LoadCreds(path string) (*CachedCreds, error)
func SwapCodeForTokens ¶
func SwapCodeForTokens(config *ClientAppConfiguration, code, redir string) (*CachedCreds, error)
func SwapRefreshForTokens ¶
func SwapRefreshForTokens(config *ClientAppConfiguration, refreshToken string) (*CachedCreds, error)
type ClientAppConfiguration ¶
type ClientAppConfiguration struct { HostedDomain string // Matches against field in Google response. Should be your domain name. ClientID string // Client ID as configured with Google: https://console.developers.google.com/ ClientNotSoSecret string // Client "Secret" corresponding to the Client ID. Note, despite the name, this is not really a secret nor intended to be. GRPCPEMCertificate string // If set, Self-signed GRPC server certificate, else GRPCPEMCertificatePath is used GRPCServer string // server:host CredentialFileName string // e.g. .geecerttoken GRPCPEMCertificatePath string // If set, path to PEM for server certificate OverrideMachinePolicy bool // If true, override machine policy such as requiring FDE OverrideGrpcSecurity bool // If true, allow insecure connection to gRPC server UseSystemCaForCert bool // If true, use a system CA instead of self-signed certificate DontWriteKeysToDisk bool // If true, never write private keys/certs to disk, instead use agent only OverrideNoKeysToDisk bool // If true, ignore the above, but print a WARNING ShortlivedKeyName string // e.g. id_orgname_shortlived_rsa SectionIdentifier string // e.g. ORGNAME-CA OpenIDConfigurationURL string // e.g.https://accounts.google.com/.well-known/openid-configuration for Google, https://login.microsoftonline.com/<tenancy id>/.well-known/openid-configuration for Azure AD OOBURI string // if set, overrides std one NeverOpenBrowser bool PortForLocalHost int // if 0, a random one is used AudienceInAppID bool // if set verify "appid" claim for client ID, INSTEAd OF "aud" claim - useful for Azure Access Token GetHostedDomainFromEmail bool // if set, check for suffix in email field instead of "hd" cliam. useful for Azure Access Token SkipEmailVerified bool // if set, don't require email_verified field. Useful for Azure Access token UseAccessTokenInstead bool // if set, validate access token instead of id token. Useful for Azure AD which won't refresh ID Tokens // contains filtered or unexported fields }
func (*ClientAppConfiguration) ExtractTokenFromCachedCreds ¶
func (c *ClientAppConfiguration) ExtractTokenFromCachedCreds(creds *CachedCreds) string
func (*ClientAppConfiguration) Init ¶
func (config *ClientAppConfiguration) Init()
type IDTokenClaims ¶
func ValidateTokenWithRetryForClock ¶
func ValidateTokenWithRetryForClock(validator IDTokenValidator, idToken string, retries int) (*IDTokenClaims, error)
type IDTokenValidator ¶
type IDTokenValidator interface { // Validates a token, including that it matchines the client ID and hosted domain // Returns the email address and nil upon success ValidateIDToken(idToken string) (*IDTokenClaims, error) }
type OIDCIDTokenValidator ¶
type OIDCIDTokenValidator struct { ConfigurationURL string ClientID string HostedDomain string AudienceInAppID bool // if set verify "appid" claim for client ID, INSTEAd OF "aud" claim - useful for Azure Access Token GetHostedDomainFromEmail bool // if set, check for suffix in email field instead of "hd" cliam. useful for Azure Access Token SkipEmailVerified bool // if set, don't require email_verified field. Useful for Azure Access token // contains filtered or unexported fields }
func (*OIDCIDTokenValidator) GetAuthRedirect ¶
func (v *OIDCIDTokenValidator) GetAuthRedirect(redir string) (string, error)
func (*OIDCIDTokenValidator) GetTokenExchangeEndpoint ¶
func (v *OIDCIDTokenValidator) GetTokenExchangeEndpoint() (string, error)
func (*OIDCIDTokenValidator) ValidateIDToken ¶
func (v *OIDCIDTokenValidator) ValidateIDToken(idToken string) (*IDTokenClaims, error)
Validates a token, including that it matchines the client ID and hosted domain Returns the email address and nil upon success