よく知られたOpenID Connect プロバイダーの設定
This document explains how to configure well-known social OIDC and OAuth2 providers.
はじめに
If you use OpenID Connect Authorization Code Flow to protect Quarkus endpoints, then you need to configure Quarkus to tell it how to connect to OpenID Connect providers, how to authenticate to such providers, which scopes to use, and so on.
Sometimes you need to use the configuration to work around the fact that some providers do not implement OpenID Connect completely or when they are in fact OAuth2 providers only.
このようなプロバイダーの設定は、複雑で非常に技術的になり、理解が困難になる可能性があります。
よく知られた OpenID Connect および OAuth2 プロバイダーを参照するために、quarkus.oidc.provider
設定プロパティーが導入されました。このプロパティーを使用して、最小限のカスタマイズのみが必要な github
などのプロバイダーを参照することができます。通常、アカウント固有の client id
、client secret
およびいくつかのプロパティーを設定して設定を完了する必要があります。
このプロパティーは、application.properties
、複数のプロバイダーを設定する必要がある場合は マルチテナント セットアップ (たとえば、 Quarkus Renarde security documentation ) を参照)、テナント設定が動的に作成される場合はカスタムの TenantConfigResolvers で使用することができます。
よく知られたプロバイダー
GitHub
GitHub の OIDC を設定するには、 GitHub developer settings で新しい OAuth アプリケーションを作成する必要があります。

詳細を適切に入力する必要がありますが、さらに重要なのは、Authorization Callback URL を http://localhost:8080/_renarde/security/github-success
に設定することです (Quarkus DEV モードを使用してテストする場合)。
次に、Register application
をクリックすると、アプリケーションページが表示されます。

Generate a new client secret
をクリックし、クレデンシャルを確認して、Client ID と Client Secret を書き留める必要があります (特に Client Secret は、後でこのページで再度見ることができないため、書き留めてください。ただし、いつでも再作成できますので、心配しすぎる必要はありません)。

次に、以下の設定を application.properties
に追加します。
quarkus.oidc.provider=github
quarkus.oidc.client-id=<Client ID>
quarkus.oidc.credentials.secret=<Secret>
quarkus.oidc.provider=github
will request GitHub
to add a user:email
scope to issued access tokens. For information about overriding this scope or requesting more scopes, see the Provider scopes section.
You can also send access tokens issued by GitHub to quarkus.oidc.application-type=service or quarkus.oidc.application-type=hybrid Quarkus applications.
|
OIDC for Google を設定するには、 Google Cloud Platform console で新しいプロジェクトを作成する必要があります。
プロジェクト名を選択し、CREATE
をクリックします。

次に、トップセレクターでプロジェクトを選択し、左側のメニューバーから APIs and Services > OAuth consent screen
をクリックします。

External
を選択して、Google ユーザーがアプリケーションにログインすることを許可し、CREATE
を押します。

これで、アプリケーション名、サポートメール、開発者の連絡先情報を入力して、SAVE AND CONTINUE
を押すことができます。

次のページにスコープを追加せずに、SAVE AND CONTINUE
を押します。

次のページにテストユーザーを追加せずに、SAVE AND CONTINUE
を押します。

トップメニューの CREATE CREDENTIALS
> OAuth client ID
をクリックします。

Application type
として Web application
を選択し、Authorised redirect URIs
リストに http://localhost:8080/_renarde/security/oidc-success
を追加して、CREATE
を押します。

Client ID と Client Secret をコピーします。

これで、application.properties
を設定できます。
quarkus.oidc.provider=google
quarkus.oidc.client-id=<Client ID>
quarkus.oidc.credentials.secret=<Secret>
quarkus.oidc.provider=google
will request Google
to add openid
, email
and profile
scopes to issued access tokens. For information about overriding these scopes or requesting more scopes, see the Provider scopes section.
You can also send access tokens issued by Google to quarkus.oidc.application-type=service or quarkus.oidc.application-type=hybrid Quarkus applications.
|
Microsoft
Microsoft 用の OIDC をセットアップするには、 Microsoft Azure Portal にアクセスし、Azure Active Directory
を検索してクリックする必要があります。

そこで、左側の Manage
の下にある App registrations
をクリックしてから、New registration
をクリックします。

アプリケーション名を入力し、Accounts in any organizational directory (Any Azure AD directory - Multitenant) and personal Microsoft accounts (e.g. Skype, Xbox)
を選択して誰でもログインできるようにし、 Web
Redirect URI を http://localhost:8080/_renarde/security/oidc-success
として追加してから Register
をクリックします。

その結果のページで、Client Id
(Application (client) ID
の下) をコピーしてから、Add a certificate or secret
をクリックします。

次に、Client secrets (0)
の下にある New client secret
をクリックします。

何も変更せずに、そのダイアログで Add
をクリックします。

結果のページで、Secret ID
をコピーします。

