d2d3 / openid-integration
Package supports OpenId integration
Requires
- php: ^7.4|^8.0
This package is not auto-updated.
Last update: 2025-07-18 08:15:47 UTC
README
* I will call the Login system OpenID System (OID) * Dependent projects that want to use login from OID are Relying Party (RP) 1. OID: - Provide login and registration forms for applications (App). - Manage RPs, where each RP needs to register with OID the following information: + client_id: application identification. + client_secret: secret key to authenticate RP with OID. + redirect_uri: the path OID will send response after authentication is complete. - After registration, each RP receives 3 links: + GET Login link: RP will redirect users to this path to log in. + POST API to get user information: RP sends AUTH_CODE to get user information. + POST API migrate user: RP can transfer user information to OID. - OID will return the env variables that need to be added to RP's .env 2. RP login: - When the user enters the RP's login page, RP will redirect to the login link from OID. - The user logs in with username/password, then OID will return the AUTH_CODE via redirect_uri. - redirect_uri will receive the AUTH_CODE and send it to the /userInfo endpoint with {client_secret} to get user information - RP will create a new user if there is no user corresponding to this email in the RP system
We need 7 steps for integration OpenId in your app
Step 1: Register app in OpenId
Redirect URI
This URL is used to get the authorization_code from OpenId. Normally, I would use the login URL to handle that too.
Step 2: Copy all Environment Variables and paste to your .env
Step 3: In your App install d2d3/openid-integration pakage
composer require d2d3/openid-integration
Step 4: Create one route api loginWithAuthCode
Step 5: LoginWithAuthCode
-
Use D2d3\OpenidIntegration\Http\Services\OauthService::loginWithAuthCode for get Userdata
-
Determine if the user already exists by Email. If the user does not exist, create a new one. If it exists, update based on information received from OpenId.
Step 6: On the user interface side: Create one link redirect to env.VUE_APP_D2D3_OID_LOGIN_URL
Step 7: At the RedirectUri route that you provide for OpenID. Handle AUTH_CODE received from the param on the url to login
You can sync user from your app to OpenId with one command
php artisan openid:sync-userThis command will get 'email', 'email_verified_at', 'first_name', 'last_name', 'phone', 'password' of your app and sync to OpenId
In case you want to sync user to OpenId when updating and creating new user, use
SyncDataService::syncUser($email)