Joplin Server
Joplin はオープンソースのノート作成アプリであり、Joplin Server はそのセルフホスト型の同期サーバーです。バージョン 3.4.1 以降、Joplin Server は SAML 2.0 アイデンティティプロバイダー (IdP) を通じてユーザーをサインインさせることができます。Casdoor を IdP として使用することで、ユーザーは Casdoor アカウントで Joplin Server およびそれと同期する Joplin アプリにサインインできます。
Joplin Server は samlify と xml-crypto を使用して SAML レスポンスを検証します。xml-crypto は Casdoor がデフォルトで署名に使用する XML カノニカライゼーション 1.1 をサポートしていないため、Casdoor のアプリケーションでは Enable SAML C14N10 をオンにする必要があります。最新の Casdoor バージョンを使用してください。古いバージョンでは、Joplin Server が拒否する形式(FAILED_TO_VERIFY_SIGNATURE または XML スキーマエラー)でレスポンスに署名します。
例では、Joplin Server 用に https://joplin.example.com、Casdoor 用に https://door.example.com を使用しています。
Casdoor でアプリケーションを作成する
-
Casdoor 管理コンソールで、ユーザーの組織を開き、アプリケーションを追加するか、既存のアプリケーションを開きます。
-
Joplin Server のエンティティ ID と Assertion Consumer Service (ACS) URL を Redirect URLs に追加します。エンティティ ID は、後述で作成するサービスプロバイダー (SP) ファイル内の
entityID(例ではJoplin)です。ACS URL は<APP_BASE_URL>/api/samlです:Joplin
https://joplin.example.com/api/saml -
SAML タブで:
-
Enable SAML C14N10 をオンにし、SAML C14N10 prefix は空のままにします。
-
Enable SAML POST binding をオンにします。Joplin Server は HTTP-POST バインディングで Casdoor にリクエストを送信するため、メタデータには Casdoor の HTTP-POST エンドポイントが記載されている必要があります。
-
SAML attributes に 2 行を追加します。Joplin Server はこれらの 2 つの属性のみを読み取り、大文字小文字は区別されます。Casdoor がデフォルトで送信する
EmailおよびDisplayName属性は対象外です。Name Name format Value emailBasic $user.emaildisplayNameBasic $user.displayNameすべてのユーザーは Casdoor にメールアドレスを持つ必要があります。Joplin Server はこれを使用してユーザーを識別します。
-
-
保存し、Copy SAML metadata URL をクリックします。Enable SAML POST binding がオンの場合、URL は
enablePostBinding=trueで終わります:https://door.example.com/api/saml/metadata?application=admin/<application-name>&enablePostBinding=true -
URL を開き、XML を
idp.xmlとして保存します。Joplin Server は IdP メタデータをファイルから読み込み、URL からは読み込みません。
Joplin Server の準備
-
SP ファイル
sp.xmlを作成します。entityIDに Redirect URLs に追加したエンティティ ID を、Locationに ACS URL を設定します:<?xml version="1.0"?>
<md:EntityDescriptor xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata" entityID="Joplin">
<md:SPSSODescriptor AuthnRequestsSigned="false" WantAssertionsSigned="false" protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol">
<md:NameIDFormat>urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress</md:NameIDFormat>
<md:AssertionConsumerService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" Location="https://joplin.example.com/api/saml" index="1" />
</md:SPSSODescriptor>
</md:EntityDescriptor> -
idp.xmlとsp.xmlを、Joplin Server が読み取れる場所に配置します。Docker を使用する場合、例えばdocker-compose.yml内で./saml:/saml:roのようにディレクトリをマウントします。 -
Joplin Server の環境変数を設定します。例えば
.envファイル内に設定します:APP_BASE_URL=https://joplin.example.com
API_BASE_URL=https://joplin.example.com
SAML_ENABLED=true
SAML_IDP_CONFIG_FILE=/saml/idp.xml
SAML_SP_CONFIG_FILE=/saml/sp.xml
SAML_ORGANIZATION_DISPLAY_NAME=Casdoor
DELETE_EXPIRED_SESSIONS_SCHEDULE=Variable Description APP_BASE_URL,API_BASE_URLSAML needs both set to the same URL. SAML_ENABLEDTurns on SAML sign-in. SAML_IDP_CONFIG_FILEThe path of the IdP metadata from Casdoor. SAML_SP_CONFIG_FILEThe path of the SP file. SAML_ORGANIZATION_DISPLAY_NAMEOptional. The name that the sign-in page shows above the SAML button. DELETE_EXPIRED_SESSIONS_SCHEDULEJoplin Server はデフォルトで 6 時間ごとにセッションをクリアするため、SAML ユーザーは手動で再サインインする必要があります。値を空にすることでこの機能を無効化できます。 SAML サインインのみを許可するには、
LOCAL_AUTH_ENABLED=falseも設定します。 -
Joplin Server を再起動します。
結果の確認
- プライベートブラウザウィンドウで
https://joplin.example.com/loginを開き、Login using your organisation account をクリックします。 - Casdoor にサインインします。Casdoor ユーザーがサインインした状態で Joplin Server のホーム画面が開きます。Joplin Server にまだ存在しないユーザーは、この最初のサインイン時に Casdoor のメールと表示名を用いて作成されます。
- Joplin アプリで、同期先として Joplin Server (SAML) を選択し、
https://joplin.example.comを入力します。アプリはブラウザでサインイン画面を開きます。Casdoor にサインインした後、Joplin Server がコードを表示するので、アプリに入力して同期を開始します。
トラブルシューティング
| Symptom | Cause and fix |
|---|---|
Joplin Server logs FAILED_TO_VERIFY_SIGNATURE: POST /api/saml | Update Casdoor to the latest version. If it persists, download the metadata again: Joplin Server must have the certificate of the application's current Cert. |
Joplin Server logs canonicalization algorithm 'http://www.w3.org/2006/12/xml-c14n11' is not supported | Turn on Enable SAML C14N10 on the application. |
Joplin Server logs ERR_EXCEPTION_VALIDATE_XML, about xs:string without a namespace declaration | Update Casdoor to the latest version. Older versions drop the xs namespace from the response when they sign it. |
email must be a string or displayName must be a string | Add the email and displayName rows to SAML attributes, with these exact names, and check that Disable SAML attributes is off. |
Could not login using email "..." | Joplin Server already has a local account with a password for this email, and doesn't let SAML sign in to it. Delete or rename the local account in Joplin Server. |
The browser opens a Joplin Server URL that ends with [object Object] | The IdP metadata has no HTTP-POST endpoint. Turn on Enable SAML POST binding, and download the metadata again with enablePostBinding=true. |
Casdoor shows Issuer URI: Joplin doesn't exist in the allowed Redirect URI list | Add the entityID of sp.xml to Redirect URLs. |
Casdoor shows AssertionConsumerServiceURL: ... doesn't match the SAML reply URL or the allowed Redirect URI list | Add <APP_BASE_URL>/api/saml to Redirect URLs. |
関連項目
- Joplin ドキュメントの Joplin Server SAML support
- CasdoorをSAML IDプロバイダーとして使用