5
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

keycloakのSPI実装

Last updated at Posted at 2019-12-09

この記事について

keycloakのログイン時に独自の認証方式を導入したく、認証SPIの実装方法を調査していました。しかし、どこを見ても公式ドキュメントをコピペしただけの内容しか見つからなかったので、備忘録として手短に残します。
環境
OS: macOS 10.14.6
keycloak: 7.0.1

準備

SPIなどのカスタマイズは全てGithubからダウンロードした、ファイルがJavaで書かれているkeycloakでないとできません。
Githubは開発途中のためgit cloneしたのではほぼ確実にエラー出ます。
releasesからちゃんとテストをパスできたバージョンをダウンロードしましょう。

Let's try!

認証SPIの実装
examplesフォルダに既に完璧に実装されているカスタマイズが入っているので、それを使ってSPIの実装を紹介します。

JARファイルの生成
examples/providers/authenticatorに秘密の質問を使った認証SPIが入っています。
ターミナルからここのフォルダでmvn clean installしてJARファイルにパッケージングします。
examples/providers/authenticator/targetauthenticator-required-action-example.jarauthenticator-required-action-example-sources.jarというふたつのJARファイルが生成されます。

keycloakダウンロード
別に$KEYCLOAK_HOMEmvn installしてdistributionにkeycloak自体のSNAPSHOTを作ってもいいですが、より確実にkeycloak公式ダウンロードページからGithubで選んだものと同じバージョンをダウンロードします。

実装
公式版KEYCLOAK_HOMEにprovidersというフォルダを作ります。
先ほど生成したJARファイルを二つともここにコピーして、./bin/standalone.shで起動すれば完了です。

thumb_3-rules-no-wishing-for-death-no-falling-in-love-65758373.png

5
3
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
5
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?