The IDVA Token microservice is a Python Flask application that exposes an API for generating and validating simple tokens.
Tokens are at default valid for 7 days and have 1 use. Time and uses can be adjusted when registering a token.
Make sure you have the following installed if you intend to build the project locally.
To set up your environment, run the following commands (or the equivalent commands if not using a bash-like terminal):
# Clone the project
git clone https://github.com/GSA-TTS/identity-idva-token-service
cd identity-idva-token-service
# Set up Python virtual environment
python3.11 -m venv .venv
source .venv/bin/activate
# .venv\Scripts\Activate.ps1 on Windows
# Install dependencies and pre-commit hooks
python -m pip install -r requirements-dev.txt
pre-commit install
Install PostgreSQL.
Set up a local database:
psql
create database idva_token;
# \q
To set a custom secret key, use the following environment variable: SECRET_KEYS
.
The project can be ran locally with:
python manage.py run
After completing development setup application locally with:
python -m pytest
python manage.py test
Headers
X-API-Key: <api-key>
Create a new token.
POST /auth
Request body:
{
"seconds": int, //OPTIONAL
"uses": int //OPTIONAL
}
Validates a token without changing its properties.
GET /auth/<token>
Invokes a token, decrementing its uses by 1.
POST /auth/<token>/decrement
Exhausts a token rendering it useless.
DELETE /auth/<token>
Export Qualtrics Survey response on a public endpoint.
POST /export/survey-response
Request body:
{
"surveyId": str
"responseId": str
"participant": {
"first": str
"last": str
"email": str
"time": str
}
}
All deployments require having the correct Cloud.gov credentials in place. If you haven't already, visit Cloud.gov and set up your account and CLI.
manifest.yml file contains the deployment configuration for cloud.gov, and expects a vars.yaml file that includes runtime variables referenced. For info, see cloud foundry manifest files reference
Running the following cf
command will deploy the application to cloud.gov
cf push --vars-file vars.yaml \
--var ENVIRONMENT=<env>
This project is in the worldwide public domain. As stated in CONTRIBUTING:
This project is in the public domain within the United States, and copyright and related rights in the work worldwide are waived through the CC0 1.0 Universal public domain dedication.
All contributions to this project will be released under the CC0 dedication. By submitting a pull request, you are agreeing to comply with this waiver of copyright interest.