Fix small TOTP and `SessionIdentification.ChallengeAnswer` property issue.
Signed-off-by: Aliwoto <aminnimaj@gmail.com>
This commit is contained in:
parent
70ef761e20
commit
039836d83f
|
@ -163,7 +163,7 @@ namespace Socialvoid.Client
|
|||
/// next jsonrpc request.
|
||||
/// <code> since: v0.0.0 </code>
|
||||
/// </summary>
|
||||
protected string _otp;
|
||||
protected string _otp_answer;
|
||||
/// <summary>
|
||||
/// <code> since: v0.0.0 </code>
|
||||
/// </summary>
|
||||
|
@ -282,7 +282,7 @@ namespace Socialvoid.Client
|
|||
if (!string.IsNullOrEmpty(jresp.Result.ChallengeSecret))
|
||||
{
|
||||
_should_otp = true;
|
||||
_otp = GetChallengeAnswer(jresp.Result.ChallengeSecret);
|
||||
_otp_answer = GetChallengeAnswer(jresp.Result.ChallengeSecret);
|
||||
// set challenege secret to null to avoid sending it again.
|
||||
// this will avoid future conflicts in using old challenge secret.
|
||||
jresp.Result.ChallengeSecret = null;
|
||||
|
@ -368,16 +368,17 @@ namespace Socialvoid.Client
|
|||
if (IsOtpValid(otp))
|
||||
{
|
||||
args.Add(OtpKey, otp);
|
||||
sessionID.ChallengeAnswer = otp;
|
||||
//sessionID.ChallengeAnswer = otp;
|
||||
}
|
||||
else if (_should_otp && IsOtpValid(_otp))
|
||||
|
||||
if (_should_otp && IsOtpValid(_otp_answer))
|
||||
{
|
||||
// after adding otp answer to args, don't forget to set
|
||||
// _should_otp to false (and _otp to null).
|
||||
args.Add(OtpKey, _otp);
|
||||
sessionID.ChallengeAnswer = _otp;
|
||||
//args.Add(OtpKey, _challenge);
|
||||
sessionID.ChallengeAnswer = _otp_answer;
|
||||
_should_otp = false;
|
||||
_otp = null;
|
||||
_otp_answer = null;
|
||||
}
|
||||
|
||||
var request = GetRpcRequest(AuthenticateUserMethod, args);
|
||||
|
|
|
@ -129,13 +129,14 @@ namespace Socialvoid.Security.Otp
|
|||
internal static string GetSha1(string value)
|
||||
{
|
||||
var data = Encoding.ASCII.GetBytes(value);
|
||||
var hashData = new SHA1Managed().ComputeHash(data);
|
||||
var hash = string.Empty;
|
||||
foreach (var b in hashData)
|
||||
{
|
||||
hash += b.ToString("X2");
|
||||
}
|
||||
return hash;
|
||||
return Convert.ToHexString(new SHA1Managed().ComputeHash(data)).ToLower();
|
||||
//var hashData = new SHA1Managed().ComputeHash(data);
|
||||
//var hash = string.Empty;
|
||||
//foreach (var b in hashData)
|
||||
//{
|
||||
// hash += b.ToString("X2");
|
||||
//}
|
||||
//return hash;
|
||||
}
|
||||
#endregion
|
||||
//-------------------------------------------------
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace Socialvoid.Security
|
|||
/// <code> since: v0.0.0 </code>
|
||||
/// </summary>
|
||||
[JsonPropertyName("challenge_answer")]
|
||||
public string ChallengeAnswer { get; internal set; }
|
||||
public string ChallengeAnswer { get; set; }
|
||||
#endregion
|
||||
//-------------------------------------------------
|
||||
#region static field's Region
|
||||
|
|
Loading…
Reference in New Issue