Skip to content

Commit 3159f46

Browse files
committed
Update the Steam provider to support the new HTTPS user identifier namespace
1 parent 643518d commit 3159f46

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/AspNet.Security.OpenId.Steam/SteamAuthenticationConstants.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ public static class SteamAuthenticationConstants
1010
{
1111
public static class Namespaces
1212
{
13-
public const string Identifier = "http://steamcommunity.com/openid/id/";
13+
public const string Identifier = "https://steamcommunity.com/openid/id/";
14+
public const string LegacyIdentifier = "http://steamcommunity.com/openid/id/";
1415
}
1516

1617
public static class Parameters

src/AspNet.Security.OpenId.Steam/SteamAuthenticationHandler.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,20 @@ protected override async Task<AuthenticationTicket> CreateTicketAsync(
4646
return ticket;
4747
}
4848

49+
// Note: prior to April 2018, the Steam identifier was prefixed with an HTTP base address.
50+
// Since then, the prefix is now an HTTPS address. The following logic supports both prefixes.
51+
if (identifier.StartsWith(SteamAuthenticationConstants.Namespaces.Identifier, StringComparison.Ordinal))
52+
{
53+
identifier = identifier.Substring(SteamAuthenticationConstants.Namespaces.Identifier.Length);
54+
}
55+
56+
else if (identifier.StartsWith(SteamAuthenticationConstants.Namespaces.LegacyIdentifier, StringComparison.Ordinal))
57+
{
58+
identifier = identifier.Substring(SteamAuthenticationConstants.Namespaces.LegacyIdentifier.Length);
59+
}
60+
4961
// Return the authentication ticket as-is if the claimed identifier is malformed.
50-
if (!identifier.StartsWith(SteamAuthenticationConstants.Namespaces.Identifier, StringComparison.Ordinal))
62+
else
5163
{
5264
Logger.LogWarning("The userinfo request was skipped because an invalid identifier was received: {Identifier}.", identifier);
5365

@@ -57,7 +69,7 @@ protected override async Task<AuthenticationTicket> CreateTicketAsync(
5769
var address = QueryHelpers.AddQueryString(Options.UserInformationEndpoint, new Dictionary<string, string>
5870
{
5971
[SteamAuthenticationConstants.Parameters.Key] = Options.ApplicationKey,
60-
[SteamAuthenticationConstants.Parameters.SteamId] = identifier.Substring(SteamAuthenticationConstants.Namespaces.Identifier.Length)
72+
[SteamAuthenticationConstants.Parameters.SteamId] = identifier
6173
});
6274

6375
var request = new HttpRequestMessage(HttpMethod.Get, address);

0 commit comments

Comments
 (0)