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

(Non)authenticated realm issue #347

Open
schtr4jh opened this issue Oct 22, 2020 · 1 comment
Open

(Non)authenticated realm issue #347

schtr4jh opened this issue Oct 22, 2020 · 1 comment

Comments

@schtr4jh
Copy link

schtr4jh commented Oct 22, 2020

So, I've spent a few hours debugging how to allow non-authenticated users to subscribe to the uri, and allow authenticated users (AuthenticationManager+WampCraAuthProvider) to publish messages to the same uri in the same realm.

AuthorizationManager rules:

[
    "role" => "anonymous",
    "action" => "subscribe",
    "uri" => "search.",
    "allow" => true,
],
[
    "role" => "user",
    "action" => "publish",
    "uri" => "search.",
    "allow" => true,
],

Is this maybe incorrect?

// If no authentication providers are registered for this realm send an abort message
if ($this->realmHasAuthProvider($realm->getRealmName())) {
$session->abort(new \stdClass(), 'wamp.error.not_authorized');
return;
}
//If we've gotten this far, it means that the user needs to be Logged in as anonymous
$session->setAuthenticationDetails(AuthenticationDetails::createAnonymous());

Based from the comment, it should be negated as:

if (!$this->realmHasAuthProvider($realm->getRealmName())) {

With this change in place, the setup works as expected. PHPUnit shows the same output:
Tests: 139, Assertions: 608, Errors: 6, Failures: 23, Skipped: 2

@schtr4jh
Copy link
Author

@davidwdan @mbonneau Any feedback?

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

No branches or pull requests

1 participant