webnode/oauth2-client

1.3.1 2024-09-26 09:58 UTC

README

Client for webnode auth/OAuth2

This can be used as SDK by partners, co no webnode library should be used.

Usage example

Instantiate factory

$factory = new \webnode\oauth2\Factory\WebnodeOAuth2Factory(
    new \webnode\oauth2\Configuration(
        'myClientId',
        'myClientSecret',
        'https://oauth2.webnode.com'
    )
);

Generate Single Sign On Url

// generate SSO Link
$oauthApiService = $factory->createApi();
$ssoUrl = $oauthApiService->getAuthorizationUrlForUser(
    $userIdentifier,// obtained from gateway-api with project info or registration
    $redirectUrl // CMS or Administration (portal) URL, both can be obtained with same request as userIdentifier 
);
// now just redirect to $ssoUrl

Generate Single Sign Out Url

// generate SSO Link
$urlGenerator = $factory->createUrlGenerator();
$ssOutUrl = $urlGenerator->getSSOutUrl(); // this url is universal, since it just disables access to current session
// now just redirect to $ssOutUrl

Logout user from all sessions

This can be used when changing password, disabling users access for violation and so on.

// generate SSO Link
$oauthApiService = $factory->createApi();
$urlGenerator->revokeUserAccess($userIdentifier);
// now just redirect to $ssOutUrl