これで、application.properties
を設定できます。
quarkus.oidc.provider=microsoft
quarkus.oidc.client-id=<Client ID>
quarkus.oidc.credentials.secret=<Secret>
quarkus.oidc.provider=microsoft
will request Microsoft
to add openid
, email
and profile
scopes to issued access tokens. For information about overriding these scopes or requesting more scopes, see the Provider scopes section.
You can also send access tokens issued by Microsoft to quarkus.oidc.application-type=service or quarkus.oidc.application-type=hybrid Quarkus applications but you may need to set quarkus.oidc.verify-access-token-with-user-info configuration property to true if access tokens issued by Microsoft are not in JWT format.
|
Some Microsoft services may issue tokens whose signatures can only be verified if the current token’s
|
Apple
Apple 用の OIDC を設定するには、開発者アカウントを作成し、99 ユーロ/年のプログラムにサインアップする必要がありますが、他のほとんどの OIDC プロバイダーのように localhost
でアプリケーションをテストすることはできません。https
で実行して公開する必要があるため、開発目的では https://ngrok.com などのサービスを使用することをお勧めします。
Create a new identifier にアクセスして +
を押します

何も触れないで、App IDs
を選択したまま Continue
を押します。

何も触れないで、App
を選択したまま Continue
を押します。

説明とバンドル ID を入力します (アプリケーションパッケージ名を使用します)。

次に、下にスクロールして Sign in with Apple
機能を見つけ、それを選択して、Continue
を押します。

アプリ ID 接頭辞を書き留めてから、Register
を押します。

Identifiers
ページに戻り、 +
を押します。

Service IDs
を選択し、Continue
を押します。

説明とバンドル ID を入力 (アプリケーションパッケージ名を使用) し、Continue
を押します。

次に、Register
を押します。

サービスリストに戻り、新しく作成したサービスをクリックします。

Sign in with Apple
を有効にして、Configure
を押します。

ドメインを追加して URL (<host>/_renarde/security/oidc-success
に設定) を返し、Next
を押します。

次に Done
を押します。

続いて Continue
を押します。

そして、Save
を押します。

左側のメニューの Keys ページに移動し、+
を押します。

キー名を入力し、Sign in with Apple
を有効にして、Configure
を押します。

Primary App ID を選択し、Save
を押します。

キーページに戻り、Continue
を押します。

次に、Register
を押します。

Key ID
を書き留めてキーをダウンロードし、src/main/resources/AuthKey_<KEYID>.p8
の Quarkus アプリケーションに保存します。

これで、application.properties
を設定できます。
quarkus.oidc.provider=apple
quarkus.oidc.client-id=<Bundle ID>
quarkus.oidc.credentials.jwt.key-file=AuthKey_<Key ID>.p8
quarkus.oidc.credentials.jwt.token-key-id=<Key ID>
quarkus.oidc.credentials.jwt.issuer=<App ID Prefix>
quarkus.oidc.credentials.jwt.subject=<Bundle ID}
quarkus.oidc.provider=apple
will request Apple
to add openid
, email
and name
scopes to issued access tokens. For information about overriding these scopes or requesting more scopes, see the Provider scopes section.
Facebook では、他のほとんどの OIDC プロバイダーのように localhost
でアプリケーションをテストすることはできません。https
で実行して公開する必要があるため、開発目的では https://ngrok.com などのサービスを使用することをお勧めします。
Facebook 用の OIDC を設定するには、 Creating an application から開始し、アプリのタイプとして None
を選択して Next
を押します。

次に、アプリケーション名と連絡先のメールアドレスを入力し、Create app
を押します。

アプリページで、Facebook login
製品の Set up
をクリックします。

Quickstarts
ページをクイックし、左側のメニューの Facebook login > Settings
をクリックします。

Redirect URIs
を入力 (<host>/_renarde/security/oidc-success
に設定) し、Save changes
を押します:

次に、左側のメニューの Settings > Basic
に移動し、App ID
と App secret
を書き留めます。

これで、application.properties
を設定できます。
quarkus.oidc.provider=facebook
quarkus.oidc.client-id=<App ID>
quarkus.oidc.credentials.secret=<App secret>
quarkus.oidc.provider=facebook
will request Facebook
to add email
and public_profile
scopes to issued access tokens. For information about overriding these scopes or requesting more scopes, see the Provider scopes section.
OIDC ログインには Twitter を使用できますが、現時点では、ユーザーのメールへのアクセスが制限されているため、ご自身で Twitter を取得して確認する必要があります。
Twitter 用の OIDC を設定するには、 Creating a project で開始し、プロジェクト名を入力して、Next
を押します。

ユースケースを入力し、Next
を押します。

プロジェクトの説明を入力し、Next
を押します。

次に、アプリケーション名を入力して、Next
を押します。

キーは再び表示されないので書き留めて、App Settings
を押します。

User authentication settings
セクションに移動し、Set up
を押します。

OAuth 2.0
チェックボックスをオンにします。

アプリケーションタイプとして Web App
を選択し、アプリケーションの詳細を入力します (Callback URI
の場合は <host>/_renarde/security/twitter-success
を使用)。
Twitter は実際には https を使用する必要はありませんが、https がないと Website URL を受け入れないため、ngrok を引き続き使用できます。
|
次に、Save
を押します。

