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

Feature/authentication service #762

Closed
wants to merge 98 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
dab0f4d
Authentication first pass
StephenHodgson Dec 28, 2020
d6103a4
updated auth implementation
StephenHodgson Dec 29, 2020
21177b3
Merge branch 'development' into feature/authentication-service
StephenHodgson Dec 29, 2020
36949cd
updated auth implementation
StephenHodgson Jan 15, 2021
d0daf58
Merge branch 'development' into feature/authentication-service
Jan 15, 2021
c6d4395
Update XRTK-Core/Packages/com.xrtk.core/Runtime/Definitions/Authentic…
StephenHodgson Jan 15, 2021
03e703a
Merge branch 'development' into feature/authentication-service
StephenHodgson Jan 15, 2021
5d19711
Merge branch 'development' into feature/authentication-service
StephenHodgson Jan 15, 2021
c9a5be2
Merge branch 'development' into feature/authentication-service
StephenHodgson Jan 24, 2021
9548292
Merge branch 'development' into feature/authentication-service
StephenHodgson Jan 25, 2021
87cbd14
Merge branch 'development' into feature/authentication-service
StephenHodgson Jan 26, 2021
ffd3000
Merge branch 'development' into feature/authentication-service
StephenHodgson Jan 26, 2021
8e01f5e
Merge branch 'development' into feature/authentication-service
StephenHodgson Jan 27, 2021
dc0f971
Merge branch 'development' into feature/authentication-service
StephenHodgson Feb 6, 2021
1e7b824
Merge branch 'development' into feature/authentication-service
StephenHodgson Feb 6, 2021
2a24699
Merge branch 'development' into feature/authentication-service
StephenHodgson Feb 8, 2021
f516b81
Merge branch 'development' into feature/authentication-service
StephenHodgson Feb 9, 2021
0d00dc6
Merge branch 'development' into feature/authentication-service
StephenHodgson Feb 9, 2021
c8c0c47
Merge branch 'development' into feature/authentication-service
StephenHodgson Feb 13, 2021
d885191
Merge branch 'development' into feature/authentication-service
StephenHodgson Feb 14, 2021
88deb24
Merge branch 'development' into feature/authentication-service
StephenHodgson Feb 14, 2021
0b97d13
Merge branch 'development' into feature/authentication-service
StephenHodgson Feb 14, 2021
4ee7e8c
Merge branch 'development' into feature/authentication-service
StephenHodgson Feb 17, 2021
41e3383
Merge branch 'development' into feature/authentication-service
StephenHodgson Mar 5, 2021
14f63b3
Merge branch 'development' into feature/authentication-service
StephenHodgson Mar 6, 2021
620ae11
Merge branch 'development' into feature/authentication-service
StephenHodgson Apr 2, 2021
127a579
Merge branch 'development' into feature/authentication-service
StephenHodgson Apr 2, 2021
c15fa33
Merge branch 'development' into feature/authentication-service
StephenHodgson Apr 2, 2021
b791dfd
Merge branch 'development' into feature/authentication-service
StephenHodgson Apr 11, 2021
81ac98f
Merge branch 'development' into feature/authentication-service
StephenHodgson Apr 11, 2021
b6629d9
Merge branch 'development' into feature/authentication-service
StephenHodgson Apr 13, 2021
77e449c
Merge branch 'development' into feature/authentication-service
StephenHodgson Apr 13, 2021
361e14e
Merge branch 'development' into feature/authentication-service
StephenHodgson Apr 15, 2021
e3ff924
Merge branch 'development' into feature/authentication-service
StephenHodgson Apr 15, 2021
3925504
Merge branch 'development' into feature/authentication-service
StephenHodgson Apr 20, 2021
e194786
Merge branch 'development' into feature/authentication-service
StephenHodgson Apr 20, 2021
11bcfb1
Merge branch 'development' into feature/authentication-service
StephenHodgson Apr 21, 2021
939a832
Merge branch 'development' into feature/authentication-service
StephenHodgson Apr 22, 2021
395b0c3
Merge branch 'development' into feature/authentication-service
StephenHodgson Apr 22, 2021
e83d8f6
Merge branch 'development' into feature/authentication-service
StephenHodgson Apr 23, 2021
d19302a
Merge branch 'development' into feature/authentication-service
StephenHodgson Apr 23, 2021
56b0cc9
Merge branch 'development' into feature/authentication-service
StephenHodgson Apr 25, 2021
5d35b4b
Merge branch 'development' into feature/authentication-service
StephenHodgson Apr 26, 2021
faacd7f
Merge branch 'development' into feature/authentication-service
StephenHodgson Apr 29, 2021
d1d6957
Merge branch 'development' into feature/authentication-service
StephenHodgson Apr 30, 2021
773834e
Merge branch 'development' into feature/authentication-service
StephenHodgson May 6, 2021
603e35f
Merge branch 'development' into feature/authentication-service
StephenHodgson May 7, 2021
3edd31a
Merge branch 'development' into feature/authentication-service
StephenHodgson May 7, 2021
841f192
Merge branch 'development' into feature/authentication-service
StephenHodgson May 7, 2021
18fa45b
Merge branch 'development' into feature/authentication-service
StephenHodgson May 8, 2021
199ef5c
Merge branch 'development' into feature/authentication-service
StephenHodgson May 10, 2021
fcca6d2
Merge branch 'development' into feature/authentication-service
StephenHodgson May 10, 2021
72b0924
Merge branch 'development' into feature/authentication-service
StephenHodgson May 11, 2021
1c6ae97
Merge branch 'development' into feature/authentication-service
StephenHodgson May 11, 2021
645cf76
Merge branch 'development' into feature/authentication-service
StephenHodgson May 11, 2021
d5cad27
Merge branch 'development' into feature/authentication-service
StephenHodgson May 11, 2021
c593bcf
Merge branch 'development' into feature/authentication-service
StephenHodgson May 11, 2021
2e086b7
Merge branch 'development' into feature/authentication-service
StephenHodgson May 12, 2021
819891b
Merge branch 'development' into feature/authentication-service
StephenHodgson May 12, 2021
34e39e1
Merge branch 'development' into feature/authentication-service
StephenHodgson May 16, 2021
3631d00
Merge branch 'development' into feature/authentication-service
StephenHodgson May 16, 2021
5541445
Merge branch 'development' into feature/authentication-service
StephenHodgson May 17, 2021
d80528b
Merge branch 'development' into feature/authentication-service
StephenHodgson May 19, 2021
0f1d81b
Merge branch 'development' into feature/authentication-service
StephenHodgson May 19, 2021
5d6cf6e
Merge branch 'development' into feature/authentication-service
StephenHodgson May 20, 2021
1ab8978
Merge branch 'development' into feature/authentication-service
StephenHodgson Jun 4, 2021
ccb9753
Merge branch 'development' into feature/authentication-service
StephenHodgson Jun 4, 2021
0863409
Merge branch 'development' into feature/authentication-service
StephenHodgson Jun 10, 2021
298662b
Merge branch 'development' into feature/authentication-service
StephenHodgson Jun 11, 2021
ec43bbb
Merge branch 'development' into feature/authentication-service
StephenHodgson Jun 11, 2021
7f375e5
Merge branch 'development' into feature/authentication-service
StephenHodgson Jun 13, 2021
b6ef8ce
Merge branch 'development' into feature/authentication-service
StephenHodgson Jun 28, 2021
e74ec90
Merge branch 'development' into feature/authentication-service
StephenHodgson Jun 28, 2021
f149155
Merge branch 'development' into feature/authentication-service
StephenHodgson Jul 9, 2021
5166dde
Merge branch 'development' into feature/authentication-service
StephenHodgson Jul 12, 2021
736ef4c
Merge branch 'development' into feature/authentication-service
StephenHodgson Jul 12, 2021
d46e5d5
Merge branch 'development' into feature/authentication-service
StephenHodgson Jul 12, 2021
ccb4fd7
Merge branch 'development' into feature/authentication-service
StephenHodgson Jul 12, 2021
1c11143
Merge branch 'development' into feature/authentication-service
StephenHodgson Jul 13, 2021
5c67f8c
Merge branch 'development' into feature/authentication-service
StephenHodgson Jul 23, 2021
65b56c4
Merge branch 'development' into feature/authentication-service
StephenHodgson Aug 1, 2021
9a92fd4
Merge branch 'development' into feature/authentication-service
StephenHodgson Aug 12, 2021
64c9fcb
Merge branch 'development' into feature/authentication-service
StephenHodgson Aug 15, 2021
a1c7b88
Merge remote-tracking branch 'origin/development' into feature/authen…
StephenHodgson Aug 25, 2021
65e14db
Merge branch 'development' into feature/authentication-service
StephenHodgson Sep 2, 2021
d0d7714
Merge branch 'development' into feature/authentication-service
StephenHodgson Sep 4, 2021
d629b4a
Merge branch 'development' into feature/authentication-service
StephenHodgson Sep 6, 2021
76da480
Merge branch 'development' into feature/authentication-service
StephenHodgson Jan 16, 2022
4c488bb
Merge branch 'development' into feature/authentication-service
StephenHodgson Jan 16, 2022
a711a9b
Merge branch 'development' into feature/authentication-service
StephenHodgson Feb 5, 2022
1d264d0
Merge branch 'development' into feature/authentication-service
StephenHodgson Mar 18, 2022
654a7e6
Merge branch 'development' into feature/authentication-service
StephenHodgson Mar 24, 2022
e7e9401
Merge branch 'development' into feature/authentication-service
StephenHodgson May 13, 2022
06f240b
Merge branch 'development' into feature/authentication-service
StephenHodgson Aug 24, 2022
12a34ab
Merge branch 'development' into feature/authentication-service
StephenHodgson Aug 24, 2022
0dc79a7
Merge branch 'development' into feature/authentication-service
StephenHodgson Aug 25, 2022
6cc8bea
Merge branch 'development' into feature/authentication-service
StephenHodgson Aug 30, 2022
2229e97
Merge branch 'development' into feature/authentication-service
StephenHodgson Nov 27, 2022
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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Copyright (c) XRTK. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using UnityEngine;
using XRTK.Attributes;
using XRTK.Definitions.Utilities;
using XRTK.Interfaces.Authentication;

