Voyti

Voyti

User management, authentication & authorization

Social Auth

Social login is built on yiisoft/yii-auth-client's OAuth2 clients rather than a hand-rolled implementation. Voyti carries no OAuth2 protocol code, and no provider configuration, of its own - providers are configured entirely through that package's own params/DI, not through any Voyti-owned option. The redirect/callback flow is handled directly by the vendor's AuthAction PSR-15 middleware, wired in Voyti's config/di.php as the voyti/session-auth route action with Voyti's own success/cancel callbacks.

Configuring providers

Configure providers via a clients map under the yiisoft/yii-auth-client params key. Voyti configures each client's OAuth2 return URL for you automatically, keyed to match its own clients entry. Alternatively you can set a callback URL manually by adding an oauth2ReturnUrl key to that client's config - Voyti only fills it in when it's left unset.

// config/params.php
return [
    'yiisoft/yii-auth-client' => [
        'clients' => [
            'github' => [
                'class' => \Yiisoft\Yii\AuthClient\Client\GitHub::class,
                'clientId' => $_ENV['GITHUB_CLIENT_ID'],
                'clientSecret' => $_ENV['GITHUB_CLIENT_SECRET'],
            ],
            'google' => [
                'class' => \Yiisoft\Yii\AuthClient\Client\Google::class,
                'clientId' => $_ENV['GOOGLE_CLIENT_ID'],
                'clientSecret' => $_ENV['GOOGLE_CLIENT_SECRET'],
            ],
        ],
    ],
];

With yiisoft/config installed (the standard way to run a Yii3 app), this is all that's needed - the package's own config/di.php is merged in automatically once it's composer required. See yii-auth-client's own Quick Start guide for the full option set each client supports (custom scope via the scope key, extra auth-URL parameters, etc.).

Whatever key you pick also becomes part of the callback URL you'll need to register with the provider itself, as a full absolute URL: https://your-domain.tld/<prefix>/auth/<key>. Most providers' developer consoles require an exact match, so settle on your keys before registering each provider's OAuth app - changing a key later means updating that provider's redirect URI too.

Supported providers

Nine branded provider classes ship in yiisoft/yii-auth-client, each backed by its own Yiisoft\Yii\AuthClient\Client\* class (plus a generic Client\OpenIdConnect client - see below). Defaults (scope, endpoints) come entirely from the vendor client and its own DI wiring - see yii-auth-client's own docs for the full per-client option set.

Vendor class Notes
Client\FacebookThe vendor client's default requested fields don't include email; same as GitHub, Voyti leaves it null rather than issuing a secondary Graph API call.
Client\GitHubIf /user doesn't include an email (private-email accounts), Voyti leaves email null rather than issuing a secondary request - the user supplies one manually during the registration-connect flow.
Client\GoogleStandard id/email/name claims.
Client\LinkedInIdentity comes from the OIDC-style sub claim rather than id.
Client\MicrosoftHits the raw Microsoft Graph /v1.0/me endpoint (email under mail, name under displayName). Multi-tenant apps just add a tenant key to the clients entry - the client resolves its authUrl/tokenUrl placeholder against it internally.
Client\TikTokIdentity comes from open_id rather than id. Never returns email.
Client\VKontakteUses the newer VK ID endpoints (id.vk.ru) rather than the legacy oauth.vk.com/api.vk.com ones. The response has no username-like field at all - Voyti falls back to the email's local part.
Client\XResponse is unwrapped from its data envelope. Never returns email (X API v2 doesn't expose it without elevated access).
Client\YandexEmail read from default_email.

How it works

With providers configured:

  1. The login page shows social login buttons for configured providers.
  2. settings/networks/ lists connected providers and renders connect buttons for the remaining configured providers.
  3. New social identities redirect to the registration connect screen, where users can log in to an existing account or register a new one before the identity is linked.

When yiisoft/yii-auth-client isn't installed, every controller/view that touches social login (SessionController, SocialNetworkController, RegistrationController, and the login page's connect-button list) degrades gracefully: no providers are listed, and the voyti/session-auth route itself is never registered.

Generic self-hosted OpenID Connect identity providers aren't part of Voyti's built-in provider list. yii-auth-client ships a generic Client\OpenIdConnect class capable of real OIDC discovery and token validation - wiring one up is entirely the host application's own responsibility, configured the same way as any other client above.