Ejemplo n.º 1
0
        public async Task <IActionResult> OidcLogin(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = "oidc-login/{platformId}")] HttpRequest req,
            [Platform(PlatformId = "{platformId}")] Platform platform,
            [LtiAdvantage] OidcClient oidcClient,
            [DurableClient] IDurableOrchestrationClient orchestrationClient)
        {
            NameValueCollection redirectQueryParams = oidcClient.GetRedirectQueryParams(platform.ClientId);
            string nonce = Guid.NewGuid().ToString();
            string state = Guid.NewGuid().ToString();

            string instanceId = await orchestrationClient.StartNewAsync(nameof(SaveState), (object)(nonce, state));

            await orchestrationClient.WaitForCompletionOrCreateCheckStatusResponseAsync(req, instanceId);

            redirectQueryParams["nonce"] = nonce;
            redirectQueryParams["state"] = state;

            string queryParams = redirectQueryParams.ToString();

            string redirectUrl = $"{platform.AuthorizationUrl}?{queryParams}";

            return(new RedirectResult(redirectUrl));
        }