namespace XRTK.Definitions.Authentication
{
/// <summary>
/// The configuration profile for <see cref="IMixedRealityAuthenticationDataProvider"/>.
/// </summary>
[CreateAssetMenu(menuName = "Mixed Reality Toolkit/Authentication System/Generic Authentication Data Provider", fileName = "AuthenticationDataProviderProfile", order = (int)CreateProfileMenuItemIndices.AuthenticationSystem)]
public class AuthenticationDataProviderProfile : BaseMixedRealityProfile
{
[SerializeField]
[Tooltip("The client ID is the unique application (client) ID assigned to your app by registering your application with the identity provider.")]
private string clientId = "";

/// <summary>
/// The client ID is the unique application (client) ID assigned to your app by registering your application with the identity provider.
/// </summary>
public string ClientId => clientId;

[SerializeField]
[Tooltip("The identity provider url to request OAuth tokens from.")]
private string identityProviderUrl = "";

/// <summary>
/// The identity provider url to request OAuth tokens from.
/// </summary>
public string IdentityProviderUrl => identityProviderUrl;

[SerializeField]
[Tooltip("Scopes or Permissions to request access to.")]
private string[] scopes = new string[0];

/// <summary>
/// The Scopes or Permissions to request access to.
/// </summary>
public string[] Scopes => scopes;

[SerializeField]
[Tooltip("The redirect url is the endpoint the identity provider will send the security tokens back to.")]
private string redirectUrl = "";

/// <summary>
/// The redirect url is the endpoint the identity provider will send the security tokens back to.
/// </summary>
public string RedirectUrl => redirectUrl;

[SerializeField]
[Prefab(typeof(IAuthenticationHandler))]
[Tooltip("The login prefab to display when the user is logging in.")]
private GameObject loginPrefab = null;

/// <summary>
/// The login prefab to display when the user is logging in.
/// </summary>
public GameObject LoginPrefab => loginPrefab;
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright (c) XRTK. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using UnityEngine;
using XRTK.Interfaces.Authentication;

namespace XRTK.Definitions.Authentication
{
public class AuthenticationSystemProfile : BaseMixedRealityServiceProfile<IMixedRealityAuthenticationDataProvider>
{
[SerializeField]
private bool cacheUserTokens = true;

/// <summary>
/// Remember previously obtained user tokens.
/// </summary>
public bool CacheUserTokens => cacheUserTokens;
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public enum CreateProfileMenuItemIndices
Networking,
NetworkingDataProviders,
Diagnostics,
AuthenticationSystem,
RegisteredServiceProviders,
Settings
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright (c) XRTK. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

namespace XRTK.Interfaces.Authentication
{
/// <summary>
/// Represents an authenticated user account
/// </summary>
public interface IAuthenticatedAccount
{
/// <summary>
/// The username of the authenticated account
/// </summary>
string Username { get; }

/// <summary>
/// The access token required for secure access to an online service
/// </summary>
string AccessToken { get; }

/// <summary>
/// Gets the <see cref="IMixedRealityAuthenticationDataProvider"/> that this account identity is associated with.
/// </summary>
IMixedRealityAuthenticationDataProvider Provider { get; }
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright (c) XRTK. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

namespace XRTK.Interfaces.Authentication
{
public interface IAuthenticationHandler : UnityEngine.EventSystems.IEventSystemHandler
{
/// <summary>
/// Display code flow message.
/// </summary>
/// <param name="message"></param>
void DisplayCodeFlowMessage(string message);
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Copyright (c) XRTK. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using System;
using System.Threading.Tasks;
using XRTK.Definitions.Authentication;

namespace XRTK.Interfaces.Authentication
{
/// <summary>
/// Interface contract for specific identity provider implementations for use in the <see cref="IMixedRealityAuthenticationSystem"/>.
/// </summary>
public interface IMixedRealityAuthenticationDataProvider : IMixedRealityDataProvider
{
/// <summary>
/// Event called when a user has successfully logged in.
/// </summary>
event Action<IAuthenticatedAccount> OnLoggedIn;

/// <summary>
/// Event called when a user has logged out.
/// </summary>
event Action<IAuthenticatedAccount> OnLoggedOut;

/// <summary>
/// The <see cref="IAuthenticatedAccount"/>. Null if no user is logged in.
/// </summary>
IAuthenticatedAccount AuthenticatedAccount { get; }

/// <summary>
/// Is there currently a valid user logged in with a valid token?
/// </summary>
bool IsUserLoggedIn { get; }

/// <summary>
/// Start Login task.
/// </summary>
/// <remarks>
/// This may prompt the user to authenticate with the <see cref="AuthenticationDataProviderProfile.LoginPrefab"/>
/// </remarks>
/// <returns>Completed <see cref="Task"/>.</returns>
Task<IAuthenticatedAccount> LoginAsync();

/// <summary>
/// Log the user out.
/// </summary>
/// <param name="reAuthenticate"></param>
void Logout(bool reAuthenticate = true);

/// <summary>
/// Removes all account tokens from the cache.
/// </summary>
void ClearTokenCache();
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// Copyright (c) XRTK. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using XRTK.Definitions.Authentication;

namespace XRTK.Interfaces.Authentication
{
/// <summary>
/// Provider agnostic Interface contract for user authentication with <see href="https://docs.microsoft.com/en-us/azure/active-directory/develop/msal-acquire-cache-tokens#public-client-applications">public client applications</see>.
/// </summary>
public interface IMixedRealityAuthenticationSystem : IMixedRealitySystem
{
/// <summary>
/// Signals when the user has been logged in
/// </summary>
event Action<IMixedRealityAuthenticationDataProvider, IAuthenticatedAccount> OnLoggedIn;

/// <summary>
/// Signals when the user has been logged out.
/// </summary>
event Action<IMixedRealityAuthenticationDataProvider, IAuthenticatedAccount> OnLoggedOut;

/// <summary>
/// Should the login tokens be cached?
/// </summary>
bool CacheUserTokens { get; set; }

/// <summary>
/// Gets the currently logged in <see cref="IAuthenticatedAccount"/>s.
/// </summary>
IReadOnlyCollection<IAuthenticatedAccount> ActiveAccounts { get; }

/// <summary>
/// All of the currently active <see cref="IMixedRealityAuthenticationDataProvider"/>s.
/// </summary>
IReadOnlyCollection<IMixedRealityAuthenticationDataProvider> ActiveAuthenticationProviders { get; }

/// <summary>
/// Register a <see cref="IMixedRealityAuthenticationDataProvider"/> with the system.
/// </summary>
/// <param name="provider">The <see cref="IMixedRealityAuthenticationDataProvider"/> to register.</param>
/// <returns>True, if the <see cref="IMixedRealityAuthenticationDataProvider"/> was successfully registered, otherwise false.</returns>
bool RegisterAuthenticationDataProvider(IMixedRealityAuthenticationDataProvider provider);

/// <summary>
/// Unregister a <see cref="IMixedRealityAuthenticationDataProvider"/> with the system.
/// </summary>
/// <param name="provider">The <see cref="IMixedRealityAuthenticationDataProvider"/> to unregister.</param>
/// <returns>True, if the <see cref="IMixedRealityAuthenticationDataProvider"/> was successfully unregistered, otherwise false.</returns>
bool UnregisterAuthenticationDataProvider(IMixedRealityAuthenticationDataProvider provider);

/// <summary>
/// Logs out of all active sessions in all active <see cref="IMixedRealityAuthenticationDataProvider"/>s.
/// </summary>
void LogOutAllSessions();

/// <summary>
/// Clears out all of the token caches for all active <see cref="IMixedRealityAuthenticationDataProvider"/>s.
/// </summary>
void ClearAllTokenCaches();
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading