omniauth + omniauth-gitlab

rubyのWebアプリケーション用ミドルウェアRackで動作する認証ライブラリのomniauthでGitLabを認証プロバイダとして使用するためのメモ。

GitLabをOAuth2認証プロバイダとして使用するためのomniauth用strategyとして,omniauth-gitlabがある。

オンプレミスでGitLabサーバを立ち上げている場合は,Standalone Usageのように設定する。

use OmniAuth::Builder do
    provider :gitlab, "***your_gitlab_key***", "***your_gitlab_secret***",
    {
        client_options: {
            site: "https://gitlab.example.com/",
        }
    }
end

ここまでは,素直にできたのだけど,OAuth2の認証後,callbackされるURLをデフォルトから変更したい場合(リバースproxyの後ろで動いているアプリなど),どうすればいいのか?

omniauth-gitlabでは,独自に用意されているオプション redirect_url があるようなので,

use OmniAuth::Builder do
    provider :gitlab, "***your_gitlab_key***", "***your_gitlab_secret***",
    {
        redirect_url: "https://yourapp.example.com/custom/callback",
        client_options: {
            site: "https://gitlab.example.com/",
        }
    }
end

とするのがよさそう。

コメント

このブログの人気の投稿

MSFS2020 G1000でのVORの使い方 (C172)

Linuxでの省電力設定

Word 2016の不具合