A home-grown JWT token provider built on Gin. This project is highly experimental, and is not currently intended for anything more than a PoC and learning exercise.
There are several required and optional variables that can be passed to a running container to configure it.
These are secrets used to sign/verify all access/refresh tokens. Both are required.
If you need to generate a new one, here's a quick command:
openssl rand -hex 64
Be sure to make a unique one for each secret.
Defaults to INFO
. Options include TRACE
, DEBUG
, INFO
, WARN
, and FATAL
.
Sets how long an individual access token should be valid. For available duration formats, please see here. Defaults to 15s
(which is admittedly very short).
Sets how long a refresh token should be valid. For available duration formats, please see here. Defaults to 1m
(which is admittedly very short).
The label given to all tokens for the iss
field. Defaults to markliederbach/auth-service
.
The recommended way to run this server is via Docker.
Once you have these environment variables set up (for example, in a .env
file somewhere), you can run the following command to serve the application.
docker run --env-file .env -it -p 8080:8080/tcp --rm markliederbach/auth-server:latest
Of course, you can replace the host port with whatever you like with -p 8080:<other port>/tcp
.
The following must be installed for all other setup to work more easily.
After clonging the repo, simply run task deps
. This will install pre-commit
, goreleaser
, and other development dependencies. Additionally, it will bootstrap the needed commit hooks.
At any point, you can run the following to format your Go code, so the commit hooks and CI will pass.
task fmt
task lint
There are currently no tests, as this is still in a PoC phase. However, the command to run tests exists as:
task test
To build artifacts for supported platforms, you can run the following:
task build
This will create the executables under dist/
.
The repo is also configured to build on push to the default branch, and upload artifacts for download.
This project has an automated release process through Github Actions with the help of GoReleaser. When you are ready to create a new tagged release, do the following.
# Update `v0.1.0` to whatever the new version will be
git tag -a v0.1.0 -m "My new version" && git push --tags
This will kickstart the Github Action for releases. This workflow builds the binary for various architectures/platforms, zips the archives, and uploads to a new draft release based on the tag.
Once you are satisfied with the release, and have added additional context to its description, you can publish the release.