Skip to content
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

fix(ocpi-2.2.1): Fixed usage of tokens & review PlatformRepository #16

Merged
merged 3 commits into from
Nov 2, 2023

Conversation

lilgallon
Copy link
Member

@lilgallon lilgallon commented Oct 31, 2023

Change notes

only for 2.2.1

Credentials logic

The credentials logic completely changed. Token B and Token C were replaced by Client Token and Server Token. The Token A usage stays the same.

The Credentials Token A is used by the sender to communicate with the receiver (only when initiating registration). After registration, it is invalidated.

Then, there are two tokens, and the token to use is specified by the registration process.

  • When you are the receiver during registration:
    • OCPI Token B is the client token, the one you have to use to send requests
    • OCPI Token C is the server token, the one you have to use to check if requests are properly authenticated
  • When you are the sender during registration:
    • OCPI Token B is the server token, the one you have to use to check if requests are properly authenticated
    • OCPI Token C is the client token, the one you have to use to send requests

This is why we do not use OCPI's token B and token C naming. According to who you are in the registration process, you have to use a different token. Using "Client Token" and "Server Token" simplifies that process of picking the right token for the right operation.

Before these changes, the library would not work when used while being the receiver of the registration process.

PlatformRepository modifications

Unused methods are removed. Some were renamed and their signature updated to match the new credentials logic. The unregistration is now in one unique method, rather than 5 different methods.

Migration guide

It's a breaking change, it also breaks your Platform objects.

You will have to update your PlatformRepository implementation to match the new interface. Everything is documented in the file. You have to re-register with your partners. Or you can mnually update your Platform object to reflect the changes (clientToken / serverToken instead of tokenB / tokenC).

Notes

This will allow us to bump the lib to 0.1.0 as it should now work properly, and it's now usable (not production ready yet obvisouly).

Copy link
Contributor

@xhanin xhanin left a comment

Choose a reason for hiding this comment

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

I have a few comments, but they are beyond the scope of this PR, and could be discussed / handled in another PR.
Therefore this PR is good for me as is, and the updates for the other versions can be handled separately in other PR / issues.

@lilgallon lilgallon marked this pull request as ready for review November 2, 2023 09:36
Base automatically changed from fix/add-missing-headers-and-fix-post-credentials-response to main November 2, 2023 09:51
Copy link

sonarcloud bot commented Nov 2, 2023

Please retry analysis of this Pull-Request directly on SonarCloud.

@lilgallon lilgallon merged commit 486a2f3 into main Nov 2, 2023
1 of 2 checks passed
@lilgallon lilgallon deleted the fix/#15-use-right-tokens branch November 2, 2023 10:38
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.

None yet

2 participants