Sign inSign up

ccavero/keycloak-auth

By ccavero

•Updated about 7 years ago

OAuth2 authentication mediator to manage Keycloak tokens

Image
0

1.1K

ccavero/keycloak-auth repository overview

⁠Keycloak OAuth 2.0 facilitator

OAuth2 authentication mediator to manage Keycloak tokens. It needs a Keycloak instance deployed with a realm, client id and user created. It exposes an API with those operations:

  • [POST] login, with username and password
  • [GET] user, get username

⁠How to deploy

  1. Keycloak setup and configuration

You need a Keycloak instance deployed⁠ to authenticate against. To be able to login in the console, create an admin user with the corresponding password:

docker run -p 8080:8080 -e KEYCLOAK_USER=<adminuser> -e KEYCLOAK_PASSWORD=<password> jboss/keycloak

Browse to http://localhost:8080⁠:

  • Login with <adminuser> and <password>
  • Create a realm for your project (test)
  • Create a client id in the realm (test)
  • Create a valid role
  • Create a user setting the password

Optional It is also possible to import an already created realm (check the Keycloak documentation to export the realm):

docker run -p 8080:8080 -e KEYCLOAK_USER=<username> -e KEYCLOAK_PASSWORD=<password> \
    -e KEYCLOAK_IMPORT=/tmp/example-realm.json -v /tmp/example-realm.json:/tmp/example-realm.json jboss/keycloak
  1. Deploy the container on localhost map port 8081
docker run -p 8081:8081 ccavero/keycloak-auth

Go to your browser and type http://localhost:8081/swagger-ui.html⁠

⁠Environment variables

KEYCLOAK_URL=
KEYCLOAK_REALM=
KEYCLOAK_CLIENT_ID=
docker run -p 8081:8081 --name auth -d -e KEYCLOAK_URL=http://localhost:8080/auth -e KEYCLOAK_REALM=test -e KEYCLOAK_CLIENT_ID=test ccavero/keycloak-auth

Logging can be also configured using LOGGING_FOLDER and sharing a volume (for ELK⁠ processing). The level of the logging can be configured with LOGGING_MODE (dev|prod):

docker run -p 8081:8081 --name auth -d -v /home/docker/log/test:/log/test -e KEYCLOAK_URL=http://localhost:8080/auth -e KEYCLOAK_REALM=test -e KEYCLOAK_CLIENT_ID=test -e LOGGING_FOLDER=/log/test -e LOGGING_MODE=dev ccavero/keycloak-auth

⁠License

By downloading this software, the downloader agrees with the specified terms and conditions of the License Agreement and the particularities of the license provided.

Tag summary

Content type

Image

Digest

Size

86.5 MB

Last updated

about 7 years ago

docker pull ccavero/keycloak-auth