Download the PHP package kematjaya/auth-bundle without Composer

On this page you can find all versions of the php package kematjaya/auth-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package auth-bundle

kematjaya/auth-bundle

API-first, stateless JWT authentication and simple array-based RBAC for Symfony. Built for apps exposing a JSON API (API Platform friendly) consumed by a decoupled frontend (e.g. Next.js) - not for server-rendered/session apps. For that use case, see kematjaya/user-bundle instead.

Ships: register, login (via lexik/jwt-authentication-bundle), refresh (via gesdinet/jwt-refresh-token-bundle), logout (refresh token revocation), change password, GET /api/me, a per-IP+email rate limiter on login/register, and an optional API Platform OpenAPI documentation decorator.

No UI. Frontend integration (Next.js) is a separate package, @kematjaya/auth-ui.

Why "bring your own User entity"

Your app almost certainly already has a User entity referenced by other domain entities (e.g. Note.owner). This bundle can't own that class - it would create a circular dependency (the bundle can't depend on the app that depends on it), and it would make the entity disappear the moment the bundle is removed, breaking every relation to it.

Instead the bundle depends on two small interfaces from Kematjaya\AuthBundle\Contract:

Installation

Requirements

Quick install

You'll likely see a cache:clear error flash by right after composer require finishes. That's expected, not a failure: Gesdinet's bundle needs config that setup.sh hasn't copied in yet at that point in time. The package itself installs fine - ignore the error and run setup.sh.

That's it for a fresh project with no User entity yet. If you already have one, see Bring your own User entity below before running setup.sh.

What setup.sh does

It's idempotent - safe to re-run any time, it skips any file that already exists (--force to overwrite). It exists because this bundle isn't published to a Flex recipes endpoint yet, so it does by hand everything a real recipe would do automatically on composer require:

# Step Result
1 Registers the bundle adds a line to config/bundles.php
2 Copies config fragments config/packages/lexik_jwt_authentication.yaml, gesdinet_jwt_refresh_token.yaml, kematjaya_auth_doctrine_types.yaml (registers the Doctrine uuid type the User template below uses), config/routes/kematjaya_auth.yaml
3 Copies User plumbing src/Entity/User.php, src/Repository/UserRepository.php, src/Security/UserManager.php - skipped if you already have your own
4 Wires the DI binding Kematjaya\AuthBundle\Contract\UserManagerInterface -> App\Security\UserManager in config/services.yaml
5 Generates the JWT keypair lexik:jwt:generate-keypair --skip-if-exists, appends JWT_SECRET_KEY/JWT_PUBLIC_KEY/JWT_PASSPHRASE to .env (change the passphrase before deploying!)
6 Updates the schema php bin/console doctrine:schema:update --force

The one manual step

setup.sh prints this reminder at the end - it is not automated on purpose:

Merge config/packages/kematjaya_auth_security.yaml.dist into your own config/packages/security.yaml (providers / firewalls / access_control). It was copied with a .dist suffix specifically so Symfony does not auto-load it - it auto-loads every .yaml file under config/packages/, and dropping a second firewalls: main: definition there would collide with the one your app's skeleton already has. Open both files side by side and merge the relevant blocks in yourself.

Until that merge is done, the bundle's routes exist but nothing is authenticated or protected by JWT.

Also double check that symfony/security-bundle, lexik/jwt-authentication-bundle, and gesdinet/jwt-refresh-token-bundle all ended up registered in config/bundles.php. Most auto-register via their own official Flex recipes, but --no-interaction/CI installs sometimes skip contrib recipes - setup.sh only registers this bundle, not its dependencies' bundles.

Bring your own User entity

If you already have a User entity (most real projects will), put it at src/Entity/User.php before running setup.sh so step 3 skips it instead of overwriting it. If you already ran setup.sh, just delete the copied file and put your own there instead. Then:

  1. Make your entity implements Kematjaya\AuthBundle\Contract\AuthenticatableUserInterface.
  2. Adapt src/Security/UserManager.php (still copied by setup.sh) to your entity/repository.

See Why "bring your own User entity" above for why this last part can't be automated further.

Uninstall (clean baseline)

composer remove kematjaya/auth-bundle, remove the bundle line from config/bundles.php, remove src/Security/UserManager.php and the kematjaya_auth_* files under config/packages/ and config/routes/, and remove the merged block from your own security.yaml. Your User entity stays untouched (it never depended on this bundle at the class level) - only remove the implements AuthenticatableUserInterface clause if you want it gone too.

Endpoints

Method Path Auth required
POST /api/register no
POST /api/login no
POST /api/token/refresh no
POST /api/logout no (revokes by possession of the refresh token)
GET /api/me yes
POST /api/change-password yes

Configuration

None. This bundle is intentionally zero-config - see the "Why bring your own User entity" section for why a user_class option was deliberately avoided. The rate limiter (5 requests/minute per IP+email on /api/login and /api/register) can be overridden by defining framework.rate_limiter.kematjaya_auth_authentication yourself before this bundle's prependExtension() runs, i.e. in your own config/packages/framework.yaml.

Testing


All versions of auth-bundle with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4
symfony/config Version ^7.0|^8.0
symfony/dependency-injection Version ^7.0|^8.0
symfony/framework-bundle Version ^7.0|^8.0
symfony/http-foundation Version ^7.0|^8.0
symfony/http-kernel Version ^7.0|^8.0
symfony/password-hasher Version ^7.0|^8.0
symfony/rate-limiter Version ^7.0|^8.0
symfony/routing Version ^7.0|^8.0
symfony/security-bundle Version ^7.0|^8.0
symfony/security-core Version ^7.0|^8.0
symfony/serializer Version ^7.0|^8.0
symfony/uid Version ^7.0|^8.0
symfony/validator Version ^7.0|^8.0
symfony/yaml Version ^7.0|^8.0
lexik/jwt-authentication-bundle Version ^3.2
gesdinet/jwt-refresh-token-bundle Version ^2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package kematjaya/auth-bundle contains the following files

Loading the files please wait ...