abp icon indicating copy to clipboard operation
abp copied to clipboard

Unable to login to ABP application after upgrading to 8.2.0 - Getting redirected back to Login Page

Open chandralk opened this issue 2 years ago • 7 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Description

I have an ABP 8.1.4 application with Angular UI and separate auth server. I upgraded it to the latest 8.2.0 version. Since then when I login through the Angular UI, I get redirected to the auth server login page and once I successfully login, it redirects to Angular but still shows me the login button. screen-capture.webm

Reproduction Steps

Login to the application

Expected behavior

After successful login, Angular UI should show that the user has logged in successfully and should display the menus which are allowed to the user.

Actual behavior

Angular UI still shows that the user has not logged in and shows the Login button again

Regression?

Yes. Was working in 8.1.4

Known Workarounds

N/A

Version

8.2.0

User Interface

Angular

Database Provider

EF Core (Default)

Tiered or separate authentication server

Separate Auth Server

Operation System

Windows (Default)

Other information

No response

chandralk avatar Jul 02 '24 04:07 chandralk

Please check your application's logs.txt.

maliming avatar Jul 02 '24 04:07 maliming

Hi @maliming,

I noticed the following error in the HttpApi.Host's logs.txt:

2024-07-02 11:34:42.476 +05:30 [INF] Failed to validate the token.
Microsoft.IdentityModel.Tokens.SecurityTokenMalformedException: IDX14100: JWT is not well formed, there are no dots (.).
The token needs to be in JWS or JWE Compact Serialization Format. (JWS): 'EncodedHeader.EndcodedPayload.EncodedSignature'. (JWE): 'EncodedProtectedHeader.EncodedEncryptedKey.EncodedInitializationVector.EncodedCiphertext.EncodedAuthenticationTag'.
 ---> System.MissingMethodException: Method not found: 'Byte[] Microsoft.IdentityModel.Tokens.Base64UrlEncoder.UnsafeDecode(System.ReadOnlyMemory`1<Char>)'.
   at Microsoft.IdentityModel.JsonWebTokens.JsonWebToken.ReadToken(String encodedJson)
   at Microsoft.IdentityModel.JsonWebTokens.JsonWebToken..ctor(String jwtEncodedString)
   at Microsoft.IdentityModel.JsonWebTokens.JsonWebTokenHandler.ReadToken(String token, TokenValidationParameters validationParameters)
   --- End of inner exception stack trace ---
2024-07-02 11:34:42.478 +05:30 [INF] Bearer was not authenticated. Failure message: IDX14100: JWT is not well formed, there are no dots (.).
The token needs to be in JWS or JWE Compact Serialization Format. (JWS): 'EncodedHeader.EndcodedPayload.EncodedSignature'. (JWE): 'EncodedProtectedHeader.EncodedEncryptedKey.EncodedInitializationVector.EncodedCiphertext.EncodedAuthenticationTag'.

There's no error in AuthServer's log.txt.

Attaching both for your reference.

HttpApi.Host - logs.txt

AuthServer-logs.txt

Please advice.

chandralk avatar Jul 02 '24 06:07 chandralk

I just tried upgrading to ABP 8.2.0 and I'm seeing the same error from Swagger after I authenticated and then called an endpoint that requires authorization.

gvassao avatar Jul 02 '24 06:07 gvassao

hi

Please use the latest IdentityModel packages in the HttpApi.Host project.

<PackageReference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" Version="7.5.1" />
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="7.5.1" />
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" Version="7.5.1" />

maliming avatar Jul 02 '24 06:07 maliming

@maliming This worked for me. Thanks for the fast response!

gvassao avatar Jul 02 '24 06:07 gvassao

Many thanks @maliming. It's working after adding those additional packages.

I also saw that a similar issue was reported in #19965.

Could you explain the need for this change a little bit so that I can contribute by adding the same to the migration document and also maybe the new templates?

chandralk avatar Jul 02 '24 06:07 chandralk

hi

The Microsoft.IdentityModel often got bugs. This is the reason.

https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet/issues?q=is%3Aissue+label%3ABug+

maliming avatar Jul 02 '24 06:07 maliming