Skip to content

Commit bf5b640

Browse files
committed
Initial fix for issue #16
1 parent 5479e35 commit bf5b640

4 files changed

Lines changed: 19 additions & 5 deletions

File tree

MFaaP.MFWSClient/MFWSClient.Authentication.cs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,15 @@ public partial class MFWSClient
2222
/// </summary>
2323
protected const string XAuthenticationHttpHeaderName = "X-Authentication";
2424

25+
/// <summary>
26+
/// The HTTP header name used to maintain the active vault (if multiple vaults and using SSO).
27+
/// </summary>
28+
protected const string XActiveVaultHttpHeaderName = "X-Active-Vault";
29+
2530
/// <summary>
2631
/// The HTTP header name used for the vault guid (<see cref="AddVaultHeader(System.Guid)"/>).
2732
/// </summary>
28-
protected const string VaultHttpHeaderName = "X-Vault";
33+
protected const string XVaultHttpHeaderName = "X-Vault";
2934

3035
/// <summary>
3136
/// This is the authentication token used in the request headers.
@@ -69,7 +74,7 @@ public void AddVaultHeader(Guid vaultGuid)
6974
/// <remarks>Typically used with OAuth authentication tokens.</remarks>
7075
public void AddVaultHeader(string vaultGuid)
7176
{
72-
this.AddDefaultHeader(MFWSClient.VaultHttpHeaderName, vaultGuid);
77+
this.AddDefaultHeader(MFWSClient.XVaultHttpHeaderName, vaultGuid);
7378
}
7479

7580
/// <summary>
@@ -78,7 +83,7 @@ public void AddVaultHeader(string vaultGuid)
7883
public void ClearVaultHeader()
7984
{
8085
// Remove the authorisation header.
81-
foreach (var parameter in this.DefaultParameters.Where(p => p.Name == MFWSClient.VaultHttpHeaderName)
86+
foreach (var parameter in this.DefaultParameters.Where(p => p.Name == MFWSClient.XVaultHttpHeaderName)
8287
.ToArray())
8388
{
8489
this.DefaultParameters.Remove(parameter);
@@ -98,7 +103,13 @@ protected virtual void ClearAuthenticationToken()
98103
this.CookieContainer = new CookieContainer();
99104

100105
// Remove the authorisation header.
101-
foreach (var parameter in this.DefaultParameters.Where(p => p.Name == MFWSClient.AuthorizationHttpHeaderName)
106+
foreach (var parameter in this
107+
.DefaultParameters
108+
.Where
109+
(
110+
p => p.Name == MFWSClient.AuthorizationHttpHeaderName
111+
|| p.Name == MFWSClient.XActiveVaultHttpHeaderName
112+
)
102113
.ToArray())
103114
{
104115
this.DefaultParameters.Remove(parameter);
@@ -137,6 +148,9 @@ protected virtual void ClearAuthenticationToken()
137148
this.CookieContainer.Add(this.BaseUrl, new Cookie(cookie.Name, cookie.Value, cookie.Path, cookie.Domain));
138149
}
139150
}
151+
152+
// Ensure that the active vault is stored.
153+
this.AddDefaultHeader(MFWSClient.XActiveVaultHttpHeaderName, vaultId.ToString("B"));
140154
}
141155

142156
/// <summary>

MFaaP.MFWSClient/MFaaP.MFWSClient.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
</ItemGroup>
1515

1616
<PropertyGroup>
17-
<Version>1.2.3-alpha</Version>
17+
<Version>1.2.4-alpha</Version>
1818
<Authors>M-Files Corporation</Authors>
1919
<Description>Sample .NET wrapper for the M-Files Web Service. Not designed for production use.</Description>
2020
<Copyright>Copyright (c) 2020 onwards, M-Files Corporation</Copyright>
-230 KB
Binary file not shown.
231 KB
Binary file not shown.

0 commit comments

Comments
 (0)