これで、Client ID
および Client Secret
をコピーして Done
を押すことができます。

これで、application.properties
を設定できます。
quarkus.oidc.provider=twitter
quarkus.oidc.client-id=<Client ID>
quarkus.oidc.credentials.secret=<Client Secret>
quarkus.oidc.provider=twitter
will request Twitter
to add offline.access
, tweet.read
and users.read
scopes to issued access tokens. For information about overriding these scopes or requesting more scopes, see the Provider scopes section.
Twitter provider requires Proof Key for Code Exchange (PKCE) which is supported by the You can provide your own secret key for encrypting the PKCE code verifier if you prefer with the |
|
X
X
is a new name for Twitter
. You can currently use either quarkus.oidc.provider=x
or quarkus.oidc.provider=twitter
but only quarkus.oidc.provider=x
may end up supported in the future.
Please see Twitter for more information about registering your Quarkus application in X
(Twitter
).
Spotify
Spotify application を作成します。

開発目的のテスト用に、リダイレクト URI として http://localhost:8080
を追加することを忘れないでください。Spotify アプリケーションのセットアップが完了すると、クライアント ID とシークレットが生成されます。以下に例を示します。

これで、application.properties
を設定できます。
quarkus.oidc.provider=spotify
quarkus.oidc.client-id=<Client ID>
quarkus.oidc.credentials.secret=<Client Secret>
quarkus.oidc.provider=spotiify
will request Spotify
to add user-read-private
and user-read-email
scopes to issued access tokens. For information about overriding these scopes or requesting more scopes, see the Provider scopes section.
Twitch
Create a Twitch application:

これで、application.properties
を設定できます。
quarkus.oidc.provider=twitch
quarkus.oidc.client-id=<Client ID>
quarkus.oidc.credentials.client-secret.value=<Client Secret>
Provider scopes
Each provider declaration will request one or more token scopes added to access tokens issued by a given provider. For example, quarkus.oidc.provider=google
will request Google
to add openid
, email
and profile
scopes.
You can override these scopes with quarkus.oidc.authentication.scopes
property, for example, if you work with Google
and would not like to have an email
scope added to access tokens:
quarkus.oidc.provider=google
quarkus.oidc.authentication.scopes=oidc,profile
You may also want to add one or more scopes in addition to the scopes requested by default. For example, if you would like to use an access token issued by Google
to access Google Calendar
service, you can do it like this:
quarkus.oidc.provider=google
quarkus.oidc.authentication.extra-params.scope=https://www.googleapis.com/auth/calendar
It is simpler than using quarkus.oidc.authentication.scopes
to add a new scope, because quarkus.oidc.authentication.scopes
overrides the scopes already set by the provider declaration, which is why you need to list all the required scopes in this case:
quarkus.oidc.provider=google
quarkus.oidc.authentication.scopes=oidc,email,profile,https://www.googleapis.com/auth/calendar
Support for multiple providers
If you would like to support authenticating users with more than one provider then a provider-specific tenant configuration resolution must be supported.
For more information, see the Quarkus Using OpenID Connect (OIDC) Multi-Tenancy guide.
Access provider services with token propagation
Sometimes, only authenticating users with a social provider is not enough. A provider-specific service also needs to be accessed for the Quarkus OIDC web-app
application to fetch or update data from the provider service on behalf of the currently authenticated user.
As mentioned in the OIDC code flow mechanism for protecting web applications guide, ID and access tokens are returned after the authorization code flow has been completed, with some providers like GitHub
returning an access token only. It is this access token that has to be propagated to services such as Google Calendar
, or Spotify Playlists
for the currently authenticated user to be able to use such services.
You do not have to bring provider-specific libraries in order to achieve this, but instead you can use a reactive Token Propagation
filter, which can be bound to a given REST client with a simple annotation. For more information, see the Quarkus Access token propagation guide.
For example, after you have configured the Google provider, you can have events added to the user’s Google Calendar by using a REST client as shown in the following example:
package org.acme.calendar;
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;
import io.quarkus.oidc.token.propagation.AccessToken;
import io.smallrye.mutiny.Uni;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
@RegisterRestClient(configKey="google-calendar-api")
@AccessToken (1)
@Path("/calendars/primary")
public interface GoogleCalendarClient {
@POST
@Path("events")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
Uni<String> addEvent(Event event);
public static class Event {
public String summary;
public String kind = "calendar#event";
public Time start;
public Time end
}
public static class Time {
public String dateTime;
public String timeZone = "Europe/CET";
public Time() {
}
public Time(String value) {
dateTime = value;
}
}
}
1 | The @AccessToken annotation enables an access token propagation to the target service. |
Finally, you need to configure the Google Calendar address and request the Google Calendar scope for an access token, as outlined in the following example:
quarkus.oidc.authentication.extra-params.scope=https://www.googleapis.com/auth/calendar
quarkus.rest-client.google-calendar-api.url=https://www.googleapis.com/calendar/v3
HTTPS Redirect URL
Some providers will only accept HTTPS-based redirect URLs. Tools such as ngrok can be set up to help testing such providers with Quarkus endpoints running on localhost in devmode.