Skip to content

Keycloak

Interactive Diagram

새 탭 ↗
  • Keycloak is an open-source identity and access management solution targeting modern applications and services. It makes it easy to secure applications and services with little to no code.
  • Keycloak’s default authentication method is OIDC based on OAuth 2.0
  • It is a solution optimized for Kubernetes and MSA environments.
  • Keycloak Core Concepts

Keycloak Core Concepts

(Source: https://developers.redhat.com/blog/2019/12/11/keycloak-core-concepts-of-open-source-identity-and-access-management)

  • Provided as open source, and the community version can be used without additional cost
  • User Registration
  • Social login
  • Single Sign-On/Sign-Off across all applications
  • belonging to the same Realm
  • 2-factor authentication
  • LDAP integration
  • Kerberos broker
  • multitenancy with per-realm customizable skin
  • Realm
    • A unit representing the scope in which authentication and authorization operate. Taking SSO (Single Sign-On) as an example, if certain clients share SSO, that scope is limited to the Realm that those clients commonly belong to. By default, a Realm called Master, which cannot be deleted, is provided.
  • Client
    • A unit representing an application that delegates authentication and authorization actions to JBoss Keycloak. It can be a website or a service that provides a REST API. One Realm can create and manage n Clients that belong to it.
  • User
    • A unit representing the actual user who will log in to each Client. One Realm can create and manage n Users that belong to it. By default, a User entity can have 4 items: Username, Email, First Name, and Last Name, and you can freely add custom items through the Custom User Attributes feature.
  • OIDC (OpenID Connect)
    • Based on the OAuth 2.0 protocol, it handles authentication simply at a higher layer and can provide user information in a more secure way through an identity verification service (IDP).
  • Install Keycloak, Grafana
  • Add a realm and client to Keycloak
  • Configure Keycloak
  • Redeploy after integration configuration
  • Verify Keycloak + Grafana integration
  • Keycloak with k8s Apps

Keycloak with k8s Apps

(Source: https://www.openshift.com/blog/adding-authentication-to-your-kubernetes-web-applications-with-keycloak)

  • Clone the Keycloak, Grafana installation and integration shell file and yaml file to your local PC
    • The repository is private due to the AWS settings in the yaml files
    • A separate request is needed to be invited as a team member to that repository
Terminal window
git clone https://github.com/Salteed/dp2_keycloak
  • Run 01_install.sh
    • Enter the following information
      • Namespace to install Keycloak in
      • Keycloak administrator account
      • Keycloak administrator password
      • Namespace to install Grafana in
    • Verify the Keycloak and Grafana endpoints
Terminal window
sh 01_install.sh
  • Run 02_keycloak_setting.sh
    • Enter the following information
      • Name of the realm to add to Keycloak
      • Client ID to add to the realm
Terminal window
sh 02_keycloak_setting.sh
  • After connecting to Keycloak, click Administration Console
  • Log in with the Keycloak administrator account
  • Click the Clients menu on the left -> click the Client ID
  • Change Access Type from public -> confidential and save
  • Click the Credentials tab and copy the Secret key
  • Click the Users menu on the left and click Add user
  • Enter Username and Email and save
  • Click the Credentials tab, enter the Password, and click Set Password
  • Click the Clients menu on the left and click the Client ID
  • Click the Roles tab and click Add Role
  • Enter the Role Name and save
  • Click the Roles menu on the left and click default-roles-{realm name}
    • ex) default-roles-realm-50
  • Click Client Roles and select the client you created
    • ex) client-50
  • Click the created Role and click Add selected
  • Modify the keycloak secret value in the 04_connect_authorization.sh file
    • ex) i_keycloak_secret
  • Check the script
  • Run 04_connect_authorization.sh
Terminal window
sh 04_connect_authorization.sh
  • Connect to Grafana
  • Click Sign in with Login Keycloak
  • Enter Username and Password
  • Verify the login