Documentation ¶
Index ¶
- Constants
- Variables
- func CheckPubkeyAuth(w http.ResponseWriter, r *http.Request, ...) (username string)
- func DefaultSession(s3meta *S3Meta) (awssession *session.Session, err error)
- func DirCopy(src string, dst string) error
- func DirsForURL(uri string) (dirs []string, err error)
- func FileCopy(src, dst string) error
- func FileSha1(fileName string) (checksum string, err error)
- func FileSha256(fileName string) (checksum string, err error)
- func GenerateDbtDir(homedir string, verbose bool) (err error)
- func GetFunc(shellCommand string) (result string, err error)
- func GetFuncUsername(shellCommand string, username string) (result string, err error)
- func GetHomeDir() (dir string, err error)
- func LatestVersion(versions []string) (latest string)
- func SemverParse(version string) (parts []int, err error)
- func Spaceship(a int, b int) int
- func StringInSlice(a string, list []string) bool
- func VersionAIsNewerThanB(a string, b string) (result bool)
- func Wrap(wrapped AuthenticatedHandlerFunc, ...) http.HandlerFunc
- type AuthOpts
- type AuthenticatedHandlerFunc
- type AuthenticatedRequest
- type Config
- type DBT
- func (dbt *DBT) AuthHeaders(r *http.Request) (err error)
- func (dbt *DBT) FetchCatalog(showVersions bool) (err error)
- func (dbt *DBT) FetchFile(fileUrl string, destPath string) (err error)
- func (dbt *DBT) FetchToolDescription(tool string, version string) (description string, err error)
- func (dbt *DBT) FetchToolNames() (tools []Tool, err error)
- func (dbt *DBT) FetchToolVersions(toolName string) (versions []string, err error)
- func (dbt *DBT) FetchTrustStore(homedir string) (err error)
- func (dbt *DBT) FindLatestVersion(toolName string) (latest string, err error)
- func (dbt *DBT) IsCurrent(binaryPath string) (ok bool, err error)
- func (dbt *DBT) ParseVersionResponse(resp *http.Response) (versions []string)
- func (dbt *DBT) RunTool(version string, args []string, homedir string, offline bool) (err error)
- func (dbt *DBT) S3FetchDescription(meta S3Meta) (description string, err error)
- func (dbt *DBT) S3FetchFile(fileUrl string, meta S3Meta, outFile *os.File) (err error)
- func (dbt *DBT) S3FetchToolNames(meta S3Meta) (tools []Tool, err error)
- func (dbt *DBT) S3FetchToolVersions(meta S3Meta) (versions []string, err error)
- func (dbt *DBT) S3FetchTruststore(homedir string, meta S3Meta) (err error)
- func (dbt *DBT) S3ToolExists(meta S3Meta) (found bool, err error)
- func (dbt *DBT) S3ToolVersionExists(meta S3Meta) (ok bool, err error)
- func (dbt *DBT) S3VerifyFileVersion(filePath string, meta S3Meta) (success bool, err error)
- func (dbt *DBT) SetVerbose(verbose bool)
- func (dbt *DBT) ToolExists(toolName string) (found bool, err error)
- func (dbt *DBT) ToolVersionExists(tool string, version string) (ok bool, err error)
- func (dbt *DBT) UpgradeInPlace(binaryPath string) (err error)
- func (dbt *DBT) VerboseOutput(message string, args ...interface{})
- func (dbt *DBT) VerifyFileChecksum(filePath string, expected string) (success bool, err error)
- func (dbt *DBT) VerifyFileSignature(homedir string, filePath string) (success bool, err error)
- func (dbt *DBT) VerifyFileVersion(fileUrl string, filePath string) (success bool, err error)
- type DBTRepoServer
- func (d *DBTRepoServer) CheckPubkeysGetFile(wrapped http.HandlerFunc) http.HandlerFunc
- func (d *DBTRepoServer) CheckPubkeysGetFunc(wrapped http.HandlerFunc) http.HandlerFunc
- func (d *DBTRepoServer) HandlePut(path string, body io.ReadCloser, md5sum string, sha1sum string, ...) (err error)
- func (d *DBTRepoServer) PubkeyFromFileGet(subject string) (pubkeys string, err error)
- func (d *DBTRepoServer) PubkeyFromFilePut(subject string) (pubkeys string, err error)
- func (d *DBTRepoServer) PubkeysFromFuncGet(subject string) (pubkey string, err error)
- func (d *DBTRepoServer) PubkeysFromFuncPut(subject string) (pubkey string, err error)
- func (d *DBTRepoServer) PutHandlerHtpasswd(w http.ResponseWriter, r *auth.AuthenticatedRequest)
- func (d *DBTRepoServer) PutHandlerPubkeyFile(w http.ResponseWriter, r *http.Request)
- func (d *DBTRepoServer) PutHandlerPubkeyFunc(w http.ResponseWriter, r *http.Request)
- func (d *DBTRepoServer) RunRepoServer() (err error)
- type DbtConfig
- type PubkeyIdpFile
- type PubkeyUser
- type S3Meta
- type Tool
- type ToolsConfig
Constants ¶
const AUTH_BASIC_HTPASSWD = "basic-htpasswd"
AUTH_BASIC_HTPASSWD config flag for basic auth
const AUTH_BASIC_LDAP = "basic-ldap"
AUTH_BASIC_LDAP config flag for user/password auth off an LDAP directory server
const AUTH_SSH_AGENT_FILE = "ssh-agent-file"
AUTH_SSH_AGENT_FILE config setting for file based ssh-agent auth (file mapping principals to public keys similer to .htaccess files)
const AUTH_SSH_AGENT_FUNC = "ssh-agent-func"
AUTH_SSH_AGENT_FUNC config setting for using a shell function to retrieve the public key for a principal
const AUTH_SSH_AGENT_LDAP = "ssh-agent-ldap"
AUTH_SSH_AGENT_LDAP flag for configuring ssh-agent auth pulling public key from an LDAP directory
const AWS_ID_ENV_VAR = "AWS_ACCESS_KEY_ID"
AWS_ID_ENV_VAR Default env var for AWS access key
const AWS_REGION_ENV_VAR = "AWS_DEFAULT_REGION"
AWS_REGION_ENV_VAR Default env var for AWS region
const AWS_SECRET_ENV_VAR = "AWS_SECRET_ACCESS_KEY"
AWS_SECRET_ENV_VAR Default env var for AWS secret key
const ConfigDir = DbtDir + "/conf"
ConfigDir is the directory where Dbt expects to find configuration info
const ConfigFilePath = ConfigDir + "/dbt.json"
ConfigFilePath is the actual dbt config file path
const DbtDir = ".dbt"
DbtDir is the standard dbt directory. Usually ~/.dbt
const ToolDir = DbtDir + "/tools"
ToolDir is the directory where tools get downloaded to
const TrustDir = DbtDir + "/trust"
TrustDir is the directory under the dbt dir where the trust store is downloaded to
const TruststorePath = TrustDir + "/truststore"
TruststorePath is the actual file path to the downloaded trust store
const VERSION = "3.6.0"
VERSION DBT's version
Variables ¶
var NOPROGRESS = false
NOPROGRESS turns off the progress bar on file fetches. Primarily used for testing to avoid cluttering up the output and confusing the test harness.
Functions ¶
func CheckPubkeyAuth ¶
func CheckPubkeyAuth(w http.ResponseWriter, r *http.Request, pubkeyRetrievalFunc func(subject string) (pubkeys string, err error)) (username string)
CheckPubkeyAuth Function that actually checks the Token sent by the client in the headers.
func DefaultSession ¶
DefaultSession creates a default AWS session from local config path. Hooks directly into credentials if present, or Credentials Provider if configured.
func DirsForURL ¶
DirsForURL given a URL, return a list of path elements suitable for creating directories/ folders
func FileSha256 ¶
FileSha256 returns the hex encoded Sha256 checksum for the given file
func GenerateDbtDir ¶
GenerateDbtDir generates the necessary dbt dirs in the user's homedir if they don't already exist. If they do exist, it does nothing.
func GetFunc ¶
GetFunc runs a shell command that is a getter function. This could certainly be dangerous, so be careful how you use it.
func GetFuncUsername ¶
GetFuncUsername runs a shell command that is a getter function for the username. This could certainly be dangerous, so be careful how you use it.
func GetHomeDir ¶
GetHomeDir get's the current user's homedir
func LatestVersion ¶
LatestVersion returns the latest version teased out of a list of semantic version strings.
func SemverParse ¶
SemverParse breaks apart a semantic version strings and returns a slice of int's holding the parts
func Spaceship ¶
Spaceship A very simple implementation of a useful operator that go seems not to have. returns 1 if a > b, -1 if a < b, and 0 if a == b
func StringInSlice ¶
StringInSlice returns true if the given string is in the given slice
func VersionAIsNewerThanB ¶
VersionAIsNewerThanB returns true if Semantic Version string v1 is newer (higher numbers) than Semantic Version string v2
func Wrap ¶
func Wrap(wrapped AuthenticatedHandlerFunc, pubkeyRetrievalFunc func(subject string) (pubkeys string, err error)) http.HandlerFunc
Wrap returns an http.HandlerFunc which wraps AuthenticatedHandlerFunc
Types ¶
type AuthenticatedHandlerFunc ¶
type AuthenticatedHandlerFunc func(http.ResponseWriter, *AuthenticatedRequest)
AuthenticatedHandlerFunc is like http.HandlerFunc, but takes AuthenticatedRequest instead of http.Request
type AuthenticatedRequest ¶
type AuthenticatedRequest struct { http.Request /* Authenticated user name. Current API implies that Username is never empty, which means that authentication is always done before calling the request handler. */ Username string }
AuthenticatedRequest Basically an http.Request with an added Username field. The Username should never be empty.
type Config ¶
type Config struct { Dbt DbtConfig `json:"dbt"` Tools ToolsConfig `json:"tools"` Username string `json:"username,omitempty"` Password string `json:"password,omitempty"` UsernameFunc string `json:"usernamefunc,omitempty"` PasswordFunc string `json:"passwordfunc,omitempty"` Pubkey string `json:"pubkey,omitempty"` PubkeyPath string `json:"pubkeypath,omitempty"` PubkeyFunc string `json:"pubkeyfunc,omitempty"` }
Config configuration of the dbt object
type DBT ¶
DBT the dbt object itself
func (*DBT) AuthHeaders ¶
AuthHeaders Convenience function to add auth headers - basic or token for non-s3 requests. Depending on how client is configured, could result in both Basic Auth and Token headers. Reposerver will, however only pay attention to one or the other.
func (*DBT) FetchCatalog ¶
FetchCatalog shows you what tools are available in your trusted repo. Repo is figured out from the config in ~/.dbt/conf/dbt.json
func (*DBT) FetchFile ¶
FetchFile Fetches a file and places it on the filesystem. Does not validate the signature. That's a different step.
func (*DBT) FetchToolDescription ¶
FetchToolDescription fetches the tool description from the repository.
func (*DBT) FetchToolNames ¶
FetchToolNames returns a list of tool names found in the trusted repo
func (*DBT) FetchToolVersions ¶
FetchToolVersions Given the name of a tool, returns the available versions, and possibly an error if things didn't go well. If tool name is "", fetches versions of dbt itself.
func (*DBT) FetchTrustStore ¶
FetchTrustStore writes the downloaded trusted signing public keys to disk.
func (*DBT) FindLatestVersion ¶
FindLatestVersion finds the latest version of the tool available in the tool repo. If the tool name is "", it is expecting to parse versions of dbt itself.
func (*DBT) IsCurrent ¶
IsCurrent returns whether the currently running version is the latest version, and possibly an error if the version check fails
func (*DBT) ParseVersionResponse ¶
ParseVersionResponse does an http get of an url and returns a list of semantic version links found at that place
func (*DBT) S3FetchDescription ¶
S3FetchDescription fetches the tool description from S3
func (*DBT) S3FetchFile ¶
S3FetchFile fetches a file out of S3 instead of using a normal HTTP GET
func (*DBT) S3FetchToolNames ¶
S3FetchToolNames fetches the list of available tools from S3
func (*DBT) S3FetchToolVersions ¶
S3FetchToolVersions fetches available versions for a tool from S3
func (*DBT) S3FetchTruststore ¶
S3FetchTruststore fetches the truststore out of S3 writing it into the dbt dir on the local disk
func (*DBT) S3ToolExists ¶
S3ToolExists detects whether a tool exists in S3 by looking at the top level folder for the tool
func (*DBT) S3ToolVersionExists ¶
S3ToolVersionExists returns true if the tool version exists
func (*DBT) S3VerifyFileVersion ¶
S3VerifyFileVersion verifies the version of a file on the filesystem matches the sha256 hash stored in the s3 bucket for that file
func (*DBT) SetVerbose ¶
SetVerbose Sets the verbose option on the dbt object
func (*DBT) ToolExists ¶
ToolExists Returns true if a tool of the name input exists in the repository given.
func (*DBT) ToolVersionExists ¶
ToolVersionExists returns true if the specified version of a tool is in the repo
func (*DBT) UpgradeInPlace ¶
UpgradeInPlace upgraded dbt in place
func (*DBT) VerboseOutput ¶
VerboseOutput Convenience function so I don't have to write 'if verbose {...}' all the time.
func (*DBT) VerifyFileChecksum ¶
VerifyFileChecksum Verifies the sha256 checksum of a given file against an expected value
func (*DBT) VerifyFileSignature ¶
VerifyFileSignature verifies the signature on the given file
type DBTRepoServer ¶
type DBTRepoServer struct { Address string `json:"address"` Port int `json:"port"` ServerRoot string `json:"serverRoot"` AuthTypeGet string `json:"authTypeGet"` AuthTypePut string `json:"authTypePut"` AuthGets bool `json:"authGets"` AuthOptsGet AuthOpts `json:"authOptsGet"` AuthOptsPut AuthOpts `json:"authOptsPut"` }
DBTRepoServer The reference 'trusted repository' server for dbt.
func NewRepoServer ¶
func NewRepoServer(configFilePath string) (server *DBTRepoServer, err error)
NewRepoServer creates a new DBTRepoServer object from the config file provided.
func (*DBTRepoServer) CheckPubkeysGetFile ¶
func (d *DBTRepoServer) CheckPubkeysGetFile(wrapped http.HandlerFunc) http.HandlerFunc
CheckPubkeysGetFile Checks the pubkey signature in the JWT token against a public key found in a htpasswd like file and if things check out, passes things along to the provided handler.
func (*DBTRepoServer) CheckPubkeysGetFunc ¶
func (d *DBTRepoServer) CheckPubkeysGetFunc(wrapped http.HandlerFunc) http.HandlerFunc
CheckPubkeysGetFunc Checks the pubkey signature in the JWT token against a public key produced from a function and if things check out, passes things along to the provided handler.
func (*DBTRepoServer) HandlePut ¶
func (d *DBTRepoServer) HandlePut(path string, body io.ReadCloser, md5sum string, sha1sum string, sha256sum string) (err error)
func (*DBTRepoServer) PubkeyFromFileGet ¶
func (d *DBTRepoServer) PubkeyFromFileGet(subject string) (pubkeys string, err error)
PubkeyFromFileGet takes a subject name, and pulls the corresponding pubkey out of the identity provider file for puts
func (*DBTRepoServer) PubkeyFromFilePut ¶
func (d *DBTRepoServer) PubkeyFromFilePut(subject string) (pubkeys string, err error)
PubkeyFromFilePut takes a subject name, and pulls the corresponding pubkey out of the identity provider file for puts
func (*DBTRepoServer) PubkeysFromFuncGet ¶
func (d *DBTRepoServer) PubkeysFromFuncGet(subject string) (pubkey string, err error)
PubkeyFromFuncGet takes a subject name, and runs the configured function to return the corresponding public key
func (*DBTRepoServer) PubkeysFromFuncPut ¶
func (d *DBTRepoServer) PubkeysFromFuncPut(subject string) (pubkey string, err error)
PubkeyFromFuncPut takes a subject name, and runs the configured function to return the corresponding public key
func (*DBTRepoServer) PutHandlerHtpasswd ¶
func (d *DBTRepoServer) PutHandlerHtpasswd(w http.ResponseWriter, r *auth.AuthenticatedRequest)
PutHandlerHtpasswd Handles puts with htpasswd auth
func (*DBTRepoServer) PutHandlerPubkeyFile ¶
func (d *DBTRepoServer) PutHandlerPubkeyFile(w http.ResponseWriter, r *http.Request)
PutHandlerPubKeyFile
func (*DBTRepoServer) PutHandlerPubkeyFunc ¶
func (d *DBTRepoServer) PutHandlerPubkeyFunc(w http.ResponseWriter, r *http.Request)
PutHandlerPubkeyFunc
func (*DBTRepoServer) RunRepoServer ¶
func (d *DBTRepoServer) RunRepoServer() (err error)
RunRepoServer Run runs the test repository server.
type PubkeyIdpFile ¶
type PubkeyIdpFile struct { GetUsers []PubkeyUser `json:"getUsers"` PutUsers []PubkeyUser `json:"putUsers"` }
PubkeyIdpFile A representation of a public key IDP (Identity Provider) file. Will have a list of users allowed to GET and a list of users authorized to PUT.
func LoadPubkeyIdpFile ¶
func LoadPubkeyIdpFile(filePath string) (pkidp PubkeyIdpFile, err error)
LoadPubkeyIdpFile Loads a public key IDP JSON file.
type PubkeyUser ¶
type PubkeyUser struct { Username string `json:"username"` AuthorizedKey string `json:"publickey"` }
PubkeyUser A representation of a user permitted to authenticate via public key. PubkeyUsers will have at minimum a Username, and a list of authorized public keys.
type S3Meta ¶
S3Meta a struct for holding metadata for S3 Objects. There's probably already a struct that holds this, but this is all I need.
type ToolsConfig ¶
type ToolsConfig struct {
Repo string `json:"repository"`
}
ToolsConfig is the config information for the tools to be downloaded and run