/// <summary> /// Creates an authorization url with parameters to begin the authorization process /// </summary> /// <param name="request">Originating web request</param> /// <param name="discoveryResponse">The response returned by the discovery process</param> /// <param name="encryptedMSISDN">Encrypted MSISDN/Subscriber Id returned from the Discovery process</param> /// <param name="state">Unique string to be used to prevent Cross Site Forgery Request attacks during request token process (defaults to guid if not supplied, value will be returned in MobileConnectStatus object)</param> /// <param name="nonce">Unique string to be used to prevent replay attacks during request token process (defaults to guid if not supplied, value will be returned in MobileConnectStatus object)</param> /// <param name="options">Optional parameters</param> /// <returns>MobileConnectStatus object with required information for continuing the mobileconnect process</returns> public MobileConnectStatus StartAuthorization(HttpRequestMessage request, DiscoveryResponse discoveryResponse, string encryptedMSISDN, string state, string nonce, MobileConnectRequestOptions options) { state = string.IsNullOrEmpty(state) ? GenerateUniqueString() : state; nonce = string.IsNullOrEmpty(nonce) ? GenerateUniqueString() : nonce; return(MobileConnectInterfaceHelper.StartAuthorization(_authentication, discoveryResponse, encryptedMSISDN, state, nonce, _config, options)); }
/// <summary> /// Performs headless authentication followed by request token if successful. Tokens will be validated before being returned. /// This may be a long running method as it waits for the authenticating user to respond using their authenticating device. /// </summary> /// <param name="request">Originating web request</param> /// <param name="discoveryResponse">The response returned by the discovery process</param> /// <param name="encryptedMSISDN">Encrypted MSISDN/Subscriber Id returned from the Discovery process</param> /// <param name="state">Unique string to be used to prevent Cross Site Forgery Request attacks during request token process (defaults to guid if not supplied, value will be returned in MobileConnectStatus object)</param> /// <param name="nonce">Unique string to be used to prevent replay attacks during request token process (defaults to guid if not supplied, value will be returned in MobileConnectStatus object)</param> /// <param name="options">Optional parameters</param> /// <param name="cancellationToken">Cancellation token that can be used to cancel long running requests</param> /// <returns>MobileConnectStatus object with required information for continuing the mobileconnect process</returns> public async Task <MobileConnectStatus> RequestHeadlessAuthenticationAsync( HttpRequestMessage request, DiscoveryResponse discoveryResponse, string encryptedMSISDN, string state, string nonce, MobileConnectRequestOptions options, string version, CancellationToken cancellationToken = default(CancellationToken)) { state = string.IsNullOrEmpty(state) ? Security.GenerateSecureNonce() : state; nonce = string.IsNullOrEmpty(nonce) ? Security.GenerateSecureNonce() : nonce; return(await MobileConnectInterfaceHelper.RequestHeadlessAuthentication( _authentication, _jwks, _identity, discoveryResponse, encryptedMSISDN, state, nonce, _config, options, version, cancellationToken)); }
/// <summary> /// Handles continuation of the process following a completed redirect, the request token url must be provided if it has been returned by the discovery process. /// Only the request and redirectedUrl are required, however if the redirect being handled is the result of calling the Authorization URL then the remaining parameters are required. /// </summary> /// <param name="request">Originating web request</param> /// <param name="redirectedUrl">Url redirected to by the completion of the previous step</param> /// <param name="sdkSession">SDKSession id used to fetch the discovery response with additional parameters that are required to request a token</param> /// <param name="expectedState">The state value returned from the StartAuthorization call should be passed here, it will be used to validate the authenticity of the authorization process</param> /// <param name="expectedNonce">The nonce value returned from the StartAuthorization call should be passed here, it will be used to ensure the token was not requested using a replay attack</param> /// <param name="options">Optional parameters</param> /// <returns>MobileConnectStatus object with required information for continuing the mobileconnect process</returns> public async Task <MobileConnectStatus> HandleUrlRedirectAsync( HttpRequestMessage request, Uri redirectedUrl, string sdkSession = null, string expectedState = null, string expectedNonce = null, MobileConnectRequestOptions options = null, string version = null) { var discoveryResponse = await GetSessionFromCache(sdkSession); if (discoveryResponse == null && (expectedNonce != null || expectedState != null || sdkSession != null)) { return(GetCacheError()); } return(await CacheIfRequired( await MobileConnectInterfaceHelper.HandleUrlRedirect( _discovery, _authentication, _jwks, redirectedUrl, discoveryResponse, expectedState, expectedNonce, _config, options, version))); }
/// <summary> /// Attempt discovery using the values returned from the operator selection redirect /// </summary> /// <param name="request">Originating web request</param> /// <param name="redirectedUrl">Uri redirected to by the completion of the operator selection UI</param> /// <returns>MobileConnectStatus object with required information for continuing the mobileconnect process</returns> public async Task <MobileConnectStatus> AttemptDiscoveryAfterOperatorSelectionAsync( HttpRequestMessage request, Uri redirectedUrl) { return(await CacheIfRequired( await MobileConnectInterfaceHelper.AttemptDiscoveryAfterOperatorSelection( _discovery, redirectedUrl, _config))); }
/// <summary> /// Attempt discovery using the supplied parameters. If msisdn, mcc and mnc are null the result will be operator selection, otherwise valid parameters will result in a StartAuthorization status /// </summary> /// <param name="request">Originating web request</param> /// <param name="msisdn">MSISDN from user</param> /// <param name="mcc">Mobile Country Code</param> /// <param name="mnc">Mobile Network Code</param> /// <param name="shouldProxyCookies">If cookies from the original request should be sent onto the discovery service</param> /// <param name="options">Optional parameters</param> /// <returns>MobileConnectStatus object with required information for continuing the mobileconnect process</returns> public async Task <MobileConnectStatus> AttemptDiscoveryAsync(HttpRequestMessage request, string msisdn, string mcc, string mnc, bool shouldProxyCookies, MobileConnectRequestOptions options) { options.ClientIP = string.IsNullOrEmpty(options.ClientIP) ? request.GetClientIp() : options.ClientIP; var cookies = shouldProxyCookies ? request.GetCookies() : null; return(await CacheIfRequired(await MobileConnectInterfaceHelper.AttemptDiscovery(_discovery, msisdn, mcc, mnc, cookies, _config, options))); }
/// <summary> /// Refresh token using using the refresh token provided in the RequestToken response /// </summary> /// <param name="request">Originating web request</param> /// <param name="refreshToken">Refresh token returned from RefreshToken request</param> /// <param name="discoveryResponse">The response returned by the discovery process</param> /// <returns>Object with required information for continuing the mobile connect process</returns> public async Task <MobileConnectStatus> RefreshTokenAsync( HttpRequestMessage request, string refreshToken, DiscoveryResponse discoveryResponse) { return(await MobileConnectInterfaceHelper.RefreshToken( _authentication, refreshToken, discoveryResponse, _config)); }
/// <summary> /// Request identity using the access token returned by <see cref="RequestTokenAsync(HttpRequestMessage, DiscoveryResponse, Uri, string, string, MobileConnectRequestOptions)"/> /// </summary> /// <param name="request">Originating web request</param> /// <param name="discoveryResponse">The response returned by the discovery process</param> /// <param name="accessToken">Access token returned from RequestToken required to authenticate the request</param> /// <param name="options">Optional parameters</param> /// <returns>MobileConnectStatus object with requested Identity information</returns> public async Task <MobileConnectStatus> RequestPremiumInfoAsync( HttpRequestMessage request, DiscoveryResponse discoveryResponse, string accessToken, MobileConnectRequestOptions options) { return(await MobileConnectInterfaceHelper.RequestPremiumInfo( _identity, discoveryResponse, accessToken, _config, options)); }
/// <summary> /// Creates an authorization url with parameters to begin the authorization process /// </summary> /// <param name="discoveryResponse">The response returned by the discovery process</param> /// <param name="encryptedMSISDN">Encrypted MSISDN/Subscriber Id returned from the Discovery process</param> /// <param name="state">Unique state value, this will be returned by the authorization process and should be checked for equality as a security measure</param> /// <param name="nonce">Unique value to associate a client session with an id token</param> /// <param name="options">Optional parameters</param> /// <returns>MobileConnectStatus object with required information for continuing the mobileconnect process</returns> public MobileConnectStatus StartAuthentication( DiscoveryResponse discoveryResponse, string encryptedMSISDN, string state, string nonce, MobileConnectRequestOptions options, string version) { return(MobileConnectInterfaceHelper.StartAuthentication( _authentication, discoveryResponse, encryptedMSISDN, state, nonce, _config, options, version)); }
/// <summary> /// Synchronous wrapper for <see cref="MobileConnectInterface.RequestTokenAsync(DiscoveryResponse, Uri, string, string, MobileConnectRequestOptions)"/> /// </summary> /// <param name="discoveryResponse">The response returned by the discovery process</param> /// <param name="redirectedUrl">Uri redirected to by the completion of the authorization UI</param> /// <param name="expectedState">The state value returned from the StartAuthorization call should be passed here, it will be used to validate the authenticity of the authorization process</param> /// <param name="expectedNonce">The nonce value returned from the StartAuthorization call should be passed here, it will be used to ensure the token was not requested using a replay attack</param> /// <param name="options">Optional parameters</param> /// <returns>MobileConnectStatus object with required information for continuing the mobileconnect process</returns> public MobileConnectStatus RequestToken( DiscoveryResponse discoveryResponse, Uri redirectedUrl, string expectedState, string expectedNonce, MobileConnectRequestOptions options, string version) { return(MobileConnectInterfaceHelper.RequestToken( _authentication, _jwks, discoveryResponse, redirectedUrl, expectedState, expectedNonce, _config, options, version).Result); }
/// <summary> /// Request token using the values returned from the authorization redirect /// </summary> /// <param name="request">Originating web request</param> /// <param name="discoveryResponse">The response returned by the discovery process</param> /// <param name="redirectedUrl">Uri redirected to by the completion of the authorization UI</param> /// <param name="expectedState">The state value returned from the StartAuthorization call should be passed here, it will be used to validate the authenticity of the authorization process</param> /// <param name="expectedNonce">The nonce value returned from the StartAuthorization call should be passed here, it will be used to ensure the token was not requested using a replay attack</param> /// <param name="options">Optional parameters</param> /// <returns>MobileConnectStatus object with required information for continuing the mobileconnect process</returns> public async Task <MobileConnectStatus> RequestTokenAsync( HttpRequestMessage request, DiscoveryResponse discoveryResponse, Uri redirectedUrl, string expectedState, string expectedNonce, MobileConnectRequestOptions options, string version) { return(await MobileConnectInterfaceHelper.RequestToken( _authentication, _jwks, discoveryResponse, redirectedUrl, expectedState, expectedNonce, _config, options, version)); }
/// <summary> /// Synchronous wrapper for <see cref="MobileConnectInterface.HandleUrlRedirectAsync(Uri, DiscoveryResponse, string, string, MobileConnectRequestOptions)"/> /// </summary> /// <param name="redirectedUrl">Url redirected to by the completion of the previous step</param> /// <param name="discoveryResponse">The response returned by the discovery process</param> /// <param name="expectedState">The state value returned from the StartAuthorization call should be passed here, it will be used to validate the authenticity of the authorization process</param> /// <param name="expectedNonce">The nonce value returned from the StartAuthorization call should be passed here, it will be used to ensure the token was not requested using a replay attack</param> /// <param name="options">Optional parameters</param> /// <returns>MobileConnectStatus object with required information for continuing the mobileconnect process</returns> public MobileConnectStatus HandleUrlRedirect( Uri redirectedUrl, DiscoveryResponse discoveryResponse = null, string expectedState = null, string expectedNonce = null, MobileConnectRequestOptions options = null, string version = null) { return(MobileConnectInterfaceHelper.HandleUrlRedirect( _discovery, _authentication, _jwks, redirectedUrl, discoveryResponse, expectedState, expectedNonce, _config, options, version).Result); }
/// <summary> /// Handles continuation of the process following a completed redirect, the request token url must be provided if it has been returned by the discovery process. /// Only the request and redirectedUrl are required, however if the redirect being handled is the result of calling the Authorization URL then the remaining parameters are required. /// </summary> /// <param name="request">Originating web request</param> /// <param name="redirectedUrl">Url redirected to by the completion of the previous step</param> /// <param name="discoveryResponse">The response returned by the discovery process</param> /// <param name="expectedState">The state value returned from the StartAuthorization call should be passed here, it will be used to validate the authenticity of the authorization process</param> /// <param name="expectedNonce">The nonce value returned from the StartAuthorization call should be passed here, it will be used to ensure the token was not requested using a replay attack</param> /// <param name="options">Optional parameters</param> /// <returns>MobileConnectStatus object with required information for continuing the mobileconnect process</returns> public async Task <MobileConnectStatus> HandleUrlRedirectAsync( HttpRequestMessage request, Uri redirectedUrl, DiscoveryResponse discoveryResponse = null, string expectedState = null, string expectedNonce = null, MobileConnectRequestOptions options = null, string version = null) { return(await CacheIfRequired( await MobileConnectInterfaceHelper.HandleUrlRedirect( _discovery, _authentication, _jwks, redirectedUrl, discoveryResponse, expectedState, expectedNonce, _config, options, version))); }
/// <summary> /// Synchronous wrapper for <see cref="RevokeTokenAsync(string, string, DiscoveryResponse)"/> /// </summary> /// <param name="token">Access/Refresh token returned from RequestToken request</param> /// <param name="tokenTypeHint">Hint to indicate the type of token being passed in</param> /// <param name="discoveryResponse">The response returned by the discovery process</param> /// <returns>Object with required information for continuing the mobile connect process</returns> public MobileConnectStatus RevokeToken( string token, string tokenTypeHint, DiscoveryResponse discoveryResponse) { return(MobileConnectInterfaceHelper.RevokeToken( _authentication, token, tokenTypeHint, discoveryResponse, _config).Result); }
/// <summary> /// Synchronous wrapper for <see cref="RefreshTokenAsync(string, DiscoveryResponse)"/> /// </summary> /// <param name="refreshToken">Refresh token returned from RefreshToken request</param> /// <param name="discoveryResponse">The response returned by the discovery process</param> /// <returns>Object with required information for continuing the mobile connect process</returns> public MobileConnectStatus RefreshToken(string refreshToken, DiscoveryResponse discoveryResponse) { return(MobileConnectInterfaceHelper.RefreshToken( _authentication, refreshToken, discoveryResponse, _config).Result); }
/// <summary> /// Revoke token using using the access / refresh token provided in the RequestToken response /// </summary> /// <param name="token">Access/Refresh token returned from RequestToken request</param> /// <param name="tokenTypeHint">Hint to indicate the type of token being passed in</param> /// <param name="discoveryResponse">The response returned by the discovery process</param> /// <returns>Object with required information for continuing the mobile connect process</returns> public async Task <MobileConnectStatus> RevokeTokenAsync( string token, string tokenTypeHint, DiscoveryResponse discoveryResponse) { return(await MobileConnectInterfaceHelper.RevokeToken( _authentication, token, tokenTypeHint, discoveryResponse, _config)); }
/// <summary> /// Request user info using the access token returned by <see cref="RequestTokenAsync(DiscoveryResponse, Uri, string, string, MobileConnectRequestOptions)"/> /// </summary> /// <param name="discoveryResponse">The response returned by the discovery process</param> /// <param name="accessToken">Access token from RequestToken stage</param> /// <param name="options">Additional optional parameters</param> /// <returns>MobileConnectStatus object with UserInfo information</returns> public async Task <MobileConnectStatus> RequestIdentityAsync(DiscoveryResponse discoveryResponse, string accessToken, MobileConnectRequestOptions options) { return(await MobileConnectInterfaceHelper.RequestIdentity(_identity, discoveryResponse, accessToken, _config, options)); }
/// <summary> /// Synchronous wrapper for <see cref="MobileConnectInterface.HandleUrlRedirectAsync(Uri, DiscoveryResponse, string, string)"/> /// </summary> /// <param name="redirectedUrl">Url redirected to by the completion of the previous step</param> /// <param name="discoveryResponse">The response returned by the discovery process</param> /// <param name="expectedState">The state value returned from the StartAuthorization call should be passed here, it will be used to validate the authenticity of the authorization process</param> /// <param name="expectedNonce">The nonce value returned from the StartAuthorization call should be passed here, it will be used to ensure the token was not requested using a replay attack</param> /// <param name="requestTokenUrl">Url for token request, this is returned by the discovery process. An error status will be returned if the redirected url triggers a token request and this parameter has not been provided.</param> /// <returns>MobileConnectStatus object with required information for continuing the mobileconnect process</returns> public MobileConnectStatus HandleUrlRedirect(Uri redirectedUrl, DiscoveryResponse discoveryResponse = null, string expectedState = null, string expectedNonce = null, string requestTokenUrl = null) { return(MobileConnectInterfaceHelper.HandleUrlRedirect(_discovery, _authentication, redirectedUrl, discoveryResponse, expectedState, expectedNonce, _config).Result); }
/// <summary> /// Attempt discovery using the values returned from the operator selection redirect /// </summary> /// <param name="redirectedUrl">Uri redirected to by the completion of the operator selection UI</param> /// <returns>MobileConnectStatus object with required information for continuing the mobileconnect process</returns> public async Task <MobileConnectStatus> AttemptDiscoveryAfterOperatorSelectionAsync(Uri redirectedUrl) { return(await MobileConnectInterfaceHelper.AttemptDiscoveryAfterOperatorSelection( _discovery, redirectedUrl, _config)); }
/// <summary> /// Attempt manually discovery using the supplied parameters. /// </summary> /// <param name="response">Discovery response</param> /// <returns></returns> public MobileConnectStatus AttemptManuallyDiscovery(DiscoveryResponse response) { return(MobileConnectInterfaceHelper.GenerateStatusFromDiscoveryResponse(_discovery, response)); }
/// <summary> /// Generate Status From Discovery Response /// </summary> /// <param name="discoveryResponse"></param> /// <returns></returns> public async Task <MobileConnectStatus> GenerateStatusFromDiscoveryResponse(DiscoveryResponse discoveryResponse) { return(await CacheIfRequired( MobileConnectInterfaceHelper.GenerateStatusFromDiscoveryResponse(_discovery, discoveryResponse))); }
/// <summary> /// Handles continuation of the process following a completed redirect. /// Only the redirectedUrl is required, however if the redirect being handled is the result of calling the Authorization URL then the remaining parameters are required. /// </summary> /// <param name="redirectedUrl">Url redirected to by the completion of the previous step</param> /// <param name="discoveryResponse">The response returned by the discovery process</param> /// <param name="expectedState">The state value returned from the StartAuthorization call should be passed here, it will be used to validate the authenticity of the authorization process</param> /// <param name="expectedNonce">The nonce value returned from the StartAuthorization call should be passed here, it will be used to ensure the token was not requested using a replay attack</param> /// <returns>MobileConnectStatus object with required information for continuing the mobileconnect process</returns> public async Task <MobileConnectStatus> HandleUrlRedirectAsync(Uri redirectedUrl, DiscoveryResponse discoveryResponse = null, string expectedState = null, string expectedNonce = null) { return(await MobileConnectInterfaceHelper.HandleUrlRedirect(_discovery, _authentication, redirectedUrl, discoveryResponse, expectedState, expectedNonce, _config)); }
/// <summary> /// Syncronous wrapper for <see cref="RequestPremiumInfoAsync"/> /// </summary> /// <param name="discoveryResponse">The response returned by the discovery process</param> /// <param name="accessToken">Access token from RequestToken stage</param> /// <param name="options">Additional optional parameters</param> /// <returns>MobileConnectStatus object with UserInfo information</returns> public MobileConnectStatus RequestPremiumInfo( DiscoveryResponse discoveryResponse, string accessToken, MobileConnectRequestOptions options) { return(MobileConnectInterfaceHelper.RequestPremiumInfo( _identity, discoveryResponse, accessToken, _config, options).Result); }
/// <summary> /// Attempt discovery using the supplied parameters. If msisdn, mcc and mnc are null the result will be /// operator selection, otherwise valid parameters will result in a StartAuthorization status /// </summary> /// <param name="msisdn">MSISDN from user</param> /// <param name="mcc">Mobile Country Code</param> /// <param name="mnc">Mobile Network Code</param> /// <param name="options">Optional parameters</param> /// <returns>MobileConnectStatus object with required information for continuing the mobileconnect process</returns> public async Task <MobileConnectStatus> AttemptDiscoveryAsync( string msisdn, string mcc, string mnc, MobileConnectRequestOptions options) { return(await MobileConnectInterfaceHelper.AttemptDiscovery( _discovery, msisdn, mcc, mnc, null, _config, options)); }
/// <summary> /// Request token using the values returned from the authorization redirect /// </summary> /// <param name="discoveryResponse">The response returned by the discovery process</param> /// <param name="redirectedUrl">Uri redirected to by the completion of the authorization UI</param> /// <param name="expectedState">The state value returned from the StartAuthorization call should be passed here, it will be used to validate the authenticity of the authorization process</param> /// <param name="expectedNonce">The nonce value returned from the StartAuthorization call should be passed here, it will be used to ensure the token was not requested using a replay attack</param> /// <returns>MobileConnectStatus object with required information for continuing the mobileconnect process</returns> public async Task <MobileConnectStatus> RequestTokenAsync(DiscoveryResponse discoveryResponse, Uri redirectedUrl, string expectedState, string expectedNonce) { return(await MobileConnectInterfaceHelper.RequestToken(_authentication, discoveryResponse, redirectedUrl, expectedState, expectedNonce, _config)); }