Skip to content
This repository has been archived by the owner on Jun 30, 2023. It is now read-only.

Commit

Permalink
Merge pull request #97 from MSOpenTech/bugs
Browse files Browse the repository at this point in the history
Remove AcquireTokenAsync overloads without redirectUri from both WinRT a...
  • Loading branch information
omercs committed Aug 25, 2014
2 parents 7845c11 + 11639c1 commit 926acb4
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 152 deletions.
7 changes: 0 additions & 7 deletions src/ADAL.WinPhone/AcquireTokenInteractiveHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,6 @@ protected override Task PreTokenRequest()

internal void AcquireAuthorization()
{
// In SSO, case, we should not pass prompt=login (i.e. PromptBehavior.Always), otherwise persistent cookie cannot be used and SSO would not work.
if (this.ssoMode || this.redirectUri.Scheme == Constant.MsAppScheme)
{
Logger.Verbose(this.CallState, "Using PromptBehavior.RefreshSession for SSO mode");
this.promptBehavior = PromptBehavior.RefreshSession;
}

Uri authorizationUri = this.CreateAuthorizationUri(false);

IDictionary<string, object> payload = new Dictionary<string, object>();
Expand Down
54 changes: 6 additions & 48 deletions src/ADAL.WinPhone/AuthenticationContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,92 +96,50 @@ public static IAsyncOperation<AuthenticationContext> CreateAsync(string authorit
return RunTaskAsAsyncOperation(UpdateAuthenticatorFromTemplateAsync(new AuthenticationContext(authority, validateAuthority, tokenCache) { CorrelationId = correlationId }));
}

/// <summary>
/// Starts security token acquisition from the authority in SSO mode.
/// </summary>
/// <param name="resource">Identifier of the target resource that is the recipient of the requested token.</param>
/// <param name="clientId">Identifier of the client requesting the token.</param>
/// <param name="authDelegate">Optional delegate that can be passed by the developer to process authentication result.</param>
/// <returns>It contains Access Token, Refresh Token and the Access Token's expiration time.</returns>
[DefaultOverload]
public void AcquireTokenAndContinue(string resource, string clientId, AuthenticationContextDelegate authDelegate)
{
this.AcquireTokenAndContinueCommon(resource, clientId, Constant.SsoPlaceHolderUri, UserIdentifier.AnyUser, null, authDelegate);
}

/// <summary>
/// Starts security token acquisition from the authority.
/// </summary>
/// <param name="resource">Identifier of the target resource that is the recipient of the requested token.</param>
/// <param name="clientId">Identifier of the client requesting the token.</param>
/// <param name="redirectUri">Address to return to upon receiving a response from the authority.</param>
/// <param name="redirectUri">Address to return to upon receiving a response from the authority. Pass null or application's callback URI for SSO mode.</param>
/// <param name="authDelegate">Optional delegate that can be passed by the developer to process authentication result.</param>
/// <returns>It contains Access Token, Refresh Token and the Access Token's expiration time.</returns>
[DefaultOverload]
public void AcquireTokenAndContinue(string resource, string clientId, Uri redirectUri, AuthenticationContextDelegate authDelegate)
{
this.AcquireTokenAndContinueCommon(resource, clientId, redirectUri, UserIdentifier.AnyUser, null, authDelegate);
this.AcquireTokenAndContinueCommon(resource, clientId, redirectUri ?? Constant.SsoPlaceHolderUri, UserIdentifier.AnyUser, null, authDelegate);
}

/// <summary>
/// Starts security token acquisition from the authority.
/// </summary>
/// <param name="resource">Identifier of the target resource that is the recipient of the requested token.</param>
/// <param name="clientId">Identifier of the client requesting the token.</param>
/// <param name="redirectUri">Address to return to upon receiving a response from the authority.</param>
/// <param name="redirectUri">Address to return to upon receiving a response from the authority. Pass null or application's callback URI for SSO mode.</param>
/// <param name="userId">Identifier of the user token is requested for. If created from DisplayableId, this parameter will be used to pre-populate the username field in the authentication form. Please note that the end user can still edit the username field and authenticate as a different user.
/// If you want to be notified of such change with an exception, create UserIdentifier with type RequiredDisplayableId. This parameter can be <see cref="UserIdentifier"/>.Any.</param>
/// <param name="authDelegate">Optional delegate that can be passed by the developer to process authentication result.</param>
/// <returns>It contains Access Token, Refresh Token and the Access Token's expiration time.</returns>
[DefaultOverload]
public void AcquireTokenAndContinue(string resource, string clientId, Uri redirectUri, UserIdentifier userId, AuthenticationContextDelegate authDelegate)
{
this.AcquireTokenAndContinueCommon(resource, clientId, redirectUri, userId, null, authDelegate);
this.AcquireTokenAndContinueCommon(resource, clientId, redirectUri ?? Constant.SsoPlaceHolderUri, userId, null, authDelegate);
}

/// <summary>
/// Acquires security token from the authority.
/// </summary>
/// <param name="resource">Identifier of the target resource that is the recipient of the requested token.</param>
/// <param name="clientId">Identifier of the client requesting the token.</param>
/// <param name="redirectUri">Address to return to upon receiving a response from the authority.</param>
/// <param name="redirectUri">Address to return to upon receiving a response from the authority. Pass null or application's callback URI for SSO mode.</param>
/// <param name="userId">Identifier of the user token is requested for. If created from DisplayableId, this parameter will be used to pre-populate the username field in the authentication form. Please note that the end user can still edit the username field and authenticate as a different user.
/// If you want to be notified of such change with an exception, create UserIdentifier with type RequiredDisplayableId. This parameter can be <see cref="UserIdentifier"/>.Any.</param>
/// <param name="extraQueryParameters">This parameter will be appended as is to the query string in the HTTP authentication request to the authority. The parameter can be null.</param>
/// <param name="authDelegate">Optional delegate that can be passed by the developer to process authentication result.</param>
/// <returns>It contains Access Token, Refresh Token and the Access Token's expiration time.</returns>
public void AcquireTokenAndContinue(string resource, string clientId, Uri redirectUri, UserIdentifier userId, string extraQueryParameters, AuthenticationContextDelegate authDelegate)
{
this.AcquireTokenAndContinueCommon(resource, clientId, redirectUri, userId, extraQueryParameters, authDelegate);
}

/// <summary>
/// Starts security token acquisition from the authority in SSO mode.
/// </summary>
/// <param name="resource">Identifier of the target resource that is the recipient of the requested token.</param>
/// <param name="clientId">Identifier of the client requesting the token.</param>
/// <param name="userId">Identifier of the user token is requested for. If created from DisplayableId, this parameter will be used to pre-populate the username field in the authentication form. Please note that the end user can still edit the username field and authenticate as a different user.
/// If you want to be notified of such change with an exception, create UserIdentifier with type RequiredDisplayableId. This parameter can be <see cref="UserIdentifier"/>.Any.</param>
/// <param name="authDelegate">Optional delegate that can be passed by the developer to process authentication result.</param>
/// <returns>It contains Access Token, Refresh Token and the Access Token's expiration time.</returns>
public void AcquireTokenAndContinue(string resource, string clientId, UserIdentifier userId, AuthenticationContextDelegate authDelegate)
{
this.AcquireTokenAndContinueCommon(resource, clientId,Constant.SsoPlaceHolderUri, userId, null, authDelegate);
}

/// <summary>
/// Starts security token acquisition from the authority in SSO mode.
/// </summary>
/// <param name="resource">Identifier of the target resource that is the recipient of the requested token.</param>
/// <param name="clientId">Identifier of the client requesting the token.</param>
/// <param name="userId">Identifier of the user token is requested for. If created from DisplayableId, this parameter will be used to pre-populate the username field in the authentication form. Please note that the end user can still edit the username field and authenticate as a different user.
/// If you want to be notified of such change with an exception, create UserIdentifier with type RequiredDisplayableId. This parameter can be <see cref="UserIdentifier"/>.Any.</param>
/// <param name="extraQueryParameters">This parameter will be appended as is to the query string in the HTTP authentication request to the authority. The parameter can be null.</param>
/// <param name="authDelegate">Optional delegate that can be passed by the developer to process authentication result.</param>
/// <returns>It contains Access Token, Refresh Token and the Access Token's expiration time.</returns>
public void AcquireTokenAndContinue(string resource, string clientId, UserIdentifier userId, string extraQueryParameters, AuthenticationContextDelegate authDelegate)
{
this.AcquireTokenAndContinueCommon(resource, clientId, Constant.SsoPlaceHolderUri, userId, extraQueryParameters, authDelegate);
this.AcquireTokenAndContinueCommon(resource, clientId, redirectUri ?? Constant.SsoPlaceHolderUri, userId, extraQueryParameters, authDelegate);
}

/// <summary>
Expand Down
1 change: 1 addition & 0 deletions src/ADAL.WinPhone/WebUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public PromptBehavior PromptBehavior
{
get
{
// In lack of PromptBehavior in WinPhone, we always pass prompt=login.
return PromptBehavior.Always;
}
}
Expand Down
Loading

0 comments on commit 926acb4

Please sign in to comment.