Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Oauth2 Azure

Oauth2 Azure Laravel Package

thenetworg/oauth2-azure

View on GitHub
Deep Wiki
Context7

Azure AD provider for the OAuth 2.0 Client.

Frequently asked questions about Oauth2 Azure
How do I install thenetworg/oauth2-azure in a Laravel project?
Run `composer require thenetworg/oauth2-azure` in your project directory. The package extends the League OAuth2 Client, so ensure you also have `league/oauth2-client` installed (v1.3.0+). No additional Laravel-specific dependencies are required.
Which Laravel versions does this package support?
The package itself is framework-agnostic, but it works seamlessly with Laravel 8.x, 9.x, and 10.x. It leverages Laravel’s Service Container and Session handling, so ensure your project uses these core features.
Can I use this package for Azure AD B2C authentication?
Yes, the package includes experimental B2C support. Configure your Azure AD app registration with B2C policies and set the appropriate `defaultEndPointVersion` (e.g., `v2.0`). Note that B2C features may require customization for edge cases.
How do I handle token refreshes for long-lived sessions?
The package supports multipurpose refresh tokens, which simplify multi-resource access. Store refresh tokens in your database (e.g., `oauth_tokens` table) and use the provider’s `getAccessToken()` method with the refresh token to obtain new access tokens when expired.
Is client certificate authentication supported, and how do I configure it?
Yes, the package supports certificate-based authentication. Provide the `clientCertificatePrivateKey` and `clientCertificateThumbprint` in the provider configuration. Ensure your Azure AD app registration is configured to use certificates instead of client secrets.
How can I validate Azure AD tokens in Laravel middleware?
Create middleware to validate tokens using the provider’s `validateAccessToken()` method. Inject the Azure provider into the middleware via Laravel’s Service Container and check the token from the request (e.g., `bearerToken()`). Example: `$provider->validateAccessToken($token);`.
Does this package support the 'on-behalf-of' flow for delegated permissions?
Yes, the package includes experimental support for the 'on-behalf-of' flow. Use the `getAccessTokenForApp()` method to obtain a token for another application, passing the initial access token and the target app’s client ID. This is useful for service-to-service delegation.
How do I protect API endpoints with Azure AD tokens?
Use the experimental `protectApi()` method to validate tokens for protected endpoints. Bind the provider to Laravel’s Service Container and call `$provider->protectApi($request)` in middleware or controllers. This ensures only valid tokens can access your API.
Are there any known issues with Microsoft Graph API changes?
Microsoft Graph API evolves frequently, and the package may lag in supporting new endpoints (e.g., `/v1.0` vs `/beta`). Monitor Microsoft’s documentation for changes and update the `resource` parameter in your provider configuration to match the latest Graph API version.
What alternatives exist for Azure AD OAuth in Laravel?
Alternatives include `azure/active-directory` (official Microsoft SDK) or `laravel-socialite/azure` (if using Socialite). However, `thenetworg/oauth2-azure` is tailored specifically for Laravel’s ecosystem, offering deeper integration with Service Container, Sessions, and middleware.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor
spatie/laravel-javascript-views