Answer the question
In order to leave comments, you need to log in
How to configure UserProvider for Oauth(azure)?
I'm trying to set up authorization using Azure AD
Installed the HWIOAuthBundle
set up the creds
#config/packages/hwi_oauth.yaml
hwi_oauth:
# list of names of the firewalls in which this bundle is active, this setting MUST be set
firewall_names: [azure]
resource_owners:
microsoft:
type: azure
client_id: '%env(MICROSOFT_CLIENT_ID)%'
client_secret: '%env(MICROSOFT_CLIENT_SECRET)%'
scope: User.Read offline_access
options:
application: common
#config/routes.yaml
microsoft_login:
path: /oauth-login/check-microsoft
#config/routes/hwi_oauth_routing.yaml
hwi_oauth_redirect:
resource: "@HWIOAuthBundle/Resources/config/routing/redirect.xml"
prefix: /connect
hwi_oauth_connect:
resource: "@HWIOAuthBundle/Resources/config/routing/connect.xml"
prefix: /connect
hwi_oauth_login:
resource: "@HWIOAuthBundle/Resources/config/routing/login.xml"
prefix: /oauth-login
#config/packages/security.yaml
security:
enable_authenticator_manager: true
# https://symfony.com/doc/current/security.html#registering-the-user-hashing-passwords
password_hashers:
Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface: 'auto'
# https://symfony.com/doc/current/security.html#loading-the-user-the-user-provider
encoders:
App\Entity\User:
algorithm: bcrypt
providers:
users_in_memory: { memory: null }
entity_provider:
entity:
class: App\Entity\User
property: username
microsoft_user_provider:
id: app.custom.user_provider
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
pattern: ^/
provider: entity_provider
form_login:
login_path: login_admin
check_path: login_admin
default_target_path: admin_contract_list
always_use_default_target_path: true
logout:
path: logout_admin
target: login_admin
azure:
pattern: ^/
oauth:
resource_owners:
microsoft: "/oauth-login/check-microsoft"
login_path: /oauth-login
use_forward: false
failure_path: /oauth-login
oauth_user_provider:
service: mf.oauth_aware.user_provider.service
provider: microsoft_user_provider
access_control:
# - { path: ^/, roles: ROLE_USER }
- { path: ^/oauth-login, roles: PUBLIC_ACCESS }
http://localhost:8001/oauth-login/check-microsoft?code=M.R3_BAY.a40cbc79.....&state=eyJjc3JmX3Rva2VuIjoiMjhiMzZ....
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question