Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable JWT Pubkey auth #17

Merged
merged 9 commits into from
Dec 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ version: 2
jobs:
build:
docker:
- image: circleci/golang:1.12.5

environment: GO111MODULE=on
- image: circleci/golang:latest

working_directory: /go/src/github.com/nikogura/dbt
steps:
- checkout

# specify any bash command here prefixed with `run: `
- run: echo "${TEST_PRIVATE_KEY}" | base64 -d > ~/.ssh/id_rsa.test
- run: chmod 700 ~/.ssh/id_rsa.test
- run: echo "${TEST_PUBLIC_KEY}" | base64 -d > ~/.ssh/id_rsa.test.pub
- run: ssh-add ~/.ssh/id_rsa.test
- run: gpg-agent --daemon
- run: go test -v -race -coverprofile=coverage.txt -covermode=atomic ./...
- run: bash <(curl -s https://codecov.io/bash)
Expand Down
41 changes: 36 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,13 @@ Output:

An http repository server. It serves up the various dbt tools and components from a file location on disk.

At present, the repo server supports basic auth via _htpasswd_ file. Other auth options will be available as time allows.
At present, the repo server supports basic auth via _htpasswd_ file and public key auth from an ssh-agent via JWT. Other auth options will be available as time allows.

Separate IDP (Identity Provider) files can be provided to provide privilege separation between tool use (GET) and tool publishing (PUT). Likewise separate auth methods can be used for GET and PUT.

Why did I make it possible to have split auth methods? Flexibility. Passwordless ssh-key auth for a user is good UX. It's secure, and easy for the users. It's kind of a pain for CI systems and other automated uses. Sometimes just sticking a password in the environment is the best way for these use cases. Hey, do what you want. I'm just trying to help.

The PublicKey Auth IDP file contains sections for both GET and PUT, so a single file can be used for both. Obviously if you do use separate files, only the appropriate portion of each file will be read.

### Reposerver Config

Expand All @@ -301,13 +307,38 @@ A JSON file of the form:
"address": "my-hostname.com",
"port": 443,
"serverRoot": "/path/to/where/you/store/tools",
"authType": "basic-htpasswd",
"authTypeGet": "basic-htpasswd",
"authTypePut": "basic-htpasswd",
"authGets": false,
"authOpts": {
"idpFile": "/path/to/htpasswd/file"
}
"authOptsGet": {
"idpFile": "/path/to/htpasswd/file/for/gets"
},
"authOptsPutt": {
"idpFile": "/path/to/htpasswd/file/for/puts"
},
}

### Reposerver IDP File

The reposerver takes an IDP file. In the case of http basic auth, this is a standard htpasswd file.

In the case of Public Key JWT Auth, it looks like so:

{
"getUsers": [
{
"username": "foo",
"publickey": "ssh-rsa ...... [email protected]"
}
],
"putUsers": [
{
"username": "bar",
"publickey": "ssh-rsa ...... [email protected]"
}
]
}

### Running the Reposerver

Command: `dbt reposerver -f /path/to/config`
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "3.1.3",
"version": "3.2.0",
"package": "github.com/nikogura/dbt",
"description": "Dynamic Binary Toolkit - A framework for running self-updating signed binaries from a central, trusted repository.",
"repository": "http://localhost:8081/artifactory/dbt",
Expand Down
2 changes: 1 addition & 1 deletion pkg/dbt/dbt.go
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ func (dbt *DBT) runExec(homedir string, args []string) (err error) {
return err
}

// VerboseOutput Covenience function so I don't have to write 'if verbose {...}' all the time.
// VerboseOutput Convenience function so I don't have to write 'if verbose {...}' all the time.
func (dbt *DBT) VerboseOutput(message string, args ...interface{}) {
if dbt.Verbose {
if len(args) == 0 {
Expand Down
Loading