Giter VIP home page Giter VIP logo

keycloak's Introduction

User Authentication Authorization Service

Keycloak setup instructions

Starts the Keycloak server in the background and exposes the server on port 9191 on the host machine;

docker run -p 9191:8080 -e KEYCLOAK_USER=admin -e KEYCLOAK_PASSWORD=admin quay.io/keycloak/keycloak:10.0.2

Go to the Keycloak Admin Console and login with the username and password you created earlier (admin/admin).

To verify that Keycloak container is running execute docker ps. The container status should be UP:

The following script configures a new realm, users and clients in Keycloak (see realm-configuration.json file):

Note
Set directAccessGrantsEnabled to true gives the client direct access to the user credentials and enables it to exchange them for access token. This is the equivalent of OAuth2 Password Grant flow
Note
Set serviceAccountsEnabled to true allows the client use direct credentials and enables it to exchange them for access token. This is the equivalent of OAuth2 Client Credentials flow
sh realm-configuration.sh

cURL OAuth2 endpoints test

Grant Type: client_credentials

curl -s -X POST -u "app-android:app-android123" -d "grant_type=client_credentials" localhost:9191/auth/realms/my-realm/protocol/openid-connect/token

Grant Type: password

curl -s -X POST 'localhost:9191/auth/realms/my-realm/protocol/openid-connect/token' \
 --header 'Content-Type: application/x-www-form-urlencoded' \
 --data-urlencode 'grant_type=password' \
 --data-urlencode 'client_id=app-android' \
 --data-urlencode 'client_secret=app-android123' \
 --data-urlencode 'username=jane-doe' \
 --data-urlencode 'password=jane-doe123'

…​and let’s decode the access_token JWT token issued for jane-doe using https://jwt.io.

All endpoins for testing purposes are available in postman 2.1 collection format

keycloak.postman_collection.json file, just download Postman and import the collection file

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.