Reputation: 1
command chat bot in ms teams and with sso authentication using Authprompt dialog.
Azure AD intra id setup completed with redirect uris
https://localhost:44310/signin-oidc
https://.ngrok-free.app/auth-end.html
https://token.botframework.com/.auth/web/redirect
sso token generated once user logins with prompted dialog img ref - SSO prompt
Next use case is to make a api call to backend to fetch data, backend service has a identity server 4 as IDP and have configured azure AD as OpenID connect in IDP as follows
.AddOpenIdConnect("AzureAD", "Azure AD", options =>
{
options.Authority = $"https://login.microsoftonline.com/{tenantid}/v2.0";
options.ClientId = "{clientid}";
options.ClientSecret = "{clientsecret}";
options.ResponseType = "code";
options.SaveTokens = true;
options.TokenValidationParameters = new TokenValidationParameters
{
ValidateIssuer = true,
ValidIssuer = $"https://sts.windows.net/{tenantid}/",
ValidateAudience = true,
ValidAudience = "{validaud}",
ValidateLifetime = true //
};
options.CallbackPath = "/signin-oidc";
options.Events = new OpenIdConnectEvents
{
OnRedirectToIdentityProvider = context =>
{
Log.Information($"OnRedirectToIdentityProvider : ");
return Task.CompletedTask;
},
OnTokenResponseReceived = context =>
{
var userClaims = context.Principal.Claims.Select(c => $"{c.Type}: {c.Value}");
Log.Information($"OnTokenResponseReceived : {string.Join(", ", userClaims)}");
return Task.CompletedTask;
},
OnTokenValidated = context =>
{
// Log user claims or other relevant information
var userClaims = context.Principal.Claims.Select(c => $"{c.Type}: {c.Value}");
Log.Information($"Token validated for user with claims: {string.Join(", ", userClaims)}");
return Task.CompletedTask;
},
OnAuthenticationFailed = context =>
{
Log.Error("Azure AD Authentication Failed", context.Exception);
return Task.FromException(new AuthenticationException("Azure AD Authentication Failed"));
}
};
}
when api call with sso token is made its returning with azure login screen expected result is to recognize users and execute api
when setting added
options.Prompt = "none";
returned
AADSTS50058: A silent sign-in request was sent but no user is signed in. The cookies used to represent the user's session were not sent in the request to Azure AD. This can happen if the user is using Internet Explorer or Edge, and the web app sending the silent sign-in request is in different IE security zone than the Azure AD endpoint (login.microsoftonline.com).
its expecting cookies but in this case its a bot making backend api call with sso token
expected result - user recognized/validated by idp and api exectue
Upvotes: 0
Views: 41