Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion root/files/tools/WinMergeFilters/touryo.flt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
desc: 棟梁
def: include

## Git
d: \\\.git$ ## Git
d: \\\.github$ ## GitHub

## CodingAgent
d: \\\.claude$ ## Git

## IDE
d: \\\.vs$ ## Visual Studio
d: \\\.vscode$ ## Visual Studio Code
f: \.suo$ ## ソリューションファイル
f: \.user$ ## ユーザファイル

Expand All @@ -28,7 +38,6 @@ d: \\node_modules$ ## npm
f: \.svnignore$ ## Subversion ignore file
f: \.(vs[sp])?scc$ ## Visual SourceSafe files

d: \\\.git$ ## git working copy
d: \\\.svn$ ## Subversion working copy
d: \\_svn$ ## Subversion working copy ASP.NET Hack
d: \\cvs$ ## CVS control directory
Expand Down
16 changes: 11 additions & 5 deletions root/files/tools/WinMergeFilters/touryofull.flt
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,23 @@
desc: 棟梁full
def: include

## Git
d: \\\.git$ ## Git
d: \\\.github$ ## GitHub

## CodingAgent
d: \\\.claude$ ## Git

## IDE
d: \\\.vs$ ## Visual Studio
d: \\\.vscode$ ## Visual Studio Code

f: \.sln$ ## ソリューションファイル
f: \.suo$ ## ソリューションファイル
f: \.user$ ## ユーザファイル
f: \.csproj$ ## プロジェクトファイル
f: \.vbproj$ ## プロジェクトファイル

## IDE
d: \\\.vs$ ## Visual Studio
d: \\\.vscode$ ## Visual Studio Code

## デザイナ(自動生成)
f: \.designer\..*$ ## デザイナファイル
d: \\web references$ ## web reference directory
Expand All @@ -35,7 +42,6 @@ d: \\node_modules$ ## npm
f: \.svnignore$ ## Subversion ignore file
f: \.(vs[sp])?scc$ ## Visual SourceSafe files

d: \\\.git$ ## git working copy
d: \\\.svn$ ## Subversion working copy
d: \\_svn$ ## Subversion working copy ASP.NET Hack
d: \\cvs$ ## CVS control directory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
//* 2019/05/29 西野 大介 Create XMLでは署名しない。
//* Encode And Sign / Decode, Verifyで署名・検証する。
//* 2019/06/04 西野 大介 スキーマ検証と属性抽出にはXPathを使用。
//* 2026/10/07 玄人 幸道 VerifyByXPathがStatusCodeを見ずにAssertionを必須にしており、
//* Assertionを持たない正当なエラー応答を弾いていたのを修正(#598)
//**********************************************************************************

