![見出し画像](https://assets.st-note.com/production/uploads/images/72817625/rectangle_large_type_2_c259a013aa58c2721fc98344c00b0091.png?width=800)
プリザンター.NET Core版×AppServiceでSAML認証してみる(SAML設定編)
よーやくここまでこれました。
プリザンターがSSL化できたのでAzure ADとSAMLの設定をしていきたいと思います。この記事もようやく終わりです。
終わるにあたりSAMLの設定自体はすぐ終わるんですが、それまでの準備が結構かかるなぁーという印象でした。
前回までの記事はこちら
参考にさせていただいたもの
感謝です。
■プリザンター(.NET Framework)にSAML認証機能を追加する(公式)
https://pleasanter.org/manual/saml-net-framework
■プリザンター(.NET Core版)でSAML認証する
https://qiita.com/tatsuya_info/items/19c33558a853501e68b0
Azure ADにアプリケーションの登録
1.「AzureAD」→「エンタープライズアプリケーション(全てのアプリケーション)」→「新しいアプリケーション」をクリックします
![スクリーンショット 2022-02-22 21.32.36](https://assets.st-note.com/production/uploads/images/72817614/picture_pc_4cd2aa43661dcf632fc09eefba392a7a.png?width=800)
2.「独自のアプリケーション」の作成を選択し、「アプリの名前」を入力した後、「ギャラリーに見つからないその他アプリケーションを作成します」を選択して「作成」ボタンをクリックします。
![スクリーンショット 2022-02-22 21.36.24](https://assets.st-note.com/production/uploads/images/72817799/picture_pc_d5d70e3987914cf37241051add89a9f2.png?width=800)
作成したアプリケーションの設定
1.作成したpleasanterアプリケーションに遷移するので「ユーザーとグループの割り当て」をクリックします。
![スクリーンショット 2022-02-22 21.40.17](https://assets.st-note.com/production/uploads/images/72818077/picture_pc_9edaf41c376f1dd7b323e5854a6f0e4e.png)
2.「ユーザーとグループ」からプリザンターにアクセスさせたいユーザーを「選択」し「割り当て」をクリックします。
![スクリーンショット 2022-02-22 21.43.45](https://assets.st-note.com/production/uploads/images/72818453/picture_pc_d8932c23fa7b108ea337685868cc0cf8.png?width=800)
3.pleasanterアプリケーションに戻り「シングルサインオンの設定」をクリックし遷移した画面で「SAML」をクリックします。
![スクリーンショット 2022-02-22 21.46.45](https://assets.st-note.com/production/uploads/images/72818608/picture_pc_dafd44e772fdc42b2879a04eb75a18a4.png)
![スクリーンショット 2022-02-22 21.48.25](https://assets.st-note.com/production/uploads/images/72818750/picture_pc_f85ac06de1e243ef7ee0aaff0f89525c.png)
4.基本的なSAML構成の右上の「編集」をクリックします。
![スクリーンショット 2022-02-22 21.49.29](https://assets.st-note.com/production/uploads/images/72818845/picture_pc_69a55646f3436e7926d3f000d35cdb38.png?width=800)
5.「基本的なSAML構成」で、下記パラメータ入力し「保存」をクリックします。
識別子:https://プリザンターのURL/Saml2
応答URL:https://プリザンターのURL/Saml2/Acs
![スクリーンショット 2022-02-22 22.03.12](https://assets.st-note.com/production/uploads/images/72820245/picture_pc_7a74af1ffc9f272e8083e0eeda96be24.png?width=800)
6.「属性とクレーム」の右上の「編集」をクリックします。
![スクリーンショット 2022-02-22 22.05.36](https://assets.st-note.com/production/uploads/images/72820301/picture_pc_3f19e21e0d3f44c5a18026fcd03b4e8e.png?width=800)
7.「新しいクレームの追加」をクリックします。
![スクリーンショット 2022-02-22 22.09.00](https://assets.st-note.com/production/uploads/images/72820602/picture_pc_38b9dd513440ca76ea5fcb29408cbf27.png?width=800)
8.「要求の管理」の画面で「名前」と「ソース属性」に下記パラメータを入力し「保存」をクリックします。
名前:Name
ソース属性:user.displayname
![スクリーンショット 2022-02-22 22.15.18](https://assets.st-note.com/production/uploads/images/72821043/picture_pc_d1978d1c2398017da52b9b5fd151cd43.png)
SAMLパラメータの確認
プリザンターに設定するためのSAMLパラメータを確認します。
「SAML 署名証明書」の項目の中から「拇印」のパラメータをコピーし「証明書(Base64)」の証明書をダウンロードします。
![スクリーンショット 2022-02-22 22.18.48](https://assets.st-note.com/production/uploads/images/72821823/picture_pc_a6255d4333dfcff20f4c0b495f970306.png?width=800)
「Pleasnter のセットアップ」の項目の中から「ログイン URL」と「Azure AD 識別子」のパラメータをコピーします。
![スクリーンショット 2022-02-22 22.26.33](https://assets.st-note.com/production/uploads/images/72822192/picture_pc_d0a498e5564a072d511f174c76c71a10.png?width=800)
AppServiceへのSAML署名証明書の追加
1.先ほどダウンロードした「証明書(Base64)」をAppServiceへ追加します。
「AppService」→TLS/SSL証明書」→「公開キー証明書」のアップロードを選択し「名前」に適当な名前を入力しダウンロードした証明書(Base64)の「CER証明書ファイル」をアップロードした後「アップロード」をクリックします。
![スクリーンショット 2022-02-22 23.39.59](https://assets.st-note.com/production/uploads/images/72828075/picture_pc_cfe0ea79e2a5a39b28b9e6c8fedab679.png?width=800)
![スクリーンショット 2022-02-22 23.46.29](https://assets.st-note.com/production/uploads/images/72828382/picture_pc_586b59209088e2da6731e2710b85ab63.png?width=800)
2.SAML署名証明書のストアが終わったら念の為AppServiceを再起動します。
「AppService」→「概要」→「再起動」をクリックしてアプリケーションの再起動を行います。
![スクリーンショット 2022-02-22 23.48.23](https://assets.st-note.com/production/uploads/images/72828636/picture_pc_8457d3d249797f80e4ba429967f950eb.png?width=800)
プリザンターのSAML設定
1.VisalStudio2019を起動し「Implem.Pleasanter/App_Data/Parameters/Authentication.json」
のファイルを書き換えます。
![スクリーンショット 2022-02-22 23.27.22](https://assets.st-note.com/production/uploads/images/72826852/picture_pc_1a818ad738290176b6ac275bf714db54.png?width=800)
![スクリーンショット 2022-02-22 23.20.10](https://assets.st-note.com/production/uploads/images/72826710/picture_pc_a92a58de3be9d664df04420804bcaf94.png?width=800)
{
//ProviderをSAMLに書き換えます
"Provider": "SAML",
"ServiceId": null,
"ExtensionUrl": null,
"RejectUnregisteredUser": false,
"LdapParameters": [
{
"LdapSearchRoot": null,
"LdapSearchProperty": "sAMAccountName",
"LdapSearchPattern": null,
"LdapLoginPattern": null,
"LdapAuthenticationType": null,
"NetBiosDomainName": null,
"LdapTenantId": 1,
"LdapDeptCode": null,
"LdapDeptCodePattern": null,
"LdapDeptName": null,
"LdapDeptNamePattern": null,
"LdapUserCode": null,
"LdapUserCodePattern": null,
"LdapFirstName": "givenName",
"LdapFirstNamePattern": null,
"LdapLastName": "sn",
"LdapLastNamePattern": null,
"LdapMailAddress": "mail",
"LdapMailAddressPattern": null,
"LdapSyncPageSize": 0,
"LdapSyncPatterns": [
"(&(ObjectCategory=User)(ObjectClass=Person))"
],
"LdapExcludeAccountDisabled": false,
"AutoDisable": false,
"AutoEnable": false,
"LdapSyncUser": null,
"LdapSyncPassword": null
}
],
"SamlParameters": {
"Attributes": {
"Name": "Name",
"UserCode": "UserCode",
"Birthday": "Birthday",
"Gender": "Gender",
"Language": "Language",
"TimeZone": "TimeZone",
"TenantManager": "TenantManager",
"DeptCode": "DeptCode",
"Dept": "Dept",
"Body": "Body",
"MailAddress": "{NameId}"
},
"SamlTenantId": 1,
"DisableOverwriteName": false,
"SPOptions": {
//SPOptionsのEntityIdをhttps://プリザンターのURL/Saml2に書き換えます。
"EntityId": "https://pleasanter.goetan.work/Saml2",
//SPOptionsのReturnUrlをhttps://プリザンターのURL/Users/SamlLoginに書き換えます。
"ReturnUrl": "https://pleasanter.goetan.work/Users/SamlLogin",
"AuthenticateRequestSigningBehavior": "IfIdpWantAuthnRequestsSigned",
"OutboundSigningAlgorithm": "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256",
"MinIncomingSigningAlgorithm": "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256",
"IgnoreMissingInResponseTo": false,
"PublicOrigin": null,
"ServiceCertificates": []
},
"IdentityProviders": [
{
//IdentityProvidersのEntityIdをAzure AD 識別子に書き換えます。
"EntityId": "https://sts.windows.net/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/",
//IdentityProvidersのSignOnUrlをログインURLに書き換えます。
"SignOnUrl": "https://login.microsoftonline.com/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/saml2",
"LogoutUrl": null,
"AllowUnsolicitedAuthnResponse": true,
"Binding": "HttpPost",
"WantAuthnRequestsSigned": false,
"DisableOutboundLogoutRequests": true,
"LoadMetadata": false,
"MetadataLocation": null,
"SigningCertificate": {
"StoreName": "CurrentUser",
"StoreLocation": "My",
"X509FindType": "FindByThumbprint",
//IdentityProvidersのSigningCertificateのFindValueを拇印に書き換えます。
"FindValue": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
}
}
]
}
}
2.書き換えが終わったら保存して一番上のメニューから「ビルド」→「ソリューションのリビルト」を選択しリビルドを行います。
![スクリーンショット 2022-02-22 23.28.45](https://assets.st-note.com/production/uploads/images/72827067/picture_pc_632ae8012f475e915a57044020cebf45.png)
3.「Implem.Pleasanter.Parameter.NetCore」を右クリックして「発行」を選択します。
![スクリーンショット 2022-02-22 23.30.47](https://assets.st-note.com/production/uploads/images/72827251/picture_pc_3279d13a8aac65ad81774f5881a2085c.png)
4.「発行」をクリックしてAzure AppServiceに公開します。
![スクリーンショット 2022-02-22 23.32.45](https://assets.st-note.com/production/uploads/images/72827349/picture_pc_243245e633e409e288bdb9f155bc7178.png?width=800)
プリザンター側にユーザーを追加
ログイン画面にSSOログインのボタンが表示されているかと思います。そのままではSSOログインできないのでプリザンター側にユーザーを作成します。
1.Administratorの権限でログインしてください。
![スクリーンショット 2022-02-22 23.55.50](https://assets.st-note.com/production/uploads/images/72830052/picture_pc_f68c6f103bbcd150a03470ad91e01189.png)
2.プリザンターにログインし「管理」→「ユーザの管理」をクリックします。
![スクリーンショット 2022-02-22 23.57.34](https://assets.st-note.com/production/uploads/images/72829336/picture_pc_e3110966a11f6265e05c4f04d07ddcfd.png)
3.ユーザ-新規作成の画面で「新規作成」をクリックします。
「ログインID」「パスワード」「名前」「再入力」の項目を入力して「作成」をクリックします。
![スクリーンショット 2022-02-23 0.00.57](https://assets.st-note.com/production/uploads/images/72829602/picture_pc_fe663e425395a6e7ec7e7424fcd498fb.png?width=800)
4.ログアウトして再度「SSOログイン」からログインするとAzure ADのクレデンシャルを利用してログインができます。
![スクリーンショット 2022-02-23 0.07.55](https://assets.st-note.com/production/uploads/images/72829977/picture_pc_3075b3bd9d5bf670c587d21186c2171b.png)
検証
こんな感じでログインできます。
プリザンターにSSOログインできるよーになったー。
— GOETAN(小さな粒) (@GOETAN_GOETAN) February 13, 2022
AppService+Azure SQLで爆速構築
まぁハマりまくって2日かかったけどw pic.twitter.com/LBwWXVo4wq
この記事が気に入ったらサポートをしてみませんか?