- Lab
- A Cloud Guru
Integrating HashiCorp Vault Authentication to a Website
In this lab, we will need to set up a web application and configure it to use HashiCorp vault for authentication, without storing user credentials to a local database.
Path Info
Table of Contents
-
Challenge
Unseal the Vault and Login with the Root Token
- In the Vault Server, retrieve the vault keys.
- Unseal the vault.
- Log in with the
Initial Root Token
.
-
Challenge
Enable Kv Secrets Engine and Create a Token with a Policy That Allows Access to It
- Enable
kv
secrets engine. - Start
python3.6
. - In the Python Interactive Console, create a hash.
- Copy the hash.
- Write a key-value secret using the email and hash.
- Create a
policy
file namedweb-policy.hcl
, and give itread
permissions. - Write the
policy
. - Create a
token
with the newpolicy
. - Copy the
client_token
- Test out the token.
- Enable
-
Challenge
Install `pip for python3`, the `Django` framework, and Allow the Web Server to Access the App
- Clone the Git repository.
- Install
python3-pip
. - Using
pip3
, install theDjango
framework. - Open the
settings.py
file. - Add the
Web Server
public IP address to theALLOWED_HOSTS
. - Save the file.
- Open the
views.py
file. - In the
get_hashed_vault_creds()
function, change theurl
andhdr
. - Save the file.
- Change to the
HashiCorp-Vault/
directory. - Run the django app.
- Open a web browser, go to 0.0.0.0:8080, and test the login.
What's a lab?
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Provided environment for hands-on practice
We will provide the credentials and environment necessary for you to practice right within your browser.
Guided walkthrough
Follow along with the author’s guided walkthrough and build something new in your provided environment!
Did you know?
On average, you retain 75% more of your learning if you get time for practice.