public static async Task <InvocationMessage> SendAsync <TResource>(this Task <InvocationMessage> invocationMessageTask, AzureApplication application = default) { var invocationMessage = await invocationMessageTask; var byteContent = invocationMessage.invocationRef.id.ToByteArray(); AzureApplication GetApplication() { if (!application.IsDefaultOrNull()) { return(application); } var app = new AzureApplication(); app.ApplicationStart(); return(app); } var applicationValid = GetApplication(); return(await EastFive.Web.Configuration.Settings.GetString( AppSettings.FunctionProcessorQueueTriggerName, async (queueTriggerName) => { await applicationValid.SendQueueMessageAsync(queueTriggerName, byteContent); return invocationMessage; }, (why) => throw new Exception(why))); }
public static async Task <HttpResponseMessage> PostAsync( [Property(Name = id_token)] string idToken, [Property(Name = state)] IRef <Authorization> authorization, AzureApplication application, UrlHelper urlHelper, HttpRequestMessage request, RedirectResponse onRedirectResponse, ServiceUnavailableResponse onNoServiceResponse, BadRequestResponse onBadCredentials, GeneralConflictResponse onFailure) { var parameters = new Dictionary <string, string> { { id_token, idToken }, { state, authorization.id.ToString("N") }, }; var authentication = await EastFive.Azure.Auth.Method.ByMethodName( AzureADB2CProvider.IntegrationName, application); return(await EastFive.Azure.Auth.Redirection.ProcessRequestAsync(authentication, parameters, application, request, urlHelper, (redirect) => onRedirectResponse(redirect), (why) => onBadCredentials().AddReason($"Bad credentials:{why}"), (why) => onNoServiceResponse().AddReason(why), (why) => onFailure(why))); }
public static async Task <InvocationMessage> FunctionAsync(this HttpRequestMessage request, AzureApplication application = default) { var invocationMessage = await request.InvocationMessageAsync(); var invocationMessageRef = invocationMessage.invocationRef; return(await await invocationMessage.StorageCreateAsync( async (created) => { var byteContent = invocationMessageRef.id.ToByteArray(); AzureApplication GetApplication() { if (!application.IsDefaultOrNull()) { return application; } var app = new AzureApplication(); app.ApplicationStart(); return app; } var applicationValid = GetApplication(); return await EastFive.Web.Configuration.Settings.GetString( AppSettings.FunctionProcessorQueueTriggerName, async(queueTriggerName) => { await applicationValid.SendQueueMessageAsync(queueTriggerName, byteContent); return invocationMessage; }, (why) => throw new Exception(why)); }, () => throw new Exception())); }
public async Task <TResult> CreatedAuthenticationLogoutAsync <TResult>(Guid requestId, AzureApplication application, string reason, string method, 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 = "LOGOUT"; doc.Action = Enum.GetName(typeof(AuthenticationActions), AuthenticationActions.signin); 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); }
public static async Task <HttpResponseMessage> GetAllSecureAsync( [QueryParameter(Name = "ApiKeySecurity")] string apiSecurityKey, [QueryParameter(Name = "authorization")] IRef <Authorization> authorizationRef, ApiSecurity apiSecurity, AzureApplication application, HttpRequestMessage request, MultipartResponseAsync <Authorization> onContent, RedirectResponse onSuccess, NotFoundResponse onNotFound, ForbiddenResponse onFailure) { return(await await authorizationRef.StorageGetAsync( async authorization => { return await await Method.ById(authorization.Method, application, async method => { return await await method.ParseTokenAsync(authorization.parameters, application, (externalId, loginProvider) => { return Auth.Redirection.ProcessAsync(authorization, async updatedAuth => { }, method, externalId, authorization.parameters, Guid.NewGuid(), request.RequestUri, application, loginProvider, (uri) => onSuccess(uri), (why) => onFailure().AddReason(why), application.Telemetry); }, why => onFailure().AddReason(why).AsTask()); }, () => onFailure().AddReason("Method no longer supported").AsTask()); }, () => onNotFound().AsTask())); }
internal static Resources.ProcessResourceView GetResource( EastFive.Azure.ProcessResourceView view, AzureApplication application, IProvideUrl url) { return(new Resources.ProcessResourceView { Id = url.GetWebId <ProcessResourceView>(view.processViewId), //Actor = application.GetActorLink(view.actorId, url), //Resource = application.GetResourceLink(view.resourceType, view.resourceId, url), ResourceType = application.GetResourceMime(view.resourceType), CurrentProcessStep = url.GetWebId <ProcessStep>(view.currentProcessStepId), Titles = view.titles, Completions = view.completions, Invalidations = view.invalidations, ResourcesDisplayed = view.displayResources, ResourcesProvided = view.resourcesProvided .Select( resourceProvided => new Resources.ProcessResourceView.ConfirmableResource { Key = resourceProvided.key, //Resource = application.GetResourceLink(resourceProvided.type, resourceProvided.resourceId, url), Type = application.GetResourceMime(resourceProvided.type), }) .ToArray(), NextStages = view.nextStages .Select(nextStageId => url.GetWebId <Resources.ProcessStage>(nextStageId.processStageId)) .ToArray(), Editable = view.editable, Completable = view.completable, }); }
public static InvokeTestApplication Init() { var application = new AzureApplication(); var tokenSource = new CancellationTokenSource(); return(Init(application, tokenSource.Token)); }
private static Task <TResult> CreateLoginResponseAsync <TResult>(Guid requestId, Guid?accountId, IDictionary <string, string> extraParams, Method method, Authorization authorization, Uri baseUri, AzureApplication application, IProvideAuthorization authorizationProvider, Func <Uri, TResult> onRedirect, Func <string, TResult> onBadResponse, TelemetryClient telemetry) { return(application.GetRedirectUriAsync(requestId, accountId, extraParams, method, authorization, baseUri, authorizationProvider, (redirectUrlSelected) => { telemetry.TrackEvent($"CreateResponse - redirectUrlSelected1: {redirectUrlSelected.AbsolutePath}"); telemetry.TrackEvent($"CreateResponse - redirectUrlSelected2: {redirectUrlSelected.AbsoluteUri}"); return onRedirect(redirectUrlSelected); }, (paramName, why) => { var message = $"Invalid parameter while completing login: {paramName} - {why}"; telemetry.TrackException(new ResponseException(message)); return onBadResponse(message); }, (why) => { var message = $"General failure while completing login: {why}"; telemetry.TrackException(new ResponseException(message)); return onBadResponse(message); })); }
public static IHttpResponse Options(IHttpRequest request, IProvideUrl url, AzureApplication application, ContentResponse onOption) { return(onOption( GetResource( new EastFive.Azure.Process() { processStageId = Guid.NewGuid(), createdOn = DateTime.UtcNow, processId = Guid.NewGuid(), resourceId = Guid.NewGuid(), resourceType = typeof(EastFive.Azure.ProcessStage), confirmedBy = Guid.NewGuid(), confirmedWhen = DateTime.UtcNow, previousStep = Guid.NewGuid(), resources = Enumerable .Range(0, 3) .Select( i => new EastFive.Azure.Process.ProcessStageResource() { key = $"key{i}", resourceId = Guid.NewGuid(), type = typeof(EastFive.Azure.Process), }) .ToArray(), }, application, url))); }
public async static Task <HttpResponseMessage> QueryByActorId( [QueryParameter(Name = ActorPropertyName)] Guid actorId, Context context, AzureApplication application, EastFive.Api.SessionToken security, UrlHelper urlHelper, ContentResponse onFound, MultipartResponseAsync onFounds, ReferencedDocumentNotFoundResponse onNotFound, UnauthorizedResponse onUnauthorized, ServiceUnavailableResponse onServiceUnavailable) { return(await await context.PasswordCredentials.GetPasswordCredentialByActorAsync( actorId, security, application, (credentials) => { var credentialResources = credentials .Select( passwordCredential => { var resource = Convert(passwordCredential, urlHelper); var response = onFound(resource); return response; }) .ToArray(); return onFounds(credentialResources); }, () => onNotFound().AsTask(), () => onUnauthorized().AsTask(), (why) => onServiceUnavailable().AsTask())); }
public Task <TResult> CredentialValidation <TResult>(Guid requestId, AzureApplication application, IRef <EastFive.Azure.Auth.Method> method, IDictionary <string, string> values, Func <Task <TResult> > onContinue, Func <string, TResult> onStop) { return(onContinue()); }
public static InvokeTestApplication Init(AzureApplication application, CancellationToken token) { var hostingLocation = Web.Configuration.Settings.GetUri( AppSettings.ServerUrl, (hostingLocationFound) => hostingLocationFound, (whyUnspecifiedOrInvalid) => new Uri("http://example.com")); return(new InvokeTestApplication(application, hostingLocation, "api", token)); }
public Task <TResult> CredentialUnmappedAsync <TResult>(Guid requestId, AzureApplication application, string subject, string method, IProvideAuthorization credentialProvider, IDictionary <string, string> extraParams, Func <Guid, Func <Guid, string, string, AuthenticationActions, Uri, Task <Task <TResult> > >, Func <string, Task <TResult> >, Task <Task <TResult> > > createMappingAsync, Func < Func <Guid, Func <Guid, string, string, AuthenticationActions, Uri, Task <Task <TResult> > >, Func <string, Task <TResult> >, Task <Task <TResult> > >, Task <TResult> > onContinue, Func <string, TResult> onStop) { return(CredentialProcessDocument.UpdateAsync(requestId, async(doc, saveAsync) => { doc.Message = "CREDENTIAL LOOKUP NOT FOUND"; doc.Provider = credentialProvider.GetType().FullName; doc.SetValuesCredential(extraParams); await saveAsync(doc); Func <Guid, Func <Guid, string, string, AuthenticationActions, Uri, Task <Task <TResult> > >, Func <string, Task <TResult> >, Task <Task <TResult> > > createMappingWrappedAsync = async(authorizationId, onCreated, onFailure) => { doc.AuthorizationId = authorizationId; Func <Guid, string, string, AuthenticationActions, Uri, Task <Task <TResult> > > onCreateWrapped = async(sessionId, token, refreshToken, action, redirectUrl) => { doc.Message = "LOOKUP CREATED"; doc.SessionId = sessionId; doc.Token = token; doc.RefreshToken = refreshToken; doc.Action = Enum.GetName(typeof(AuthenticationActions), action); doc.RedirectUrl = redirectUrl.IsDefaultOrNull() ? string.Empty : redirectUrl.ToString(); await saveAsync(doc); return await onCreated(sessionId, token, refreshToken, action, redirectUrl); }; Func <string, Task <TResult> > onFailureWrapped = async(why) => { doc.Message = $"LOOKUP CREATION FAILURE:{why}"; await saveAsync(doc); return await onFailure(why); }; return await createMappingAsync(authorizationId, onCreateWrapped, onFailureWrapped); }; var resp = await onContinue(createMappingWrappedAsync); return resp; }, application.AzureContext.DataContext.AzureStorageRepository)); }
public Task <TResult> CredentialUnmappedAsync <TResult>(Guid requestId, AzureApplication application, string subject, string method, IProvideAuthorization credentialProvider, IDictionary <string, string> extraParams, Func <Guid, Func <Guid, string, string, AuthenticationActions, Uri, Task <Task <TResult> > >, Func <string, Task <TResult> >, Task <Task <TResult> > > createMappingAsync, Func <Func <Guid, Func <Guid, string, string, AuthenticationActions, Uri, Task <Task <TResult> > >, Func <string, Task <TResult> >, Task <Task <TResult> > >, Task <TResult> > onContinue, Func <string, TResult> onStop) { return(onContinue(createMappingAsync)); }
public Task <TResult> CreatedAuthenticationLogoutAsync <TResult>(AzureApplication application, string reason, string method, IProvideAuthorization provider, IDictionary <string, string> extraParams, Uri redirectUrl, Func <Task <TResult> > onContinue, Func <string, TResult> onStop) { //await saveAuthLogAsync(true, $"Logout:{location} -- {reason}", extraParams); application.Telemetry.TrackEvent($"ResponseController.ProcessRequestAsync - location: {redirectUrl.AbsolutePath}"); return(onContinue()); }
public static async Task <IHttpResponse> DeleteAsync( [UpdateId(Name = AuthorizationIdPropertyName)] IRef <Authorization> authorizationRef, IProvideUrl urlHelper, AzureApplication application, NoContentResponse onLogoutComplete, AcceptedBodyResponse onExternalSessionActive, NotFoundResponse onNotFound, GeneralFailureResponse onFailure) { return(await authorizationRef.StorageUpdateAsync( async (authorizationToDelete, updateAsync) => { authorizationToDelete.deleted = DateTime.UtcNow; if (!authorizationToDelete.authorized) { return onLogoutComplete().AddReason("Deleted"); } var locationLogout = await await Auth.Method.ById(authorizationToDelete.Method, application, (authentication) => { return authentication.GetLogoutUrlAsync( application, urlHelper, authorizationRef.id); }, () => default(Uri).AsTask()); authorizationToDelete.LocationLogout = locationLogout; await updateAsync(authorizationToDelete); bool NoRedirectRequired() { if (locationLogout.IsDefaultOrNull()) { return true; } if (!locationLogout.IsAbsoluteUri) { return true; } if (locationLogout.AbsoluteUri.IsNullOrWhiteSpace()) { return true; } return false; } if (NoRedirectRequired()) { return onLogoutComplete().AddReason("Logout Complete"); } return onExternalSessionActive(authorizationToDelete, "application/json") .AddReason($"External session removal required:{locationLogout.AbsoluteUri}"); }, () => onNotFound())); }
public static IHttpResponse Options(AzureApplication application, IProvideUrl url, ContentResponse onOption) { return(onOption( GetResource( new EastFive.Azure.ProcessResourceView() { processViewId = Guid.NewGuid(), actorId = Guid.NewGuid(), resourceId = Guid.NewGuid(), resourceType = typeof(EastFive.Azure.Process), currentProcessStepId = Guid.NewGuid(), titles = new string[] { "Step 1", "Step 2", "Step 1", "Step 3" }, completions = new DateTime?[] { DateTime.UtcNow - TimeSpan.FromDays(4.0), default(DateTime?), DateTime.UtcNow - TimeSpan.FromDays(2.0), DateTime.UtcNow - TimeSpan.FromDays(1.0), }, invalidations = new DateTime?[] { default(DateTime?), DateTime.UtcNow - TimeSpan.FromDays(3.0), default(DateTime?), default(DateTime?), }, displayResources = new string[] { "process", "process" }, resourcesProvided = new EastFive.Azure.Process.ProcessStageResource[] { new EastFive.Azure.Process.ProcessStageResource { }, new EastFive.Azure.Process.ProcessStageResource { }, }, nextStages = new EastFive.Azure.ProcessStage[] { new EastFive.Azure.ProcessStage { processStageId = Guid.NewGuid(), } }, editable = true, completable = true, }, application, url))); }
public static async Task <IHttpResponse> QueueUpBackupPartitions( [Property(Name = IdPropertyName)] IRef <RepositoryBackup> repositoryBackupRef, [Property(Name = StorageSettingCopyFromPropertyName)] string storageSettingCopyFrom, [Property(Name = StorageSettingCopyToPropertyName)] string storageSettingCopyTo, [Resource] RepositoryBackup repositoryBackup, AzureApplication application, EastFive.Api.Security security, RequestMessage <TableBackup> requestQuery, IHttpRequest request, EastFive.Analytics.ILogger logger, MultipartAsyncResponse <InvocationMessage> onQueued, AlreadyExistsResponse onAlreadyExists) { CloudStorageAccount account = CloudStorageAccount .Parse(storageSettingCopyFrom); CloudTableClient tableClient = new CloudTableClient(account.TableEndpoint, account.Credentials); return(await repositoryBackup.StorageCreateAsync( (discard) => { var includedTables = BackupFunction.DiscoverStorageResources() .Where(x => x.message.Any()) .Select(x => x.tableName) .ToArray(); var resourceInfoToProcess = tableClient.GetTables() .Where(table => includedTables.Contains(table.Name, StringComparer.OrdinalIgnoreCase)) .Distinct() .Select( async cloudTable => { var tableBackup = new TableBackup() { tableBackupRef = Ref <TableBackup> .NewRef(), backup = repositoryBackupRef, tableName = cloudTable.Name, when = DateTime.UtcNow, }; var invocationMessage = await requestQuery .HttpPost(tableBackup) .CompileRequest(request) .FunctionAsync(); logger.Trace($"Invocation[{invocationMessage.id}] will backup table `{tableBackup.tableName}`."); return invocationMessage; }) .Await(readAhead: 10); return onQueued(resourceInfoToProcess); }, () => onAlreadyExists())); }
public static Task <IHttpResponse> FindByIdAsync( [QueryParameter(CheckFileName = true, Name = ProcessStep.IdPropertyName)] Guid id, AzureApplication httpApplication, EastFive.Api.Security security, IProvideUrl url, ContentResponse onFound, NotFoundResponse onNotFound, UnauthorizedResponse onUnauthorized) { return(EastFive.Azure.Processes.FindByIdAsync(id, security, (process) => onFound(GetResource(process, httpApplication, url)), () => onNotFound(), () => onUnauthorized())); }
public static Task <CloudQueueMessage> SendToQueueAsync(IRefs <InvocationMessage> invocationMessageRef, AzureApplication azureApplication) { var byteContent = invocationMessageRef.ids.Select(id => id.ToByteArray()).SelectMany().ToArray(); return(EastFive.Web.Configuration.Settings.GetString( AppSettings.FunctionProcessorQueueTriggerName, (queueTriggerName) => { return azureApplication.SendQueueMessageAsync(queueTriggerName, byteContent); }, (why) => throw new Exception(why))); }
public async Task <TResult> CredentialUnmappedAsync <TResult>(AzureApplication application, string subject, string method, IProvideAuthorization credentialProvider, IDictionary <string, string> extraParams, Func <Guid, Func <Guid, string, string, AuthenticationActions, Uri, Task <Task <TResult> > >, Func <string, Task <TResult> >, Task <Task <TResult> > > createMappingAsync, Func <TResult> onContinue, Func <string, TResult> onStop) { application.Telemetry.TrackEvent($"ResponseController.ProcessRequestAsync - Token is not connected to a user in this system."); //var updatingAuthLogTask = saveAuthLogAsync(true, $"Login:{subject}/{credentialProvider.GetType().FullName}", extraParams); return(onContinue()); }
public static async Task <HttpResponseMessage> QueueUpBackupPartitions( [Property(Name = IdPropertyName)] IRef <RepositoryBackup> repositoryBackupRef, [Property(Name = StorageSettingCopyFromPropertyName)] string storageSettingCopyFrom, [Property(Name = StorageSettingCopyToPropertyName)] string storageSettingCopyTo, [Resource] RepositoryBackup repositoryBackup, AzureApplication application, RequestMessage <TableBackup> requestQuery, HttpRequestMessage request, EastFive.Analytics.ILogger logger, MultipartResponseAsync <InvocationMessage> onQueued, AlreadyExistsResponse onAlreadyExists) { logger.Trace($"Cleaning backup results"); var repo = AzureTableDriverDynamic.FromStorageString(storageSettingCopyTo); await DeleteAllAsync(GetRepository(storageSettingCopyTo)); CloudStorageAccount account = CloudStorageAccount .Parse(storageSettingCopyFrom); CloudTableClient tableClient = new CloudTableClient(account.TableEndpoint, account.Credentials); return(await await repositoryBackup.StorageCreateAsync( (discard) => { var resourceInfoToProcess = tableClient .ListTables() .Distinct() .Select( async cloudTable => { var tableBackup = new TableBackup() { tableBackupRef = Ref <TableBackup> .NewRef(), backup = repositoryBackupRef, tableName = cloudTable.Name, when = DateTime.UtcNow, }; var invocationMessage = await requestQuery .HttpPost(tableBackup) .CompileRequest(request) .FunctionAsync(); logger.Trace($"Invocation[{invocationMessage.id}] will backup table `{tableBackup.tableName}`."); return invocationMessage; }) .AsyncEnumerable(); return onQueued(resourceInfoToProcess); }, () => onAlreadyExists().AsTask())); }
public static async Task <IHttpResponse> Post( [Property(Name = StatePropertyName)] string state, [PropertyOptional(Name = CodePropertyName)] string code, [Property(Name = TokenPropertyName)] string token, AzureApplication application, IHttpRequest request, IProvideUrl urlHelper, IInvokeApplication endpoints, RedirectResponse onRedirectResponse, BadRequestResponse onBadCredentials, HtmlResponse onCouldNotConnect, HtmlResponse onGeneralFailure) { var method = EastFive.Azure.Auth.Method.ByMethodName( AzureADB2CProvider.IntegrationName, application); var requestParams = request.RequestUri .ParseQuery() .Distinct(kvp => kvp.Key) .ToDictionary(); if (state.HasBlackSpace()) { requestParams.Add(StatePropertyName, state); } if (code.HasBlackSpace()) { requestParams.Add(CodePropertyName, code); } if (token.HasBlackSpace()) { requestParams.Add(TokenPropertyName, token); } return(await ProcessRequestAsync(method, requestParams, application, request, endpoints, urlHelper, (redirect, accountIdMaybe) => { return onRedirectResponse(redirect); }, (why) => onBadCredentials().AddReason(why), (why) => { return onCouldNotConnect(why); }, (why) => { return onGeneralFailure(why); })); }
public static async Task <InvocationMessage> SendAsync(this InvocationMessage invocationMessage) { var byteContent = invocationMessage.invocationRef.id.ToByteArray(); return(await EastFive.Web.Configuration.Settings.GetString( AppSettings.FunctionProcessorServiceBusTriggerName, async (serviceBusTriggerName) => { await AzureApplication.SendServiceBusMessageStaticAsync(serviceBusTriggerName, byteContent.AsEnumerable()); return invocationMessage; }, (why) => throw new Exception(why))); }
//private static Task<TResult> UnmappedCredentialAsync<TResult>( // string subject, IDictionary<string, string> extraParams, // EastFive.Azure.Auth.Method authentication, Authorization authorization, // IProvideAuthorization authorizationProvider, // IAuthApplication application, // Uri baseUri, // Func<Guid, TResult> createMapping, // Func<TResult> onAllowSelfServe, // Func<Uri, TResult> onInterceptProcess, // Func<string, TResult> onFailure, // TelemetryClient telemetry) //{ // return application.OnUnmappedUserAsync(subject, extraParams, // authentication, authorization, authorizationProvider, baseUri, // (accountId) => createMapping(accountId), // () => onAllowSelfServe(), // (callback) => onInterceptProcess(callback), // () => // { // var message = "Token is not connected to a user in this system"; // telemetry.TrackException(new ResponseException(message)); // return onFailure(message); // }); //} public static async Task <TResult> MapAccountAsync <TResult>(Authorization authorization, Guid internalAccountId, string externalAccountKey, IInvokeApplication endpoints, Uri baseUri, AzureApplication application, IHttpRequest request, Func <Uri, TResult> onRedirect, Func <string, TResult> onFailure, TelemetryClient telemetry) { // applies when intercept process is used if (authorization.accountIdMaybe.IsDefault()) { authorization = await authorization.authorizationRef.StorageUpdateAsync( async (a, saveAsync) => { a.accountIdMaybe = internalAccountId; await saveAsync(a); return(a); }); } return(await await AccountMapping.CreateByMethodAndKeyAsync(authorization, externalAccountKey, internalAccountId, ProcessAsync, ProcessAsync)); async Task <TResult> ProcessAsync() { return(await await Method.ById(authorization.Method, application, async method => { return await await method.GetLoginProviderAsync(application, (loginProviderMethodName, loginProvider) => { return CreateLoginResponseAsync( internalAccountId, authorization.parameters, method, authorization, application, request, endpoints, baseUri, loginProvider, (url, modifier) => onRedirect(url), onFailure, telemetry); }, () => { return onFailure("Login provider is no longer supported by the system").AsTask(); }); }, () => onFailure("Method no longer suppored.").AsTask())); } }
public SpaHandler(AzureApplication httpApp, System.Web.Http.HttpConfiguration config) : base(config) { // TODO: A better job of matching that just grabbing the first segment firstSegments = System.Web.Routing.RouteTable.Routes .Where(route => route is System.Web.Routing.Route) .Select(route => route as System.Web.Routing.Route) .Where(route => !route.Url.IsNullOrWhiteSpace()) .Select( route => route.Url.Split(new char[] { '/' }).First()) .ToArray(); ExtractSpaFiles(httpApp); }
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 static async Task <InvocationMessage> SendToFunctionsAsync(this InvocationMessage invocationMessage, string serviceBusTriggerNameOverride = default) { var invocationMessageRef = invocationMessage.invocationRef; var byteContent = invocationMessageRef.id.ToByteArray(); var serviceBusTriggerName = serviceBusTriggerNameOverride.HasBlackSpace() ? serviceBusTriggerNameOverride : AppSettings.FunctionProcessorServiceBusTriggerName.ConfigurationString(value => value, (why) => throw new Exception(why)); await AzureApplication.SendServiceBusMessageStaticAsync(serviceBusTriggerName, byteContent.AsEnumerable()); return(invocationMessage); }
private object RemoveApplicationRegistrationAsync(OperationRunner context) { AzureClient client = new AzureClient(WizardContext.TokenProvider); client.SetLogger(context.Logger); AzureApplication application = client.GetApplicationAsync(DataModel.InstallationConfiguration.Azure.FunctionApp.ApplicationRegistrationName).Result; if (application == null) { return(true); } return(client.DeleteApplicationAsync(application.Id).Result); }
public static async Task <TResult> UnmappedCredentailAsync <TResult>(AzureApplication application, IProvideAuthorization authorizationProvider, string method, string subject, IDictionary <string, string> extraParams, Uri baseUri, Func <Guid, Func <Guid, string, string, AuthenticationActions, Uri, Task <Task <TResult> > >, Func <string, Task <TResult> >, Task <Task <TResult> > > createMappingAsync, Func <Uri, string, TResult> onRedirect, Func <HttpStatusCode, string, string, TResult> onResponse, TelemetryClient telemetry) { throw new NotImplementedException(); //return await await application.OnUnmappedUserAsync<Task<TResult>>(method, authorizationProvider, subject, extraParams, // async (authorizationId) => // { // //await updatingAuthLogTask; // telemetry.TrackEvent($"ResponseController.ProcessRequestAsync - Creating Authentication."); // //updatingAuthLogTask = saveAuthLogAsync(true, $"New user mapping requested:{subject}/{credentialProvider.GetType().FullName}[{authorizationId}]", extraParams); // return await await createMappingAsync(authorizationId, // async (sessionId, jwtToken, refreshToken, action, redirectUrl) => // { // //await updatingAuthLogTask; // //await saveAuthLogAsync(true, $"New user mapping requested:{subject}/{credentialProvider.GetType().FullName}[{authorizationId}]", extraParams); // telemetry.TrackEvent($"ResponseController.ProcessRequestAsync - Created Authentication. Creating response."); // var resp = CreateResponse(application, authorizationProvider, method, action, // sessionId, authorizationId, jwtToken, refreshToken, extraParams, // baseUri, redirectUrl, // onRedirect, // onResponse, // telemetry); // //await updatingAuthLogTask; // return resp; // }, // async (why) => // { // //await updatingAuthLogTask; // //await saveAuthLogAsync(true, $"Failure to create user mapping requested:{subject}/{credentialProvider.GetType().FullName}[{authorizationId}]: {why}", extraParams); // var message = $"Failure to connect token to a user in this system: {why}"; // telemetry.TrackException(new ResponseException(message)); // return onResponse(HttpStatusCode.Conflict, message, message); // }); // }, // () => // { // var message = "Token is not connected to a user in this system"; // telemetry.TrackException(new ResponseException(message)); // return onResponse(HttpStatusCode.Conflict, message, message).ToTask(); // }); }