IdentityServer4 icon indicating copy to clipboard operation
IdentityServer4 copied to clipboard

Integarte Idsvr4 with web portal by oidc via Https

Open atpyk opened this issue 9 years ago • 7 comments

Oidc works fine on my local machine with Http that be hosted in Kestrel. But run into a lot of issues when switch to Https. When I deploy the Idsvr4 and web portal on same sever and use Https, the web portal need to redirect to Idsvr to do sign-in, I get the error is "unauthorized_client".

Error logs: Invalid redirect_uri: http://clientportal/signin-oidc { "ClientId": "grapeseed.dashboard", "ClientName": "GrapeSeed Dashboard", "RedirectUri": "http://clientportal/signin-oidc", "AllowedRedirectUris": [ "https://clientportal/signin-oidc" ], "SubjectId": "anonymous", "RequestedScopes": "", "Raw": { "client_id": "dashboard", "redirect_uri": "http://clientportal/signin-oidc" "response_type": "code id_token", "scope": "openid profile basicinfo", "response_mode": "form_post", "nonce": "636203912324322100.ZmQ5MTk5MTAtZGY3Ni00MjFkLWIyOGUtODhkOGVkY "state": "CfDJ8G9vLBoK3ENEk2u8hnV9DK0OcF8dAi3RKfbg2NZosKw6Gab2oPcR_WKx } }

I wondering why could the "https" be converted to "http" eventually.

There are less info about how to integrate IdentityServer4 with Client web application via Https. Can you provide one example for it.

atpyk avatar Jan 19 '17 02:01 atpyk

If the client is at an https address then you should specify https redirects in your IS4 client setup and in your oidc settings. "redirect_uri": "https://clientportal/signin-oidc"

ravetroll avatar Jan 19 '17 21:01 ravetroll

Thanks, I've set https for all places, in this case, it will be converted to http implicitly.

atpyk avatar Jan 20 '17 01:01 atpyk

all set on this issue?

brockallen avatar Jan 21 '17 11:01 brockallen

I've followed this way(https://github.com/IdentityServer/IdentityServer4/issues/213) to rewrite the host header on Idsvr side and portal side:

app.Use(async (context, next) => { context.Request.Scheme = "https"; HostString httpsHostString = new HostString("xxx"); context.Request.Host = httpsHostString; await next.Invoke(); });

Current issue has been solved. But when the authorize finished, the page would keep loading and could not redirect to the "http://clientportal/signin-oidc". Eventually it would show the "504 Gateway Time-out" page.

No error log in Idsvr side, the client portal side's log is:

fail: Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectMiddleware[17] Exception occurred while processing message. Microsoft.IdentityModel.Tokens.SecurityTokenExpiredException: IDX10223: Lifetime validation failed. The token is expired. ValidTo: '01/22/2017 01:00:59' Current time: '01/22/2017 01:05:59'. at Microsoft.IdentityModel.Tokens.Validators.ValidateLifetime(Nullable1 notBefore, Nullable1 expires, SecurityToken securityToken, TokenValidationParameters validationParameters) at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ValidateLifetime(Nullable1 notBefore, Nullable1 expires, JwtSecurityToken securityToken, TokenValidationParameters validationParameters) at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ValidateTokenPayload(JwtSecurityToken jwt, TokenValidationParameters validationParameters) at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ValidateToken(String token, TokenValidationParameters validationParameters, SecurityToken& validatedToken) at Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectHandler.ValidateToken(String idToken, AuthenticationProperties properties, TokenValidationParameters validationParameters, JwtSecurityToken& jwt) at Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectHandler.d__20.MoveNext() info: Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectMiddleware[4] Error from RemoteAuthentication: IDX10223: Lifetime validation failed. The token is expired. ValidTo: '01/22/2017 01:00:59' Current time: '01/22/2017 01:05:59'..

atpyk avatar Jan 22 '17 01:01 atpyk

Maybe it's .net core's bug, can you give me some info to help, thanks.

atpyk avatar Jan 22 '17 01:01 atpyk

Open a new issue for new topics, please.

brockallen avatar Jan 22 '17 12:01 brockallen

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

lock[bot] avatar Jan 15 '20 03:01 lock[bot]