Skip to content

Conversation

@bhavya-shukla-lrn
Copy link
Contributor

…ization object[LRN-38974]

@bhavya-shukla-lrn bhavya-shukla-lrn force-pushed the LRN-38974/Create-demo-page-questions-api branch 8 times, most recently from 31242ff to ba1d0ef Compare January 30, 2023 13:23
this.validSecurityKeys = new string[5] { "consumer_key", "domain", "timestamp", "expires", "user_id" };
this.validServices = new string[7] { "assess", "author", "data", "events", "items", "questions", "reports" };
this.algorithm = "sha256";
this.algorithm = "hmac256";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the algorithm name is hmac-sha256

/// <param name="value"></param>
/// <returns>The hashed string</returns>
private string hashValue(string[] value)
private string hashValue(string prehash, string value )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the parameter "value" should be "secret" to make it more intuitive

signatureList.Add(this.securityPacket.getString("user_id"));
signatureList.Add(this.secret);

string signature = this.hashValue(signatureList.ToArray());
Copy link
Contributor

@markus-liang-lrn markus-liang-lrn Jan 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the signatureList is only here, so maybe the declaration and the initialisation should be removed too?

{
string user_id = users[i];
hashedUsers.set(user_id, Tools.hash(this.algorithm, user_id + this.secret));
hashedUsers.set(user_id, Tools.hash(this.algorithm,this.prehashString, user_id + this.secret));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need space after comma

/// </summary>
/// <param name="s">String to be hashed</param>
/// <returns>64-character hex string</returns>
public static string hmac256(string prehash,string value)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use a proper algorithm name, its hmac sha256

/// </summary>
/// <param name="s">String to be hashed</param>
/// <returns>64-character hex string</returns>
public static string hmac256(string prehash,string value)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the value should be secret

/// <summary>
/// Returns HMAC256 hash
/// </summary>
/// <param name="prehash"></param>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need explanation of the parameters

/// <param name="value"></param>
/// <returns></returns>
public static string hash(string algorithm, string message)
public static string hash(string algorithm, string prehash, string value)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

value

this.validSecurityKeys = new string[5] { "consumer_key", "domain", "timestamp", "expires", "user_id" };
this.validServices = new string[7] { "assess", "author", "data", "events", "items", "questions", "reports" };
this.algorithm = "hmac256";
this.algorithm = "hmac-sha256";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed name to hmac-sha256

private string hashValue(string prehash, string secret )
{
string hash = Tools.hash(this.algorithm, prehash, value);
string hash = Tools.hash(this.algorithm, prehash, secret);
Copy link
Contributor Author

@bhavya-shukla-lrn bhavya-shukla-lrn Jan 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added summary for params , changed params name to secret as per the comments given


signatureList.Add(this.securityPacket.getString("user_id"));
signatureList.Add(this.secret);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will remove extra lines in my next commit

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

signatureList.Add(this.securityPacket.getString("user_id"));
signatureList.Add(this.secret);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per the review signatureList initialisation and declaration has been removed

{
string user_id = users[i];
hashedUsers.set(user_id, Tools.hash(this.algorithm,this.prehashString, user_id + this.secret));
hashedUsers.set(user_id, Tools.hash(this.algorithm, this.prehashString, user_id + this.secret));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added space after comma

///<param name="secret">String used for encryption</param>
/// <returns>64-character hex string</returns>
public static string hmac256(string prehash,string value)
public static string hmacsha256(string prehash, string secret)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed algo to hmacsha256

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed param value to secret and also added function summary with params

/// <param name="prehash"></param>
///<param name="value"></param>
/// <param name="prehash">String to be hashed</param>
///<param name="secret">String used for encryption</param>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added comments for params

/// <param name="secret">String used for encryption</param>
/// <returns></returns>
public static string hash(string algorithm, string prehash, string value)
public static string hash(string algorithm, string prehash, string secret)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed value to secret(params)

{
case "hmac256":
str = Tools.hmac256(prehash, value);
case "hmac-sha256":
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed name to hmac-sha256

@bhavya-shukla-lrn bhavya-shukla-lrn force-pushed the LRN-38974/Create-demo-page-questions-api branch 2 times, most recently from 82ef665 to a82f88c Compare February 21, 2023 09:28
// item_edit mode and item_list mode
// the below example generate initOptions for item_edit mode
// more information about item_list mode can be found in initializeItemList() function
Init init = (mode == "item_list") ? initializeItemEdit() : initializeItemList();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this conditional correct? if mode is item_list, then you will return itemEdit, and if mode is not item_list then you return item_list?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ohh I need to correct that , If mode is Item list it should return itemList not item edit. Thanks For pointing it out I will make that change

// the below example generate initOptions for item_edit mode
// more information about item_list mode can be found in initializeItemList() function
Init init = (mode == "item_list") ? initializeItemEdit() : initializeItemList();
Init init = (mode == "item_list") ? initializeItemList() : initializeItemEdit();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, just need to remove unnecessary space after '?'

@bhavya-shukla-lrn bhavya-shukla-lrn force-pushed the LRN-38974/Create-demo-page-questions-api branch from 0e63b85 to 79fdbd6 Compare February 24, 2023 12:01
@bhavya-shukla-lrn bhavya-shukla-lrn force-pushed the LRN-38974/Create-demo-page-questions-api branch 5 times, most recently from bc57763 to 083e761 Compare February 28, 2023 12:58
@bhavya-shukla-lrn bhavya-shukla-lrn force-pushed the LRN-38974/Create-demo-page-questions-api branch 4 times, most recently from af9ba81 to 019801f Compare March 29, 2023 15:43
Copy link
Contributor

@TheRealEdDawson TheRealEdDawson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left some minor comments, but generally, looks great, guys. Please go ahead!

Copy link
Contributor

@TheRealEdDawson TheRealEdDawson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. Thanks @bhavya-shukla-lrn , please go ahead with it.

@bhavya-shukla-lrn bhavya-shukla-lrn force-pushed the LRN-38974/Create-demo-page-questions-api branch from d10e1e2 to 9abab5a Compare June 26, 2023 11:27
Copy link
Contributor

@TheRealEdDawson TheRealEdDawson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good @bhavya-shukla-lrn @markus-liang-lrn @markkellyeire, I made some minor edits to text in "README.md" and to the copyright year in "LearnositySDK.csproj", to change it to this year "2023".

@bhavya-shukla-lrn bhavya-shukla-lrn force-pushed the LRN-38974/Create-demo-page-questions-api branch from abe9b6b to 04f6de5 Compare June 29, 2023 06:44
…ages for the new signature LRN-38572

Change in branch
@bhavya-shukla-lrn bhavya-shukla-lrn force-pushed the LRN-38974/Create-demo-page-questions-api branch from 04f6de5 to a6bf743 Compare June 29, 2023 06:49
@bhavya-shukla-lrn bhavya-shukla-lrn merged commit 5c19004 into master Jun 29, 2023
@bhavya-shukla-lrn bhavya-shukla-lrn deleted the LRN-38974/Create-demo-page-questions-api branch June 29, 2023 06:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants