Welcome to yii-auth-client Discussions! #4
Replies: 1 comment
-
OAuth2 clients can be augmented with an additional layer Iodc? You're correct that OpenID Connect (OIDC) is an authentication protocol built on top of OAuth2, adding an identity layer. Since your repository, rossaddison/yii-auth-client, is for Yii Framework external authentication via OAuth and OpenID, integrating OIDC support is a logical extension. Here's how you could approach adding OIDC support to your Yii authentication client: 1. Understand the Protocol Differences
2. Identify Where OAuth2 Logic ExistsLook for the part of your codebase that handles OAuth2 flows (likely classes related to clients, token exchange, and user info retrieval). 3. Extend or Add an OIDC Client
4. Update the Authorization and Token Logic
5. Fetch User Info
6. Integrate with Yii User Authentication
Example: Basic PHP OIDC IntegrationPseudo-code for the main parts: // 1. Build the auth URL with 'openid' scope
$authUrl = $oidcProvider->getAuthorizationUrl([
'scope' => 'openid profile email'
]);
// 2. Exchange code for tokens (access_token, id_token)
$tokenData = $oidcProvider->getAccessToken('authorization_code', [
'code' => $_GET['code'],
]);
$idToken = $tokenData['id_token'];
// 3. Validate id_token (using a JWT library)
$claims = $jwtLibrary->decode($idToken, $providerPublicKey);
// 4. Use claims for Yii user authentication
$user = Yii::$app->user->loginByOidcClaims($claims); Libraries & References
Next Steps
If you want code samples for a specific step, let me know which part you’d like to see! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
👋 Welcome!
We’re using Discussions as a place to connect with other members of our community. We hope that you:
build together 💪.
To get started, comment below with an introduction of yourself and tell us about what you do with this community.
Beta Was this translation helpful? Give feedback.
All reactions