question

PrathameshShende avatar image
0 Votes"
PrathameshShende asked Bruce-SqlWork commented

Call Identity Server URL From IdentityModel

I want to generate this url of identity server from identity model -
I gone through the docs of identityModel but its not helpful.

How do I generate this -

Account/Login?ReturnUrl=%2Fconnect%2Fauthorize%2Fcallback%3Fclient_id%3Dbrekon%26redirect_uri%3Dhttps%253A%252F%252Flocalhost%253A44382%252Fauthentication%252Flogin-callback%26response_type%3Dcode%26scope%3Dopenid%2520profile%2520email%2520api1%26code_challenge%3DgpralpA1djm4DZs4J-i_SG5aw9mQtMiHpWuh1clq7co%26code_challenge_method%3DS256%26response_mode%3Dform_post%26nonce%3D637993598524237769.ZmVjOGI2YTQtZjFlYy00MjMyLWI3NzMtNjRkNTEwZWNlN2YyNzZiMzg2ZDQtZjExZi00ZjYyLThjMGEtMjlkMmQ5NDQ1NjU2%26state%3DCfDJ8OhhiPHXuTJFtAjFNi6MNVOw-nJmIt80t8l7pELKwDeq77OM1trdr_F10Odc0MDjnLLsXyTU_3pd1Z2uXTZDbjZtFbmLNTsdx4m9h2F5hCwNfR6fxkp1cAXvgwCBGa2oTCqPK--WIxkpoJVMxerN8xkLYfzkgHEDukIqAI2y61Ud2I_rFXyYLmum413YkSjoEQAerfLN-ll3oCyzkV3DXbquvSiDc3T26m3ohkTaqiycmqYpZoqx24Ht1wp5iUFxrjphVm2pmLAkmjU4dcyDW7rSZBcY5OQD66APi8Na3eUE2Zjzl8u99OeDkLh8VpNpmd84XHPnxB2ojqGlySOQBIJdFwZf-TFVAcaKy3Wq2mviInlvr1F-y8j1HUz4WO503cfxq8A1Ex_FYrhshOGuQnc%26x-client-SKU%3DID_NETSTANDARD2_0%26x-client-ver%3D6.10.0.0

dotnet-aspnet-core-general
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Bruce-SqlWork avatar image
0 Votes"
Bruce-SqlWork answered Bruce-SqlWork commented

that is all pass-thru data for the identity server to pass back to the callback handler. this data is required by the callback code. it looks like an oauth flow.

decoded ReturnUrl:

/connect/authorize/callback?client_id=brekon
&redirect_uri=https%3A%2F%2Flocalhost%3A44382%2Fauthentication%2Flogin-callback
&response_type=code
&scope=openid%20profile%20email%20api1
&code_challenge=gpralpA1djm4DZs4J-i_SG5aw9mQtMiHpWuh1clq7co
&code_challenge_method=S256
&response_mode=form_post
&nonce=637993598524237769.ZmVjOGI2YTQtZjFlYy00MjMyLWI3NzMtNjRkNTEwZWNlN2YyNzZiMzg2ZDQtZjExZi00ZjYyLThjMGEtMjlkMmQ5NDQ1NjU2
&state=CfDJ8OhhiPHXuTJFtAjFNi6MNVOw-nJmIt80t8l7pELKwDeq77OM1trdr_F10Odc0MDjnLLsXyTU_3pd1Z2uXTZDbjZtFbmLNTsdx4m9h2F5hCwNfR6fxkp1cAXvgwCBGa2oTCqPK--WIxkpoJVMxerN8xkLYfzkgHEDukIqAI2y61Ud2I_rFXyYLmum413YkSjoEQAerfLN-ll3oCyzkV3DXbquvSiDc3T26m3ohkTaqiycmqYpZoqx24Ht1wp5iUFxrjphVm2pmLAkmjU4dcyDW7rSZBcY5OQD66APi8Na3eUE2Zjzl8u99OeDkLh8VpNpmd84XHPnxB2ojqGlySOQBIJdFwZf-TFVAcaKy3Wq2mviInlvr1F-y8j1HUz4WO503cfxq8A1Ex_FYrhshOGuQnc
&x-client-SKU=ID_NETSTANDARD2_0
&x-client-ver=6.10.0.0

normally a controller would generate this with:

       return Challenge(
                 new AuthenticationProperties { RedirectUri = redirectUrl },
                 scheme);




· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

The problem I m facing is When I set IdentityServer 4 settings in program.cs and App.razor It will secure the whole website due to Authorization Added in Program.cs and need to login first. So the If remove the Authorization from program.cs It will work fine. and I can see pages without login.
But I cannot call this URL and not redirect to Identity Server 4 Project. So I was thinking If I can generate this url on blazor Server-Side Project Then I can get easy get Identity Server 4 Login Screen It will redirect back to url by returnUrl.

Is It Possible? Any other solution on it.?

0 Votes 0 ·

if you want blazor to control login rather than the hosting server use the msal library:

https://learn.microsoft.com/en-us/aspnet/core/blazor/security/webassembly/standalone-with-azure-active-directory?view=aspnetcore-6.0

0 Votes 0 ·