Skip to content

Commit

Permalink
Working with current vault !
Browse files Browse the repository at this point in the history
  • Loading branch information
Félix Cantournet committed Jan 2, 2017
1 parent e3e9da8 commit ae07077
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 2 deletions.
1 change: 0 additions & 1 deletion cmd/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ func newVaultCtl() *cli.App {
app.Commands = []cli.Command{
newSyncCommand(),
newTransitCommand(),
newKubeCommand(),
}

return app
Expand Down
31 changes: 31 additions & 0 deletions cmd/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ import (

"github.com/fcantournet/vault-sync/pkg/api"
"github.com/fcantournet/vault-sync/pkg/utils"
"github.com/fcantournet/vault-sync/pkg/vault"

"github.com/codegangsta/cli"
)

// parseConfigFiles parses the configuration files and extracts the resources
Expand All @@ -41,3 +44,31 @@ func parseConfigFiles(files []string) (*resources, error) {

return r, nil
}

// getVaultClient retrieves a vault client for use
func getVaultClient(cx *cli.Context) (*vault.Client, error) {
host := cx.GlobalString("vault-addr")
username := cx.GlobalString("vault-username")
password := cx.GlobalString("vault-password")
token := cx.GlobalString("vault-token")
creds := cx.GlobalString("credentials")

// step: validate we have the requirements
if creds != "" {
if !utils.IsFile(creds) {
printUsage("the vault credentials file does not exist")
}
} else if token == "" {
if username == "" || password == "" {
return nil, fmt.Errorf("you need to specify a username and password if no token")
}
}

// step: create a vault client
client, err := vault.New(host, username, password, creds, token)
if err != nil {
return nil, err
}

return client, nil
}
31 changes: 30 additions & 1 deletion tests/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@

auths:
- path: token
type: token
attributes:
- uri: roles/applications
allowed_policies: ""
disallowed_policies: "admin"
orphan: true
period: 1h
path_suffix: jan2017
- path: userpass
type: userpass
- path: extra/userpass
Expand All @@ -8,7 +17,27 @@ auths:
type: github
attributes:
- uri: config
organization: UKHomeOffice
organization: Cloudwatt
- path: ldap
type: ldap
attributes:
- uri: config
binddn: "uid=vault,ou=users,dc=infra,dc=cloudwatt,dc=net"
bindpass: "youplaboum"
certificate: ""
deny_null_bind: true
discoverdn: false
groupattr: "cn"
groupdn: "ou=applications,dc=infra,dc=cloudwatt,dc=net"
groupfilter: "(uniqueMember={{.UserDN}})"
insecure_tls: true
starttls: false
tls_max_version: "tls12"
tls_min_version: "tls12"
upndomain: ""
url: "ldaps://ldap.int4.aub.cloudwatt.net:636"
userattr: "uid"
userdn: "ou=users,dc=infra,dc=cloudwatt,dc=net"

users:
- userpass:
Expand Down

0 comments on commit ae07077

Please sign in to comment.