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 azuread provider #1254

Merged
merged 2 commits into from
Mar 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ x.y.z (TBD)
### Breaking Changes

### Enhancements
- Added Azure Active Directory (AzureAD) credentials provider. (#1254)

### Bug fixes

Expand Down
11 changes: 11 additions & 0 deletions Platform.PCL/Realm.Sync.PCL/CredentialsPCL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,17 @@ public static Credentials UsernamePassword(string username, string password, boo
return null;
}

/// <summary>
/// Creates <see cref="Credentials"/> based on a Facebook login.
/// </summary>
/// <param name="adToken">An access token, obtained by logging into Azure Active Directory.</param>
/// <returns>An instance of <see cref="Credentials"/> that can be used in <see cref="User.LoginAsync"/></returns>
public static Credentials AzureAD(string adToken)
{
RealmPCLHelpers.ThrowProxyShouldNeverBeUsed();
return null;
}

/// <summary>
/// Gets the identity provider for the credentials.
/// </summary>
Expand Down
17 changes: 17 additions & 0 deletions Shared/Realm.Sync.Shared/Credentials.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ internal static class Providers
internal const string Password = "password";

internal const string AccessToken = "accessToken";

internal const string AzureAD = "azuread";
}

internal static class Keys
Expand Down Expand Up @@ -129,6 +131,21 @@ public static Credentials UsernamePassword(string username, string password, boo
};
}

/// <summary>
/// Creates <see cref="Credentials"/> based on a Facebook login.
/// </summary>
/// <param name="adToken">An access token, obtained by logging into Azure Active Directory.</param>
/// <returns>An instance of <see cref="Credentials"/> that can be used in <see cref="User.LoginAsync"/></returns>
public static Credentials AzureAD(string adToken)
{
if (adToken == null)
{
throw new ArgumentNullException(nameof(adToken));
}

return new Credentials { IdentityProvider = Providers.AzureAD, Token = adToken };
}

internal static Credentials AccessToken(string accessToken, string identity, bool isAdmin = false)
{
return new Credentials
Expand Down