Skip to content

Commit a0badc8

Browse files
committed
Update the Steam provider to support the new HTTPS user identifier namespace
1 parent a193697 commit a0badc8

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
@@ -56,8 +56,20 @@ protected override async Task<AuthenticationTicket> CreateTicketAsync(
5656
return ticket;
5757
}
5858

59+
// Note: prior to April 2018, the Steam identifier was prefixed with an HTTP base address.
60+
// Since then, the prefix is now an HTTPS address. The following logic supports both prefixes.
61+
if (identifier.StartsWith(SteamAuthenticationConstants.Namespaces.Identifier, StringComparison.Ordinal))
62+
{
63+
identifier = identifier.Substring(SteamAuthenticationConstants.Namespaces.Identifier.Length);
64+
}
65+
66+
else if (identifier.StartsWith(SteamAuthenticationConstants.Namespaces.LegacyIdentifier, StringComparison.Ordinal))
67+
{
68+
identifier = identifier.Substring(SteamAuthenticationConstants.Namespaces.LegacyIdentifier.Length);
69+
}
70+
5971
// Return the authentication ticket as-is if the claimed identifier is malformed.
60-
if (!identifier.StartsWith(SteamAuthenticationConstants.Namespaces.Identifier, StringComparison.Ordinal))
72+
else
6173
{
6274
Logger.LogWarning("The userinfo request was skipped because an invalid identifier was received: {Identifier}.", identifier);
6375

@@ -67,7 +79,7 @@ protected override async Task<AuthenticationTicket> CreateTicketAsync(
6779
var address = QueryHelpers.AddQueryString(Options.UserInformationEndpoint, new Dictionary<string, string>
6880
{
6981
[SteamAuthenticationConstants.Parameters.Key] = Options.ApplicationKey,
70-
[SteamAuthenticationConstants.Parameters.SteamId] = identifier.Substring(SteamAuthenticationConstants.Namespaces.Identifier.Length)
82+
[SteamAuthenticationConstants.Parameters.SteamId] = identifier
7183
});
7284

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

0 commit comments

Comments
 (0)