public async Task <TResult> CreateAsync <TResult>(Guid authenticationRequestId, string method, AuthenticationActions action, Guid actorLinkId, string token, Uri redirectUrl, Uri redirectLogoutUrl, Func <TResult> onSuccess, Func <TResult> onAlreadyExists) { var doc = new Documents.AuthenticationRequestDocument { Method = method, Action = Enum.GetName(typeof(AuthenticationActions), action), LinkedAuthenticationId = actorLinkId, Token = token, RedirectUrl = redirectUrl.IsDefault() ? default(string) : redirectUrl.AbsoluteUri, RedirectLogoutUrl = redirectLogoutUrl.IsDefault() ? default(string) : redirectLogoutUrl.AbsoluteUri, }; return(await this.repository.CreateAsync(authenticationRequestId, doc, () => onSuccess(), () => onAlreadyExists())); }
public AuthenticationInput(string userName, string password, AuthenticationActions action, bool saveCredentials = false) { this.UserName = userName; this.Password = password; this.Action = action; this.SaveCredentials = saveCredentials; this.UserService = null; }
public AuthenticationInput(UserService userService, AuthenticationActions action) { this.UserName = String.Empty; this.Password = String.Empty; this.Action = action; this.SaveCredentials = false; this.UserService = userService; }
public virtual async Task <TResult> GetRedirectUriAsync <TResult>(Context context, CredentialValidationMethodTypes validationType, AuthenticationActions action, Guid requestId, Guid?authorizationId, string token, string refreshToken, IDictionary <string, string> authParams, Uri redirectUriFromPost, Func <Uri, TResult> onSuccess, Func <string, string, TResult> onInvalidParameter, Func <string, TResult> onFailure) { if (!redirectUriFromPost.IsDefault()) { var redirectUrl = SetRedirectParameters(redirectUriFromPost, requestId, authorizationId, token, refreshToken); return(onSuccess(redirectUrl)); } if (null != authParams && authParams.ContainsKey(Configuration.AuthorizationParameters.RedirectUri)) { Uri redirectUri; var redirectUriString = authParams[Configuration.AuthorizationParameters.RedirectUri]; if (!Uri.TryCreate(redirectUriString, UriKind.Absolute, out redirectUri)) { return(onInvalidParameter("REDIRECT", $"BAD URL in redirect call:{redirectUriString}")); } var redirectUrl = SetRedirectParameters(redirectUri, requestId, authorizationId, token, refreshToken); return(onSuccess(redirectUrl)); } return(await EastFive.Web.Configuration.Settings.GetUri( EastFive.Security.SessionServer.Configuration.AppSettings.LandingPage, (redirectUri) => { var redirectUrl = SetRedirectParameters(redirectUri, requestId, authorizationId, token, refreshToken); return onSuccess(redirectUrl); }, (why) => onFailure(why)).ToTask()); }
public static async Task <TResult> CreateResponse <TResult>(AzureApplication application, IProvideAuthorization authorizationProvider, string method, AuthenticationActions action, Guid sessionId, Guid?authorizationId, string jwtToken, string refreshToken, IDictionary <string, string> extraParams, Uri baseUri, Uri redirectUrl, Func <Uri, string, TResult> onRedirect, Func <HttpStatusCode, string, string, TResult> onResponse, TelemetryClient telemetry) { throw new NotImplementedException(); //var redirectResponse = await application.GetRedirectUriAsync(authorizationProvider, // method, action, // sessionId, authorizationId, jwtToken, refreshToken, extraParams, // baseUri, // redirectUrl, // (redirectUrlSelected) => // { // telemetry.TrackEvent($"CreateResponse - redirectUrlSelected1: {redirectUrlSelected.AbsolutePath}"); // telemetry.TrackEvent($"CreateResponse - redirectUrlSelected2: {redirectUrlSelected.AbsoluteUri}"); // return onRedirect(redirectUrlSelected, null); // }, // (paramName, why) => // { // var message = $"Invalid parameter while completing login: {paramName} - {why}"; // telemetry.TrackException(new ResponseException(message)); // return onResponse(HttpStatusCode.BadRequest, message, why); // }, // (why) => // { // var message = $"General failure while completing login: {why}"; // telemetry.TrackException(new ResponseException(message)); // return onResponse(HttpStatusCode.BadRequest, message, why); // }); //var msg = redirectResponse; //telemetry.TrackEvent($"CreateResponse - {msg}"); //return redirectResponse; }
private async Task <IHttpActionResult> CreateResponse(Context context, CredentialValidationMethodTypes method, AuthenticationActions action, Guid sessionId, Guid?authorizationId, string jwtToken, string refreshToken, IDictionary <string, string> extraParams, Uri redirectUrl, TelemetryClient telemetry) { var config = Library.configurationManager; var redirectResponse = await config.GetRedirectUriAsync(context, method, action, sessionId, authorizationId, jwtToken, refreshToken, extraParams, redirectUrl, (redirectUrlSelected) => { telemetry.TrackEvent($"CreateResponse - redirectUrlSelected1: {redirectUrlSelected.AbsolutePath}"); telemetry.TrackEvent($"CreateResponse - redirectUrlSelected2: {redirectUrlSelected.AbsoluteUri}"); return(Redirect(redirectUrlSelected)); }, (paramName, why) => { var message = $"Invalid parameter while completing login: {paramName} - {why}"; telemetry.TrackException(new ResponseException(message)); return(Request.CreateResponse(HttpStatusCode.BadRequest, message) .AddReason(why) .ToActionResult()); }, (why) => { var message = $"General failure while completing login: {why}"; telemetry.TrackException(new ResponseException(message)); return(Request.CreateResponse(HttpStatusCode.BadRequest, message) .AddReason(why) .ToActionResult()); }); var msg = redirectResponse; telemetry.TrackEvent($"CreateResponse - {msg}"); return(redirectResponse); }
private async static Task <Session> Convert( Guid authenticationRequestStorageId, string method, string name, IProvideLogin provider, AuthenticationActions action, string token, Guid authorizationId, Uri loginUrl, Uri redirect, IDictionary <string, string> extraParams, IDictionary <string, string> labels, IDictionary <string, Type> types, IDictionary <string, string> descriptions) { var keys = labels.SelectKeys().Concat(types.SelectKeys()).Concat(descriptions.SelectKeys()); var userParams = keys .Distinct() .Select( key => { var val = default(string); if (null != extraParams) { val = extraParams.ContainsKey(key) ? extraParams[key] : default(string); } return((new CustomParameter { Value = val, Type = types.ContainsKey(key) ? types[key] : default(Type), Label = labels.ContainsKey(key) ? labels[key] : default(string), Description = descriptions.ContainsKey(key) ? descriptions[key] : default(string), }).PairWithKey(key)); }) .ToDictionary(); var resourceTypes = await ServiceConfiguration.IntegrationResourceTypesAsync(authenticationRequestStorageId, (resourceTypesInner) => resourceTypesInner, () => new string[] { }); var computedName = !string.IsNullOrWhiteSpace(name) ? name : provider is IProvideIntegration integrationProvider?integrationProvider.GetDefaultName(extraParams) : method; return(new Session { id = authenticationRequestStorageId, method = method, name = computedName, action = action, token = token, authorizationId = authorizationId, redirectUrl = redirect, loginUrl = loginUrl, userParams = userParams, resourceTypes = resourceTypes .Select(resourceType => resourceType.PairWithValue(resourceType)) .ToDictionary(), }); }
public Task <TResult> CreatedAuthenticationLoginAsync <TResult>(Guid requestId, AzureApplication application, Guid sessionId, Guid authorizationId, string token, string refreshToken, string method, AuthenticationActions action, IProvideAuthorization provider, IDictionary <string, string> extraParams, Uri redirectUrl, Func <Task <TResult> > onContinue, Func <string, TResult> onStop) { return(onContinue()); }
public async Task <TResult> CreatedAuthenticationLoginAsync <TResult>(AzureApplication application, Guid sessionId, Guid authorizationId, string token, string refreshToken, string method, AuthenticationActions action, IProvideAuthorization provider, IDictionary <string, string> extraParams, Uri redirectUrl, Func <Task <TResult> > onContinue, Func <string, TResult> onStop) { //var updatingAuthLogTask = saveAuthLogAsync(true, $"Login:{authorizationId}/{sessionId}[{action}]", extraParams); application.Telemetry.TrackEvent($"ResponseController.ProcessRequestAsync - Created Authentication. Creating response."); var resp = onContinue(); //await updatingAuthLogTask; return(await resp); }
public async Task <TResult> CreatedAuthenticationLoginAsync <TResult>(Guid requestId, AzureApplication application, Guid sessionId, Guid authorizationId, string token, string refreshToken, string method, AuthenticationActions action, IProvideAuthorization provider, IDictionary <string, string> extraParams, Uri redirectUrl, Func <Task <TResult> > onContinue, Func <string, TResult> onStop) { var loggingTask = CredentialProcessDocument.UpdateAsync(requestId, async(doc, saveAsync) => { doc.Message = "AUTHENTICATED"; doc.SessionId = sessionId; doc.AuthorizationId = authorizationId; doc.Token = token; doc.RefreshToken = refreshToken; doc.Action = Enum.GetName(typeof(AuthenticationActions), action); doc.Provider = provider.GetType().FullName; doc.SetValuesCredential(extraParams); doc.RedirectUrl = redirectUrl.IsDefaultOrNull() ? string.Empty : redirectUrl.ToString(); await saveAsync(doc); return(true); }, application.AzureContext.DataContext.AzureStorageRepository); var resp = await onContinue(); bool b = await loggingTask; return(resp); }