antwerpes/socialite-doccheck

DocCheck Login Provider for Laravel Socialite

Maintainers

Package info

github.com/antwerpes/socialite-doccheck

pkg:composer/antwerpes/socialite-doccheck

Statistics

Installs: 63

Dependents: 0

Suggesters: 0

Stars: 1

Open Issues: 3

2.0.0 2026-05-06 07:56 UTC

README

Latest Version on Packagist GitHub Code Style Action Status Total Downloads

Laravel Socialite provider for the DocCheck Login. Compatible with both economy and business licenses.

Installation

You can install the package via composer:

composer require antwerpes/socialite-doccheck

Update your services configuration (config/services.php) with the following entry:

'doccheck' => [
    'client_id' => env('DOCCHECK_CLIENT_KEY'),
    'client_secret' => env('DOCCHECK_CLIENT_SECRET'),
    'redirect' => env('DOCCHECK_REDIRECT_URI'),
    'language' => env('DOCCHECK_LANGUAGE', 'de'),
    'template' => env('DOCCHECK_TEMPLATE', 'fullscreen_dc'),
    'license' => env('DOCCHECK_LICENSE', 'economy'),
],

Usage

After setting up the environment variables (see configuration above), you may use this provider as any other Socialite provider, see also Socialite documentation. The user object returned by the provider differs by license. For the economy license, only an ID will be present. For the business license all other fields will also be present.

Example code:

<?php

use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Laravel\Socialite\Facades\Socialite;

class LoginController extends Controller
{
    public function handleProviderCallback(Request $request)
    {
        $details = Socialite::driver('doccheck')->user();
         
        $user = User::query()
            ->firstOrNew([
                'id' => $details->getId(),
            ])
            // Only available with the `business` license
            ->fill([
                'email' => $details->getEmail(),
                'first_name' => $details->first_name,
                'last_name' => $details->last_name,
                'title' => $details->title,
                'street' => $details->street,
                'postal_code' => $details->street,
                'city' => $details->city,
                'country' => $details->country,
                'language' => $details->language,
                'gender' => $details->gender,
                'profession_id' => $details->profession_id,
                'discipline_id' => $details->discipline_id,
            ]);
        $user->save();
        auth()->login($user);
        
        return redirect()->intended('/');
    }
}

Login button in Blade

You can either render the DocCheck Login button with the DocCheck Web Component or pass the Login URL directly to a Blade template.

If you want to pass the generated URL directly:

public function showLoginForm(): Response
{
    $url = Socialite::driver('doccheck')->redirect()->getTargetUrl();

    return response()->view('auth.login', [
        'url' => $url,
    ]);
}

Blade Template:

<a href="{{ $url }}">Login with DocCheck</a>

If you want to render the Login with DocCheck Button using the Web Component, also extract and pass the state parameter:

public function showLoginForm(): Response
{
    $url = Socialite::driver('doccheck')->redirect()->getTargetUrl();
    $state = null;
    $query = parse_url($url, PHP_URL_QUERY);

    if (is_string($query)) {
        parse_str($query, $params);
        $state = $params['state'] ?? null;
    }

    return response()->view('auth.login', [
        'url' => $url,
        'state' => $state,
    ]);
}

Blade example (DocCheck Web Component):

<script src="[latest main.js]"></script>
<dc-login-button
    size="medium"
    language="en"
    loginClientId="{{ config('services.doccheck.client_id') }}"
    redirectUri="{{ config('services.doccheck.redirect') }}"
    scope="unique_id profession country language"
    state="{{ $state }}"
></dc-login-button>

The callback logic stays the same (see example above).

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Contributions are welcome! Leave an issue on GitHub, or create a Pull Request.

License

The MIT License (MIT). Please see License File for more information.