Skip to content

Commit

Permalink
fix(v2.0.1): DisableREmoteAuthorization with EMAID token
Browse files Browse the repository at this point in the history
We could send Authorize requests with an emaid token even though disable remote auth was true.

Signed-off-by: mlitre <martinlitre@mac.com>
  • Loading branch information
mlitre committed Sep 18, 2024
1 parent 088a6db commit 1a7f07f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/ocpp/v201/charge_point.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,10 @@ AuthorizeResponse ChargePoint::validate_token(const IdToken id_token, const std:
return response;
}

bool disabled_remote_auth =
this->device_model->get_optional_value<bool>(ControllerComponentVariables::DisableRemoteAuthorization)
.value_or(false);

// C07: Authorization using contract certificates
if (id_token.type == IdTokenEnum::eMAID) {
// Temporary variable that is set to true to avoid immediate response to allow the local auth list
Expand All @@ -707,7 +711,7 @@ AuthorizeResponse ChargePoint::validate_token(const IdToken id_token, const std:
bool forwarded_to_csms = false;

// If OCSP data is provided as argument, use it
if (is_online and ocsp_request_data.has_value()) {
if (is_online and ocsp_request_data.has_value() and !disabled_remote_auth) {
EVLOG_info << "Online: Pass provided OCSP data to CSMS";
response = this->authorize_req(id_token, std::nullopt, ocsp_request_data);
forwarded_to_csms = true;
Expand All @@ -728,7 +732,7 @@ AuthorizeResponse ChargePoint::validate_token(const IdToken id_token, const std:
// C07.FR.01: When CS is online, it shall send an AuthorizeRequest
// C07.FR.02: The AuthorizeRequest shall at least contain the OCSP data
// TODO: local validation results are ignored if response is based only on OCSP data, is that acceptable?
if (is_online) {
if (is_online and !disabled_remote_auth) {
// If no OCSP data was provided, check for a contract root
if (local_verify_result == CertificateValidationResult::IssuerNotFound) {
// C07.FR.06: Pass contract validation to CSMS when no contract root is found
Expand Down Expand Up @@ -912,8 +916,7 @@ AuthorizeResponse ChargePoint::validate_token(const IdToken id_token, const std:

// When set to true this instructs the Charging Station to not issue any AuthorizationRequests, but only use
// Authorization Cache and Local Authorization List to determine validity of idTokens.
if (!this->device_model->get_optional_value<bool>(ControllerComponentVariables::DisableRemoteAuthorization)
.value_or(false)) {
if (disabled_remote_auth) {
response = this->authorize_req(id_token, certificate, ocsp_request_data);

if (auth_cache_enabled) {
Expand Down

0 comments on commit 1a7f07f

Please sign in to comment.