Skip to content

Commit

Permalink
Added support for "eligible_authrole" and "eligible_authid" options i…
Browse files Browse the repository at this point in the history
…n publish messages, in accordance with the standard. For backwards compatibility, the prefixed versions "_thruway_eligible_authroles" and "_thruway_eligible_authids" are still preferred if both prefixed and unprefixed variant are specified.
  • Loading branch information
boenrobot committed Jul 13, 2022
1 parent 705b7ab commit c57aa42
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/Message/PublishMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,20 +157,24 @@ public function setOptions($options)
$this->exclude_me = isset($options->exclude_me) && $options->exclude_me === false ? false : true;
$this->exclude = isset($options->exclude) && is_array($options->exclude) ? $options->exclude : [];
$this->eligible = isset($options->eligible) && is_array($options->eligible) ? $options->eligible : null;
$this->eligible_authroles = []; // default to no auth roles eligible

if (isset($options->_thruway_eligible_authroles)) {
if (is_array($options->_thruway_eligible_authroles)) {
$this->eligible_authroles = $options->_thruway_eligible_authroles;
$this->eligible_authroles = []; // default to no auth roles eligible
// Support both the standard and prefixed versions of eligible_authroles, preferring the prefixed version
$authroles = $options->_thruway_eligible_authroles ?? $options->eligible_authrole ?? null;
if (isset($authroles)) {
if (is_array($authroles)) {
$this->eligible_authroles = $authroles;
}
} else {
$this->eligible_authroles = null; // null says every authrole is valid
}

$this->eligible_authids = []; // default to no authids eligible
if (isset($options->_thruway_eligible_authids)) {
if (is_array($options->_thruway_eligible_authids)) {
$this->eligible_authids = $options->_thruway_eligible_authids;
// Support both the standard and prefixed versions of eligible_authids, preferring the prefixed version
$authids = $options->_thruway_eligible_authids ?? $options->eligible_authid ?? null;
if (isset($authids)) {
if (is_array($authids)) {
$this->eligible_authids = $authids;
}
} else {
$this->eligible_authids = null; // null says every authid is valid
Expand Down

0 comments on commit c57aa42

Please sign in to comment.