-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Psre 2138/feature/pre hash string utils PSRE-2229 #70
Conversation
1a9608b
to
df747fb
Compare
c252e2a
to
0e9329b
Compare
4937087
to
76aa9ba
Compare
Signed-off-by: Olivier Mehani <olivier.mehani@learnosity.com>
Signed-off-by: Olivier Mehani <olivier.mehani@learnosity.com>
Signed-off-by: Olivier Mehani <olivier.mehani@learnosity.com>
Signed-off-by: Olivier Mehani <olivier.mehani@learnosity.com>
Signed-off-by: Olivier Mehani <olivier.mehani@learnosity.com>
Signed-off-by: Olivier Mehani <olivier.mehani@learnosity.com>
Signed-off-by: Olivier Mehani <olivier.mehani@learnosity.com>
Signed-off-by: Olivier Mehani <olivier.mehani@learnosity.com>
[TEST] ParamsFixture/items: add user_id in security [TEST] ParamsFixture lexical ordering of method per API name [TEST] ParamsFixture: move data timestamp to fixture [TEST] ParamsFixture: reuse apiQuestionActivity in Assess init options [TEST] Explicitely disable telemetry in constructor tests Signed-off-by: Olivier Mehani <olivier.mehani@learnosity.com>
Only leave hardcoded signatures in test for bespoke modifications. Signed-off-by: Olivier Mehani <olivier.mehani@learnosity.com>
Signed-off-by: Olivier Mehani <olivier.mehani@learnosity.com>
d20163e
to
a1ee325
Compare
Signed-off-by: Olivier Mehani <olivier.mehani@learnosity.com>
Signed-off-by: Olivier Mehani <olivier.mehani@learnosity.com>
…ward compatibility Signed-off-by: Olivier Mehani <olivier.mehani@learnosity.com>
Signed-off-by: Olivier Mehani <olivier.mehani@learnosity.com>
…d current schemes Signed-off-by: Olivier Mehani <olivier.mehani@learnosity.com>
Signed-off-by: Olivier Mehani <olivier.mehani@learnosity.com>
a1ee325
to
595b8b1
Compare
@@ -6,17 +6,17 @@ | |||
|
|||
class HashSignature implements SignatureInterface | |||
{ | |||
const ALGORITHM = 'sha256'; | |||
public const ALGORITHM = 'sha256'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these really public? I understand that the default of these is public, but I think these should only be used in this class, so should be private
@@ -8,17 +8,17 @@ | |||
|
|||
class HmacSignature implements SignatureInterface | |||
{ | |||
const ALGORITHM = 'sha256'; | |||
public const ALGORITHM = 'sha256'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Visibility should be private I'd say
|
||
use LearnositySdk\Exceptions\ValidationException; | ||
|
||
class LegacyPreHashString implements PreHashStringInterface |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume there will be another class implementing this in the future, otherwise the interface makes no sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, the idea is to make each signature pattern independent, rather than the current pattern we have which is really hard to audit because it jumps around and has too many ifs.
The LegacyPreHashString
implementation is different from what we had in the SDK before, as it takes the approach of the implementation we have in LP instead, which is a lot simpler to follow.
use LearnositySdk\Services\PreHashStrings\PreHashStringInterface; | ||
use LearnositySdk\Services\PreHashStrings\LegacyPreHashString; | ||
|
||
class PreHashStringFactory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if PreHashString
is the best name for these classes. Maybe PlainStringManipulator
? Not sure if that's better though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not a great name, but that's the one that has been used historically, so I went with that.
https://github.com/Learnosity/learnosity-sdk-php/blob/master/src/Request/Init.php#L297-L315
It's a very specific Service that should only do PHS generation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prior to the signature upgrade in most cases the pre hash string variable was called $signature
in many places which was so confusing. Changing it to prehash string was a revelation in terms of readability but I now realise that probably only was the case for myself and others who had struggled to understand the code when it was called $signature
.
Has a look each implementation of of hash hmac in each of the SDK languages we support just for naming convention ideas and it seems most languages refer to the data to be hashed as message or simply data which in both cases is probably too ambiguous.
src/Request/Init.php
Outdated
$this->requestPacket, | ||
$this->action | ||
); | ||
/* $preHashString = $this->generatePreHashString(); */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shtrom Looks like this commented out line can go.
use LearnositySdk\Services\PreHashStrings\PreHashStringInterface; | ||
use LearnositySdk\Services\PreHashStrings\LegacyPreHashString; | ||
|
||
class PreHashStringFactory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prior to the signature upgrade in most cases the pre hash string variable was called $signature
in many places which was so confusing. Changing it to prehash string was a revelation in terms of readability but I now realise that probably only was the case for myself and others who had struggled to understand the code when it was called $signature
.
Has a look each implementation of of hash hmac in each of the SDK languages we support just for naming convention ideas and it seems most languages refer to the data to be hashed as message or simply data which in both cases is probably too ambiguous.
Signed-off-by: Olivier Mehani <olivier.mehani@learnosity.com>
Signed-off-by: Olivier Mehani <olivier.mehani@learnosity.com>
Signed-off-by: Olivier Mehani <olivier.mehani@learnosity.com>
Signed-off-by: Olivier Mehani <olivier.mehani@learnosity.com>
40d291e
to
49c0fc7
Compare
This PR:
It may help to review this PR commit by commit, as they build on top of each other.
Checklist
Feature
Bug
Refactor
ChangeLog.md updated
Tests added
All testsuite passes
make dist
completed successfully