using System;
Expand Down Expand Up @@ -556,6 +558,13 @@ public static bool VerifyPost(string saml, string referenceId, RSA rsa)
/// <param name="schema">SAML2Enum.SamlSchema</param>
/// <param name="samlNsMgr">XmlNamespaceManager</param>
/// <returns>bool</returns>
/// <remarks>
/// Response の Assertion は、StatusCode が Success のときだけ必須(#598)。
/// SAML 2.0 Core 3.2.2 / 4.1.4.2 のとおり、エラー応答は Status だけで正当である。
///
/// そのため、Response で true が返っても Assertion があるとは限らない。
/// Assertion を読む前に、StatusCode が Success であることを確かめること。
/// </remarks>
public static bool VerifyByXPath(
XmlDocument saml, SAML2Enum.SamlSchema schema, XmlNamespaceManager samlNsMgr)
{
Expand Down Expand Up @@ -615,6 +624,16 @@ public static bool VerifyByXPath(
{
interimReport = true;
}
else if (xmlNodeList != null && xmlNodeList.Count == 0)
{
// エラー応答(StatusCode が Success 以外)は、
// Assertion を持たないのが正当(#598)。
if (SAML2Bindings.GetStatusCodeInResponse(saml, samlNsMgr)
!= SAML2Const.UrnStatusCodeSuccess)
{
result = true;
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
//* 日時 更新者 内容
//* ---------- ---------------- -------------------------------------------------
//* 2019/06/04 西野 大介 新規作成
//* 2026/10/07 玄人 幸道 VerifyResponseのout statusCodeを、検証の前に設定するようにした(#598)。
//* 検証に失敗するとnullのままで、呼び出し側が理由を切り分けられなかった。
//**********************************************************************************

using System;
Expand Down Expand Up @@ -125,6 +127,13 @@ public static string CreatePostRequest(
/// <param name="samlResponse2">XmlDocument</param>
/// <param name="hashAlgorithmName">HashAlgorithmName</param>
/// <returns>bool</returns>
/// <remarks>
/// statusCode は、応答を読めた時点(署名・構造の検証より前)で設定する(#598)。
/// false が返ったときに、呼び出し側が理由を切り分けるためである。
///
/// したがって、false のときの statusCode は検証されていない値である。
/// 表示・ログによる切り分けにだけ使い、認証の判断には戻り値を使うこと。
/// </remarks>
public static bool VerifyResponse(
string queryString, string samlResponse,
out string nameId, out string iss, out string aud,
Expand Down Expand Up @@ -179,6 +188,12 @@ public static bool VerifyResponse(

// XmlNamespaceManager
XmlNamespaceManager samlNsMgr = SAML2Bindings.CreateNamespaceManager(samlResponse2);

// StatusCode
// 検証に失敗しても呼び出し側が理由を切り分けられるよう、検証の前に設定する(#598)。
SAML2Enum.StringToEnum(
SAML2Bindings.GetStatusCodeInResponse(
samlResponse2, samlNsMgr), out statusCode);
#endregion

#region 検証
Expand Down Expand Up @@ -215,11 +230,7 @@ public static bool VerifyResponse(
string temp1 = "";
string temp2 = "";

// StatusCode
SAML2Enum.StringToEnum(
SAML2Bindings.GetStatusCodeInResponse(
samlResponse2, samlNsMgr), out statusCode);

// StatusCode(準備の時点で設定済み)
if (statusCode == SAML2Enum.StatusCode.Success)
{
// iss
Expand Down
2 changes: 2 additions & 0 deletions root/programs/CS/Frameworks/Tests/TestCode/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
//* 1 つが例外を投げると、以降が実行されなかった。
//* 2026/08/08 玄人 幸道 TestZipV2の呼び出しを追加(#524)
//* 2026/09/10 玄人 幸道 TestIdTokenの呼び出しを追加(#584)
//* 2026/10/07 玄人 幸道 TestSAML2の呼び出しを追加(#598)
//**********************************************************************************

using System;
Expand Down Expand Up @@ -110,6 +111,7 @@ public static void Main(string[] args)

#region Framework
Program.Run("TestIdToken", TestIdToken.Root);
Program.Run("TestSAML2", TestSAML2.Root);
#endregion

#region Business
Expand Down
1 change: 1 addition & 0 deletions root/programs/CS/Frameworks/Tests/TestCode/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ y_Build_TestCode_Public.bat … ビルド → 実行 → 結果ファイル
| ファイル | 対象 | 見ていること |
|---|---|---|
| `TestIdToken` | `Framework.Authentication` | `at_hash` / `c_hash` / `s_hash` の計算(`IdToken.CreateHash` / `VerifyHash`)。**期待値は OIDC 仕様の例示値**(#584) |
| `TestSAML2` | `Framework.Authentication` | SAML2 の応答の構造検証(`SAML2Bindings.VerifyByXPath`)。**Assertion が必須なのは `StatusCode` が `Success` のときだけ**(#598) |

`TestEmbedded.txt` は `TestResourceLoader` が読む埋め込みリソース。
**`LogicalName` を `TestCode.TestEmbedded.txt` に固定している**
Expand Down
19 changes: 14 additions & 5 deletions root/programs/CS/Frameworks/Tests/TestCode/Result48.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ log4net: Setting Collection Property [AddFilter] to object [log4net.Filter.Level
log4net: Created Appender [OPERATION2]
log4net: Adding appender named [OPERATION2] to logger [OPERATION].
log4net: Hierarchy Threshold []
[2026/09/10 22:27:52,562],[DEBUG],[1],LogIF.DebugLog("ACCESS");
[2026/09/10 22:27:52,568],[INFO ],[1],LogIF.InfoLog("ACCESS");
[2026/09/10 22:27:52,569],[WARN ],[1],LogIF.WarnLog("ACCESS");
[2026/09/10 22:27:52,569],[ERROR],[1],LogIF.ErrorLog("ACCESS");
[2026/09/10 22:27:52,569],[FATAL],[1],LogIF.FatalLog("ACCESS");
[2026/10/07 17:09:45,036],[DEBUG],[1],LogIF.DebugLog("ACCESS");
[2026/10/07 17:09:45,048],[INFO ],[1],LogIF.InfoLog("ACCESS");
[2026/10/07 17:09:45,049],[WARN ],[1],LogIF.WarnLog("ACCESS");
[2026/10/07 17:09:45,049],[ERROR],[1],LogIF.ErrorLog("ACCESS");
[2026/10/07 17:09:45,049],[FATAL],[1],LogIF.FatalLog("ACCESS");
LogIF.Is*Enabled - ACCESS : Debug True / Info True / Warn True / Error True / Fatal True
log4net: configuring repository [log4net-default-repository] using stream
log4net: loading XML configuration
Expand Down Expand Up @@ -2972,4 +2972,13 @@ IdToken.VerifyHash
左半分(OIDC の定義) : True
左右の XOR(修正前の値) : False
----------------------------------------------------------------------------------------------------
SAML2Bindings.VerifyByXPath(Response)
Success・Assertion あり : True(期待値と一致 : True)
Success・Assertion なし : False(期待値と一致 : True)
Requester・Assertion なし : True(期待値と一致 : True)
Responder・Assertion なし : True(期待値と一致 : True)
Requester・Assertion あり : True(期待値と一致 : True)
Requester・Assertion に Issuer なし : False(期待値と一致 : True)
Status なし : False(期待値と一致 : True)
----------------------------------------------------------------------------------------------------
log4net: Shutdown called on Hierarchy [log4net-default-repository]
19 changes: 14 additions & 5 deletions root/programs/CS/Frameworks/Tests/TestCode/ResultCore100.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ log4net: Setting Collection Property [AddFilter] to object [log4net.Filter.Level
log4net: Created Appender [OPERATION2]
log4net: Adding appender named [OPERATION2] to logger [OPERATION].
log4net: Hierarchy Threshold []
[2026/09/10 22:27:55,097],[DEBUG],[2],LogIF.DebugLog("ACCESS");
[2026/09/10 22:27:55,105],[INFO ],[2],LogIF.InfoLog("ACCESS");
[2026/09/10 22:27:55,105],[WARN ],[2],LogIF.WarnLog("ACCESS");
[2026/09/10 22:27:55,106],[ERROR],[2],LogIF.ErrorLog("ACCESS");
[2026/09/10 22:27:55,106],[FATAL],[2],LogIF.FatalLog("ACCESS");
[2026/10/07 17:09:49,867],[DEBUG],[2],LogIF.DebugLog("ACCESS");
[2026/10/07 17:09:49,876],[INFO ],[2],LogIF.InfoLog("ACCESS");
[2026/10/07 17:09:49,877],[WARN ],[2],LogIF.WarnLog("ACCESS");
[2026/10/07 17:09:49,877],[ERROR],[2],LogIF.ErrorLog("ACCESS");
[2026/10/07 17:09:49,877],[FATAL],[2],LogIF.FatalLog("ACCESS");
LogIF.Is*Enabled - ACCESS : Debug True / Info True / Warn True / Error True / Fatal True
log4net: configuring repository [log4net-default-repository] using stream
log4net: loading XML configuration
Expand Down Expand Up @@ -2993,4 +2993,13 @@ IdToken.VerifyHash
左半分(OIDC の定義) : True
左右の XOR(修正前の値) : False
----------------------------------------------------------------------------------------------------
SAML2Bindings.VerifyByXPath(Response)
Success・Assertion あり : True(期待値と一致 : True)
Success・Assertion なし : False(期待値と一致 : True)
Requester・Assertion なし : True(期待値と一致 : True)
Responder・Assertion なし : True(期待値と一致 : True)
Requester・Assertion あり : True(期待値と一致 : True)
Requester・Assertion に Issuer なし : False(期待値と一致 : True)
Status なし : False(期待値と一致 : True)
----------------------------------------------------------------------------------------------------
log4net: Shutdown called on Hierarchy [log4net-default-repository]
Loading
Loading