Closed JonnyD closed 6 years ago
In your config, you have:
hwi_oauth:
# name of the firewall in which this bundle is active, this setting MUST be set
firewall_name: secured_area
but hwi_oauth is not active in your firewall_name
firewall
What do you mean? I have secured_area
in the list of firewalls in security.yml
or am I missing something else?
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
login:
pattern: ^/login$
security: false
secured_area:
pattern: ^/
form_login:
login_path: login
check_path: login_check
default_target_path: /
always_use_default_target_path: true
logout:
path: logout
target: /
anonymous: ~
http_basic:
realm: "Secured Demo Area"
you have this firewall, but it only has form_login and http_basic as authentication ways, not OAuth
Ah I see, I totally overlooked this part of the documentation: https://github.com/hwi/HWIOAuthBundle/blob/master/Resources/doc/3-configuring_the_security_layer.md
Thanks!
Note: I had a similar error, because I had a mistake in my security.yml
config...(firewalls was specified twice).
security:
providers:
in_memory:
memory: ~
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
default:
anonymous: ~
firewalls:
secured_area:
anonymous: ~
oauth:
resource_owners:
my_github: "/login/check-github"
login_path: /login
use_forward: false
failure_path: /login
oauth_user_provider:
service: hwi_oauth.user.provider
access_control:
- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
For posterity, I was seeing this error...but only when I tried to run unit tests.
Adding this to a service definition file (facebook.xml) did the trick:
<!-- HWIOAuth has a dynamically-named dependency: a service with id "hwi_oauth.resource_ownermap.%s",
where %s is the firewall_name assigned to hwi_oauth. The firewall_name we gave hwi_oauth is "main"
(see config.yml). Below, we pre-emptively declare a service named "hwi_oauth.resource_ownermap.main".
If we don't do this, the service is "non-existent" when unit tests are run, and they fail.-->
<service id="hwi_oauth.resource_ownermap.main"
class="HWI\Bundle\OAuthBundle\Security\Http\ResourceOwnerMap">
<argument type="service" id="security.http_utils" />
<argument type="collection"/>
<argument type="collection"/>
</service>
If you run into the same issue, make sure you replace "main" with whatever your firewall_name
is. If it's "secured_area" you'd want to add:
<service id="hwi_oauth.resource_ownermap.secured_area"
class="HWI\Bundle\OAuthBundle\Security\Http\ResourceOwnerMap">...</service>
Has this issue been resolved? I'm using symfony4 and getting the same error. Followed up the advice from the comments, but no success.
problem "solved" when we add public: true in the ResourceOwnerMap declaration service (as proposed by @carawarner ) in SF 4.0.9
:+1:
Routing
Security
Config