0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Keycloak紹介

Posted at

Keycloakとは

  • KeycloakはWebアプリケーションおよびRESTfulなWebサービスのためのシングル・サインオン・ソリューションです。​
  • Keycloakの目的はセキュリティーをシンプルに実現し、アプリケーション開発者が組織内にデプロイしたアプリケーションやサービスを保護することです。​
  • ログイン、登録、システム管理、アカウント管理のための、カスタマイズ可能なユーザー・インターフェイスを提供しています

機能

  • ブラウザー・アプリケーションに対するシングル・サインオンとシングル・サインアウト。​
  • OpenID Connectのサポート。 OAuth 2.0のサポート。 SAMLのサポート。​
  • ユーザー、ロール、ロール・マッピング、クライアントと設定を一元管理するための管理コンソール。​
  • ユーザーに自分達のアカウントを一元管理することを許可するためのアカウント管理コンソール。

関連情報

基本概念

レルム

  • Masterレルム​
    • 管理用、開発用
    • Masterレルムがシステム初期化の時に作成される ​
  • そのほかのレルム​
    • Masterレルムの中に作成されているadminユーザで、そのほかのレルムを作成する​
    • アプリケーション用のクライアントは、そのほかのレルムにしか作成されない​
    • ユーザ、グループを追加する​
レルム間の関係

{B287D565-4F3A-41A4-B613-B5330F62374B}.png

Relying Party(RP)対応

オンプレ

ツール
nginx設定
    init_by_lua_block {​
        require "resty.session".init({​
            remember = true,​
            store_metadata = true,​
            secret = "",​
            secret_fallbacks = {​
                "",​
                "",​
            },​
            storage = "redis",​
            redis = {​
                host = "redis",​
                port = "6379",​
                prefix = "sessions",​
            },​
        })​
    }​
    server {​
        listen       80;​

        location / {​
                set $pass '';​
                access_by_lua_file /usr/local/openresty/main.lua;​
                proxy_pass $pass;​
        }
RP実装 main.lua
local opts = {​
    ssl_verify = "no",​
    redirect_uri = "http://localhost/cb",​
    discovery = "http://../.well-known/openid-configuration",​
    cient_id = "",​
    client_secret = ""​
}​

local res, err, a, session = require("resty.openidc").authenticate(opts)​
local jwt = require "resty.jwt"​
local jwt_token = jwt:sign(​
    "secret_key_",​
    {​
        header={typ="JWT", alg="HS256"},​
        payload=res.user​
    }​
)​

ngx.req.set_header("X-RICOH-OIDC-TOKEN", jwt_token)​
ngx.var.pass="http://fastapi:3000/"

AWS ALB

  • Application Load Balancer が OIDC を使用してユーザーの認証フロー
  • {E0ED3526-A969-4D71-BEDE-0DE7E5AAD2D7}.png

まとめ

  • keycloakは、優秀なID管理やアクセス管理(IAM:Identity and Access Management)を実現するオープンソースソフトウェア(OSS)​
  • レルムの概念の理解​
  • Lua言語でRPを実装してみた
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?