Asp.Net Web API oAuth 2.0 无法使用包含与号 (&) 的密码进行验证

时间:2023-03-27
本文介绍了Asp.Net Web API oAuth 2.0 无法使用包含与号 (&) 的密码进行验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我在 AngularJs 应用程序中遇到了有线问题.当用户尝试登录应用时,如果密码中包含与号 (&),则无法验证用户.

I am having a wired issue in my AngularJs application. When user is trying to login to the app and if the password contains ampersand (&), then it couldn't able to validate the user.

我正在使用 OWIN、oAuth2.0 JWT 令牌来验证我的 Asp.Net Web API.

I am using OWIN, oAuth2.0 JWT token to validate my Asp.Net Web APIs.

当我调试时,我发现如果密码包含 & 符号 (&),那么它会截断 & 符号 (&) 中的所有字符.

When i debug i found that if the password contains ampersand (&), then it is truncating all the characters from ampersand (&).

例如,如果密码为x&x",则 OAuthValidateClientAuthenticationContext 上下文只会获取密码值中的x".

For example, if the password is 'x&x' the OAuthValidateClientAuthenticationContext context is getting only 'x' in password value.

我附上了问题的屏幕截图点击查看问题..

I have attached a screen shot of the issue click to see the issue..

对此问题的任何帮助,我们将不胜感激.

Any help on this issue, would be highly appreciated.

推荐答案

我猜测该值被解释为查询字符串分隔符.

Am guessing the value is being interpreted as a query string separator.

尝试使用javascript方法

Try using the javascript method

encodeURI()

或者

EncodeURIcomponent()

在发布到服务器之前你的密码值,所以和号变成了

On your password value before posting to the server, so the ampersand becomes

&

服务器将为您解码.
如果您不这样做,您可能会发现斜杠和问号在密码中也不起作用

The server will decode this for you.
You'll probably find that slashes and question marks will also not work in passwords if you dont

这篇关于Asp.Net Web API oAuth 2.0 无法使用包含与号 (&) 的密码进行验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

上一篇:使用 AspNet.Security.OpenIdConnect.Server (ASP.NET vNext) 的自定义 下一篇:使用 Owin 从 JWT 获取自定义声明

相关文章