Giter Site home page Giter Site logo

gites / vault-auth-file Goto Github PK

View Code? Open in Web Editor NEW
6.0 1.0 4.0 38 KB

HashiCorp Vault authentication plugin for authenticating via Unix password like file

License: Apache License 2.0

Go 86.33% Shell 13.67%
vault auth plugin vault-plugins file password

vault-auth-file's Introduction

Go Report Card Build Status codecov

Vault Auth File

HashiCorp Vault authentication plugin for authenticating via Unix password like file.

Authentication workflow

  1. User name and password are sent to Vault.
  2. Vault calculate password hash and compare it to hash stored in password file.
  3. If succesfull, policies listed in password file are applayed to user.
  4. Valid token is returned to user.

Instalation

  1. Set plugin_directory variable in Vault config.
    plugin_directory="/opt/vault/plugins"
  2. Copy vault-auth-file binary to plugin_directory.
  3. Enable plugin in Vault.
    SHA_256SUM=`sha256sum /opt/vault/plugins/vault-auth-file/vault-auth-file|cut -d' ' -f1`
    vault write sys/plugins/catalog/vault-auth-file sha_256=$SHA_256SUM command=vault-auth-file
    vault auth-enable -path=file -plugin-name vault-auth-file plugin

Configuration

Configuration endpoint is located at auth/file/config. Configuration options:

  • path (mandatory) - path to password file (example: /opt/vault/etc/password-file)
  • ttl (optional) - token TTL (example: 1h)
  • max_ttl (optional) - max token TTL (example: 2h)

Example:

vault write auth/file/config path=/opt/vault/etc/password-file ttl=1h max_ttl=2h

Password file format

Password file format is similar to Unix/Linux password file:

username:password_hash:coma,separated,policy,list

For now only SHA-512 hashes are supported.

Example:

wac:$6$.R4zGSdU$UQbNz4pV/AuDxD0Su6qfeVRaKz6gsq3w7zD8ywhFFpF7vbtiBxEFq49SbNI8kNGPmZyMzJIelUFvf12tUknjE0:ops,dev
wacek:$6$AwBd/60MqRG8M1V2$mXPJ39lAs26otEjY4YvObn7lEN2UeZgsEE6ueeN0zWS96QBJQuJLUhLmf1LuvCk7.MYpNik7tl5CEdqr.3Is80:ops,dev,netops
zenek:$6$jG6ZxCOkrXI$r4za9aGwb/VVw3nB3vRyvO2njCzgyKKCPxMn.GOYkW0/WaEMQENpbEufrX6CAQqlsIDr0x9DUsAhIS8bL3OGf1:ops,dev,netops
gites:$6$spfjUPN4$6ap3h.6Fac23HO/CFTZpQYdwvZ8zFflZkCQMWVO.13pCFEOjw8sjVljiIU6SgAhRDwwUBK1DYvHmBdoz/3wef0:ops
gites2:$6$EBzUEPlL$sLnPV5wKqvWloHNf7rfaO2bG1wxGl7zda6Jy/qU3ChLuIlK2EujMIaIdJfHhwbCst60IHqkFAiZXMVhFTQx3b1:ops

Login

Login endpoint is located at auth/file/login. Login options:

  • username (mandatory) - username to login
  • password (mandatory) - password for that user

Example:

vault write auth/file/login username=wac password=lubieplacki      
Key                     Value                         
---                     -----                         
token                   ffff3192-87cf-c3c9-e3af-1a3373fb6017                                                 
token_accessor          9689189d-548c-3c06-6c81-fb621f9e404c                                                 
token_duration          1h0m0s                        
token_renewable         true                          
token_policies          [default dev ops]             
token_meta_username     "wac"                         
token_meta_woop         "woop.sh" 

Also auth/file/login/<username> endpoint can be used. This make vault-auth-file plugin compatible with Vault client binary and userpass auth method.

Example:

vault write auth/file/login/wac username=wac password=lubieplacki 
Key                    Value                        
---                    -----                        
token                  1c24c452-5599-f308-1f2b-4dc3f1621584                                              
token_accessor         c7a57130-90a7-7bbc-279d-b984053b7ee3                                              
token_duration         768h                         
token_renewable        true                         
token_policies         [default dev ops]            
token_meta_username    wac                          
token_meta_woop        woop.sh                      

Example using userpass auth method:

vault login -method=userpass -path=file username=wac 
Password (will be hidden):
Success! You are now authenticated. The token information displayed below
is already stored in the token helper. You do NOT need to run "vault login"
again. Future Vault requests will automatically use this token.

Key                    Value
---                    -----
token                  08c7483b-3f8f-37fe-c648-2f6d019d0742
token_accessor         9af3c49e-5ac2-f062-4e17-6c0058a2cc20
token_duration         768h
token_renewable        true
token_policies         [default dev ops]
token_meta_username    wac
token_meta_woop        woop.sh

vault-auth-file's People

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

vault-auth-file's Issues

bad http error codes when unable to auth user

Error writing data to auth/file/login: Error making API request.   

URL: PUT http://127.0.0.1:8200/v1/auth/file/login                  
Code: 500. Errors:               

* unexpected EOF
# ./vault write -format=json auth/file/login username=wac password=nielubueplackow                                                    
Error writing data to auth/file/login: Error making API request.   

URL: PUT http://127.0.0.1:8200/v1/auth/file/login                  
Code: 400. Errors:               

* Couldn't authenticate client  

In both cases 401 should be returned instead of 400 and 500

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.