mod_auth_mellon + ADFS の組み合わせで認証が失敗する


はじめに

idP に Microsoft ADFS、SAMP SP に mod_auth_mellon を組み合わせた際に発生した認証エラーの対処内容です。
内容としては単純なものでしたが、若干ハマってしまったのでご参考になればと思います。

発生した事象

SPにアクセスを行い、ADFSに遷移しログインが成功したのち、SPにレスポンスをPOSTしたタイミングで、mod_auth_mellon にて以下のエラーが出力されて認証が失敗する。

Error processing authn response. Lasso error: [-432] Status code is not success, SAML Response: 
StatusCode1="urn:oasis:names:tc:SAML:2.0:status:Requester",
StatusCode2="urn:oasis:names:tc:SAML:2.0:status:InvalidNameIDPolicy", StatusMessage="(null)"

原因と対処方法

原因は ADFSが返答する情報が mod_auth_mellon が求めているポリシーに則っていないためエラーとなっている。
対処方法としては、ADFSに要求規則名 Name ID で以下の規則を追加する。

c:[Type == "http://schemas.microsoft.com/ws/2008/06/identity/claims/windowsaccountname"]
 => issue(Type = "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier", Issuer = c.Issuer, OriginalIssuer = c.OriginalIssuer, Value = c.Value, ValueType = c.ValueType, Properties["http://schemas.xmlsoap.org/ws/2005/05/identity/claimproperties/format"] = "urn:oasis:names:tc:SAML:2.0:nameid-format:transient");

おまけ

上記の対処方法に行き着くまでに調査した内容です。

ハッシュアルゴリズムの相違?

idP と SP でハッシュアルゴリズムが異なっている場合にもこのエラーが発生するとのことだったが、両者ともSHA254となっていた。
→ 念の為、SHA1で揃えてみたがエラーは解消せず。

ライブラリのバージョン

mod_auth_mellon は SSO のライブラリに lasso を使用しており、SHA256を使用するには lasso 2.5以上が必要。
→ バージョンを確認したところ、2.5.1だった。

# yum list installed | grep lasso
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
lasso.x86_64                          2.5.1-3.el7                     @base

参考(ソフトウェア構成)

SAMLのミドルウェア 備考
idP Microsoft ADFS WindowsServer2019
SAMP SP mod_auth_mellon CentOS Linux (release 7.7.1908)
Apache(2.4.6-90.el7.centos)
mod_auth_mellon(0.14.0-2.el7_6.4)