-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74 from auth0/semantic-cleanup
Semantic cleanup
- Loading branch information
Showing
31 changed files
with
453 additions
and
385 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
namespace Auth0.OidcClient | ||
using System; | ||
|
||
namespace Auth0.OidcClient | ||
{ | ||
/// <summary> | ||
/// PlatformWebView offers the best platform-specific web view implementation | ||
/// at a given time. On Android that is the Chrome Custom Tabs at this time. | ||
/// </summary> | ||
public class PlatformWebView : ChromeCustomTabsBrowser | ||
[Obsolete("It is recommended you leave Browser unassigned to accept the library default of ChromeCustomTabsBrowser.")] | ||
public class PlatformWebView : SystemBrowser | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,114 +1,13 @@ | ||
using IdentityModel.OidcClient.Browser; | ||
using System; | ||
using System.Threading.Tasks; | ||
using Windows.Security.Authentication.Web; | ||
using System; | ||
|
||
namespace Auth0.OidcClient | ||
{ | ||
public class PlatformWebView : IBrowser | ||
[Obsolete("It is recommended you leave Browser unassigned to accept the library default or assign an instance of WebAuthenticationBrokerBrowser if you need to enable Windows authentication.")] | ||
public class PlatformWebView : WebAuthenticationBrokerBrowser | ||
{ | ||
private readonly bool _enableWindowsAuthentication; | ||
|
||
public PlatformWebView(bool enableWindowsAuthentication = false) | ||
: base(enableWindowsAuthentication) | ||
{ | ||
_enableWindowsAuthentication = enableWindowsAuthentication; | ||
} | ||
|
||
public async Task<BrowserResult> InvokeAsync(BrowserOptions options) | ||
{ | ||
if (string.IsNullOrWhiteSpace(options.StartUrl)) throw new ArgumentException("Missing StartUrl", nameof(options)); | ||
|
||
var startUri = new Uri(options.StartUrl); | ||
if (startUri.AbsolutePath.StartsWith("/v2/logout", StringComparison.OrdinalIgnoreCase)) | ||
return await InvokeLogoutAsync(startUri); | ||
|
||
try | ||
{ | ||
var authOptions = ConfigureWebAuthOptions(options.DisplayMode); | ||
var authResult = await WebAuthenticationBroker.AuthenticateAsync(authOptions, startUri, new Uri(options.EndUrl)); | ||
return CreateBrowserResult(authResult); | ||
} | ||
catch (Exception ex) | ||
{ | ||
return new BrowserResult | ||
{ | ||
ResultType = BrowserResultType.UnknownError, | ||
Error = ex.ToString() | ||
}; | ||
} | ||
} | ||
|
||
private async Task<BrowserResult> InvokeLogoutAsync(Uri logoutUri) | ||
{ | ||
try | ||
{ | ||
await WebAuthenticationBroker.AuthenticateAsync(WebAuthenticationOptions.SilentMode, logoutUri); | ||
} | ||
catch | ||
{ | ||
} | ||
|
||
return new BrowserResult | ||
{ | ||
ResultType = BrowserResultType.Success, | ||
Response = String.Empty | ||
}; | ||
} | ||
|
||
private static BrowserResult CreateBrowserResult(WebAuthenticationResult authResult) | ||
{ | ||
switch (authResult.ResponseStatus) | ||
{ | ||
case WebAuthenticationStatus.Success: | ||
return new BrowserResult | ||
{ | ||
ResultType = BrowserResultType.Success, | ||
// Windows IoT Core adds a \0 char at the end of the ResponseData | ||
// when doing response_mode=form_post, so we remove it here | ||
// to avoid breaking the response processor. | ||
Response = authResult.ResponseData?.Replace("\0", string.Empty) | ||
}; | ||
|
||
case WebAuthenticationStatus.ErrorHttp: | ||
return new BrowserResult | ||
{ | ||
ResultType = BrowserResultType.HttpError, | ||
Error = authResult.ResponseErrorDetail.ToString() | ||
}; | ||
|
||
case WebAuthenticationStatus.UserCancel: | ||
return new BrowserResult | ||
{ | ||
ResultType = BrowserResultType.UserCancel | ||
}; | ||
|
||
default: | ||
return new BrowserResult | ||
{ | ||
ResultType = BrowserResultType.UnknownError, | ||
Error = "Invalid response from WebAuthenticationBroker" | ||
}; | ||
} | ||
} | ||
|
||
private WebAuthenticationOptions ConfigureWebAuthOptions(DisplayMode mode) | ||
{ | ||
var options = WebAuthenticationOptions.None; | ||
|
||
if (_enableWindowsAuthentication) | ||
options |= WebAuthenticationOptions.UseCorporateNetwork; | ||
|
||
switch (mode) | ||
{ | ||
case DisplayMode.Visible: | ||
return options; | ||
|
||
case DisplayMode.Hidden: | ||
return options | WebAuthenticationOptions.SilentMode; | ||
|
||
default: | ||
throw new ArgumentException("Invalid DisplayMode", nameof(options)); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.