tourze/real-name-authentication-bundle
A Symfony bundle from tourze for real-name authentication (实名认证). It provides reusable services and integration points to verify user identity, manage verification status, and add real-name checks to registration or account flows.
composer require tourze/real-name-authentication-bundle
0.0.1 is the initial tagged release and ships with nothing but a changelog link — there is no README-level API documentation, no upgrade guide, and no stability guarantee. Budget your first hour for reading source, not for wiring it into a feature.
Where to look first, in order:
Tourze\RealNameAuthenticationBundle\RealNameAuthenticationInterface with a single authenticate(string $name, string $idNumber): bool-style method. This interface is the only surface you should couple your application to.Resources/config/services.yaml or a *Bundle class. If all you find is Symfony service config, there is no Laravel service provider and you will bind everything yourself.composer.json of the package. Check whether it drags in symfony/http-kernel, Doctrine, or an HTTP client. composer show tourze/real-name-authentication-bundle --tree before you commit to it.First use case: gate a single high-value action — payout, withdrawal, account upgrade, marketplace seller onboarding — behind a one-time name + ID-number check. Do not model your registration flow around it yet.
// app/Providers/AppServiceProvider.php
public function register(): void
{
$this->app->bind(
\Tourze\RealNameAuthenticationBundle\RealNameAuthenticationInterface::class,
\App\Services\RealName\VendorRealNameAuthenticator::class,
);
}
Wrap the interface, never call it from controllers. The package is an abstraction seam, not a service. Put a thin application-level service in front of it so you can add caching, auditing, and retries without touching vendor code.
final class RealNameVerifier
{
public function __construct(
private readonly RealNameAuthenticationInterface $authenticator,
) {}
public function verify(User $user, string $realName, string $idNumber): VerificationResult
{
$result = $this->authenticator->authenticate($realName, $idNumber);
RealNameRecord::create([
'user_id' => $user->id,
'real_name' => $realName, // encrypt this cast
'id_number' => $idNumber, // encrypt this cast
'passed' => $result,
'checked_at' => now(),
]);
return new VerificationResult($result);
}
}
Store your own records. If the bundle ships Doctrine entities, do not try to make them coexist with Eloquent. Keep an real_name_records table of your own — you need it for audit trail, dispute handling, and rate limiting anyway, and a future 0.x bump that reshapes the vendor's entity won't take your schema with it.
Queue it. Real-name checks hit a third-party network and are the slowest thing in an onboarding request. Dispatch a job, return 202, and surface status through a verified_at timestamp or a dedicated status column on users.
VerifyRealName::dispatch($user, $realName, $encryptedIdNumber)
->onQueue('verification');
Fire domain events (RealNameVerified, RealNameRejected) from the job rather than from the vendor callback — it keeps the package at arm's length and gives you a single place to add telemetry.
Gate features with middleware, not scattered ifs. Once verified_at is set, a EnsureRealNameVerified middleware plus a Gate::define('payout', ...) covers every call site.
Fake it in tests. Bind a deterministic fake to the interface in TestCase::setUp() so the suite never touches the real provider:
$this->app->bind(RealNameAuthenticationInterface::class, fn () => new class implements RealNameAuthenticationInterface {
public function authenticate(string $name, string $idNumber): bool
{
return $idNumber === '110101199003071234';
}
});
Keep the provider behind your own port. If you anticipate switching vendors, define App\Contracts\RealNameProvider and write a one-class adapter that implements both your contract and the Tourze interface. The day the bundle is abandoned (a real risk at 0.0.1), you delete the adapter and nothing else.
extra.laravel.providers, which this almost certainly does not. Expect to bind the interface manually — and expect the shipped service definitions to be inert under Laravel."tourze/real-name-authentication-bundle": "0.0.1" — not ^0.0.1. At 0.x, semver explicitly allows breaking changes on any minor bump, and this vendor moves fast. Treat every upgrade as a code review.src/ directory between tags before bumping. composer update --dry-run will not tell you that a method signature changed.id_number and real_name, never log the raw payload, never put an ID number in a queue payload or an exception message, and mask it (110101********1234) in any admin UI. If the package logs request bodies internally, that's a blocker — check its HTTP client usage.null or throw. Stub implementations in early-stage bundles frequently return null, throw LogicException('not implemented'), or return true unconditionally. Do not treat a truthy return as proof of identity until you have read the implementation you actually bound.APP_KEY. Rotating it makes every historical id_number unreadable. If you need long-term auditability, use a dedicated key or store a salted hash of the ID number alongside the encrypted value.RealNameAuthenticationException hierarchy (catch the base class, not the leaves), and any configuration tree. Bind to interfaces and catch base exceptions so a 0.0.2 refactor of leaf classes doesn't break you.composer.json line.How can I help you explore Laravel packages today?