PhoenixKitWeb.Plugs.EnsureOAuthConfig (phoenix_kit v1.5.1)
View SourcePlug that ensures OAuth configuration is loaded before processing OAuth requests.
This plug serves as a fallback safety mechanism for cases where:
- PhoenixKit.Supervisor starts AFTER parent application's Endpoint
- OAuthConfigLoader worker failed to load configuration
- Configuration was cleared or lost for any reason
How It Works
- Checks if Ueberauth has :providers configured
- If configuration is missing or invalid, loads it synchronously
- If loading fails, returns 503 Service Unavailable error
- Otherwise, allows request to proceed normally
Usage
Add this plug BEFORE Ueberauth plug in OAuth controller:
plug PhoenixKitWeb.Plugs.EnsureOAuthConfig
plug UeberauthWhy This Is Needed
Ueberauth plug expects :providers key to exist in application config. If it's missing, Ueberauth.get_providers/2 fails with MatchError.
This plug prevents that error by ensuring configuration exists before Ueberauth plug runs.