Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SteamAuthentication to handle new Steam login flow sessions #1129

Merged
merged 29 commits into from
Mar 23, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
0084f8e
Create SteamAuthentication
xPaw Aug 29, 2022
3c8472d
Add some polling support
xPaw Aug 29, 2022
cf5635a
Add AccessToken to LogOnDetails
xPaw Aug 29, 2022
a127e68
Return tokens when poll returns data
xPaw Aug 29, 2022
b617056
Put send/poll methods on the session object
xPaw Aug 30, 2022
d373630
Add authenticator object and implement 2FA auth
xPaw Aug 30, 2022
a8add89
Sort by preferred auth confirmation
xPaw Aug 30, 2022
7603aa8
Add AuthenticationException
xPaw Aug 31, 2022
6322eb3
Add guard_data; add some comments
xPaw Mar 3, 2023
8c7b10f
Add authentication sample
xPaw Mar 11, 2023
f92bac3
Change enum to IsPersistentSession bool
xPaw Mar 12, 2023
b7d393f
Add cancellation token to polling
xPaw Mar 13, 2023
ec96a73
Make `AuthenticationException` public
JustArchi Mar 15, 2023
3687218
Allow consumers to decide whether they want to poll for device confir…
xPaw Mar 15, 2023
5767a15
Add a sample for authenticating using qr codes
xPaw Mar 15, 2023
1c2cc7a
Add more comments
xPaw Mar 15, 2023
8d10d5a
Cleanup, add qr challenge url change callback, add os type
xPaw Mar 17, 2023
43b634a
Use default WebsiteID in sample
xPaw Mar 17, 2023
f8ec8a9
Add a sample parsing jwt payload
xPaw Mar 17, 2023
44cf6b4
Deprecate login keys
xPaw Mar 17, 2023
b006cd2
Document more website ids
xPaw Mar 17, 2023
2fc013e
Handle incorrect 2FA codes and call the authenticator again
xPaw Mar 17, 2023
20c0b84
Update guard data comment
xPaw Mar 22, 2023
7b266f3
Review
xPaw Mar 22, 2023
2cb4a75
Move authentication stuff to its own namespace
xPaw Mar 22, 2023
2496b06
Suppress LoginKey obsolete warnings in SK codebase
xPaw Mar 22, 2023
9aa61d0
Review
xPaw Mar 23, 2023
79931d7
Change visibility
xPaw Mar 23, 2023
1d41f5f
Added `SteamClient.Authentication`
xPaw Mar 23, 2023
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
4 changes: 2 additions & 2 deletions Samples/1a.Authentication/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

if ( args.Length < 2 )
{
Console.WriteLine( "Sample1: No username and password specified!" );
Console.Error.WriteLine( "Sample1a: No username and password specified!" );
return;
}

Expand Down Expand Up @@ -60,7 +60,7 @@ async void OnConnected( SteamClient.ConnectedCallback callback )
} );

// Starting polling Steam for authentication response
var pollResponse = await authSession.StartPolling();
var pollResponse = await authSession.PollingWaitForResultAsync();

// Logon to Steam with the access token we have received
// Note that we are using RefreshToken for logging on here
Expand Down
2 changes: 1 addition & 1 deletion Samples/1b.QrCodeAuthentication/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ async void OnConnected( SteamClient.ConnectedCallback callback )

// Starting polling Steam for authentication response
// This response is later used to logon to Steam after connecting
var pollResponse = await authSession.StartPolling();
var pollResponse = await authSession.PollingWaitForResultAsync();

Console.WriteLine( $"Logging in as '{pollResponse.AccountName}'..." );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,20 @@ namespace SteamKit2
/// <summary>
/// Thrown when <see cref="SteamAuthentication"/> fails to authenticate.
/// </summary>
public class AuthenticationException : Exception
[Serializable]
public sealed class AuthenticationException : Exception
{
xPaw marked this conversation as resolved.
Show resolved Hide resolved
/// <summary>
/// Gets the result of the authentication request.
/// </summary>
public EResult Result { get; private set; }
public EResult Result { get; }

/// <summary>
/// Initializes a new instance of the <see cref="AuthenticationException"/> class.
/// </summary>
public AuthenticationException()
{
}

/// <summary>
/// Initializes a new instance of the <see cref="AuthenticationException"/> class.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace SteamKit2
{
/// <summary>
///
/// Represents an authenticator to be used with <see cref="SteamAuthentication"/>.
/// </summary>
public interface IAuthenticator
{
Expand All @@ -13,22 +13,22 @@ public interface IAuthenticator
/// </summary>
/// <param name="previousCodeWasIncorrect">True when previously provided code was incorrect.</param>
/// <returns>The 2-factor auth code used to login. This is the code that can be received from the authenticator app.</returns>
public Task<string> ProvideDeviceCode( bool previousCodeWasIncorrect );
public Task<string> GetDeviceCodeAsync( bool previousCodeWasIncorrect );

/// <summary>
/// This method is called when the account being logged into uses Steam Guard email authentication. This code is sent to the user's email.
/// </summary>
/// <param name="email">The email address that the Steam Guard email was sent to.</param>
/// <param name="previousCodeWasIncorrect">True when previously provided code was incorrect.</param>
/// <returns>The Steam Guard auth code used to login.</returns>
public Task<string> ProvideEmailCode( string email, bool previousCodeWasIncorrect );
public Task<string> GetEmailCodeAsync( string email, bool previousCodeWasIncorrect );

/// <summary>
/// This method is called when the account being logged has the Steam Mobile App and accepts authentication notification prompts.
///
/// Return false if you want to fallback to entering a code instead.
/// </summary>
/// <returns>Return true to poll until the authentication is accepted, return false to fallback to entering a code.</returns>
public Task<bool> AcceptDeviceConfirmation();
public Task<bool> AcceptDeviceConfirmationAsync();
}
}
Loading