Skip to content

Add withdraw authorization command in auth interface #992

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

Merged
merged 2 commits into from
Mar 23, 2025

Conversation

Pietfried
Copy link
Contributor

@Pietfried Pietfried commented Dec 13, 2024

Describe your changes

This PR adds a withdraw_authorization command in the auth interface and the Auth module.

Issue ticket number and link

#978

Checklist before requesting a review

  • I have performed a self-review of my code
  • I have made corresponding changes to the documentation
  • I read the contribution documentation and made sure that my changes meet its requirements

@Pietfried Pietfried force-pushed the refactor/auth-module-mutex-usage branch 2 times, most recently from 564c9ec to 887138e Compare December 16, 2024 17:45
Base automatically changed from refactor/auth-module-mutex-usage to main December 17, 2024 10:30
@Pietfried Pietfried force-pushed the feature/978-withdraw-authorization branch 3 times, most recently from 1a9c491 to 692e61a Compare December 19, 2024 21:30
@Pietfried Pietfried marked this pull request as ready for review December 20, 2024 14:36
std::mutex event_mutex;
std::mutex withdraw_mutex;
Copy link
Member

Choose a reason for hiding this comment

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

this could probably also use the event_mutex now, or am I mistaken?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Initially I thought so too. If we only use the event_mutex multiple withdraw requests could run in parallel and they could override this->withdraw_request in that case, because the event_mutex is released here while waiting for the targeted processing threads to finish. It ensures that only one withdraw_request can run at a time. Since a withdraw request should not block for a significant amount of time this seems to be the best solution to me

@Pietfried Pietfried linked an issue Jan 6, 2025 that may be closed by this pull request
@Pietfried Pietfried force-pushed the feature/978-withdraw-authorization branch 2 times, most recently from adc0be8 to 7dac05d Compare January 9, 2025 17:53
@Pietfried Pietfried requested a review from SebaLukas as a code owner January 13, 2025 09:21
@Pietfried Pietfried force-pushed the feature/978-withdraw-authorization branch from 53d86a8 to 929afb3 Compare January 13, 2025 09:48
@Pietfried Pietfried requested a review from andistorm as a code owner February 14, 2025 09:20
@Pietfried Pietfried force-pushed the feature/978-withdraw-authorization branch 3 times, most recently from f382707 to 227ba77 Compare March 4, 2025 12:43
@@ -19,10 +19,8 @@ void Auth::init() {
this->info.id, (!this->r_kvs.empty() ? this->r_kvs.at(0).get() : nullptr));

for (const auto& token_provider : this->r_token_provider) {
token_provider->subscribe_provided_token([this](ProvidedIdToken provided_token) {
std::thread t([this, provided_token]() { this->auth_handler->on_token(provided_token); });
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 this change means that we can handle only one token at a time. We do have for example setups where we have 2 sockets and each socket has a own rfid card reader (so the customers should be able to start sessions simultaneously)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The handlers are running in their own thread as long as the tokens are published from different token_providers. If tokens are published from the same provider you are right though, the handlers will only be executed once the previous one has returned. I will therefore change it back.

@Pietfried Pietfried force-pushed the feature/978-withdraw-authorization branch 2 times, most recently from cc20775 to 9c439c3 Compare March 14, 2025 10:43
maaikez and others added 2 commits March 22, 2025 08:42
* added operator overloading for ProvidedIdToken and IdToken types
* Changed tokens_in_process from set of strings to set of ProvidedIdToken to be able to access the referenced connectors
* Introduced processing_finished_cv in AuthHandler to be able to notify a withdraw request waiting thread that the processing of a token has finished
* Implemented handle_withdraw_authorization function
* Added test cases for new functionality
* Move Deuathorized event in EvseManager so that its only published in case session is currently active

Signed-off-by: Piet Gömpel <[email protected]>
Signed-off-by: Maaike Zijderveld, iolar <[email protected]>
@Pietfried Pietfried force-pushed the feature/978-withdraw-authorization branch from 9c439c3 to 918d79d Compare March 22, 2025 07:42
@Pietfried Pietfried merged commit 9e3b180 into main Mar 23, 2025
11 checks passed
@Pietfried Pietfried deleted the feature/978-withdraw-authorization branch March 23, 2025 09:54
mhei added a commit to mhei/remotechargeport that referenced this pull request Mar 30, 2025
In our case, we only provide a Auth interface, thus we simply need to
add the stub handler and return a meaningful/error value.

Signed-off-by: Michael Heimpold <[email protected]>
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.

Withdraw authorization
4 participants