Download the PHP package bannerstop/keycloak-bundle without Composer

On this page you can find all versions of the php package bannerstop/keycloak-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 keycloak-bundle

bannerstop/keycloak-bundle

Symfony integration of bannerstop/keycloak: single sign-on with Keycloak for the Symfony security component.

Versions

Version PHP Symfony
1.x ≥ 7.1.3 4.4 (Guard), 5.4 (Guard or authenticator system)
2.x ≥ 7.2 4.4 (Guard), 5.4 (Guard or authenticator system)
3.x ≥ 7.3 4.4 (Guard), 5.4 (Guard or authenticator system)
4.x ≥ 7.4 4.4 (Guard), 5.4 (Guard or authenticator system)
5.x ≥ 8.0 5.4, 6.x (authenticator system)
6.x ≥ 8.1 5.4, 6.4
7.x ≥ 8.2 6.4, 7.x
8.x ≥ 8.3 6.4, 7.x
9.x ≥ 8.4 7.4, 8.x
10.x ≥ 8.5 7.4, 8.x

Installation

Without Symfony Flex, register the bundle in config/bundles.php:

Import the routes (/login/keycloak and /login/keycloak/callback), e.g. in config/routes/bannerstop_keycloak.yaml:

In Keycloak, register https://your-app.example/login/keycloak/callback as redirect URI and your logout target as post logout redirect URI. See the core README for the full client setup.

Configuration

directory gives the user directory (UserDirectory, admin REST API) its own confidential client. We recommend it: create a client with only Service accounts roles enabled and assign realm-management → view-users to its service account, so that the login client has no admin API rights. Without directory, the login client is used for both and needs the service account and view-users itself.

cache (default cache.app) caches the discovery document and the signing keys. http_client, request_factory and stream_factory take service ids if you do not use symfony/http-client.

Security

Your own users

By default users only live in the session (KeycloakUser, identified by the Keycloak subject) and are served by bannerstop_keycloak.user_provider.

To use your own user entity instead, implement Bannerstop\KeycloakBundle\User\UserProvisioner. After every successful login and every accepted bearer token, the bundle calls provision() with the verified identity and the mapped roles; the user it returns is the authenticated user. Link accounts by the Keycloak subject, not by e-mail address, which can change:

user_provisioner is an option of this bundle (not of Symfony itself) and takes the service id of your provisioner. With autowiring, the id is the class name:

The firewall then uses your usual entity provider instead of bannerstop_keycloak.user_provider:

The provisioner hands Symfony the user at login; on every following request Symfony reloads it through the firewall's provider. That provider must therefore return the same entity class.

remember_me on the firewall applies to Keycloak logins as well. It needs a user with a password property or other signature_properties, so it works with your own users, not with the session-only KeycloakUser.

Ending sessions with Keycloak

Logging out of Keycloak, or of another application, does not end the Symfony session by itself. The bundle closes that gap in two ways:

On the next request after its Keycloak session ended, a session is logged out (including the remember-me cookie): pages redirect to themselves, so the firewall's entry point asks for a new login, and XHR/JSON requests get a 401. Only sessions that came from a Keycloak login are checked.

Keycloak does not always send a back-channel call for every session, e.g. when an administrator signs a user out of all sessions. Keep check_interval switched on as a safety net; 300 seconds is a good start.

Login errors

A failed login redirects to failure_path. AuthenticationUtils::getLastAuthenticationError() then returns an exception whose message key is one of keycloak.login.state_mismatch, .cancelled, .provider_error, .invalid_token or .not_allowed. Translate them in the security domain.

Services

Service Use
Bannerstop\Keycloak\KeycloakClient refresh tokens, userinfo, verify tokens yourself
Bannerstop\Keycloak\Admin\UserDirectory list users of the realm through the service account of the directory client, or of the login client (view-users)
Bannerstop\Keycloak\Role\RoleMapper the configured role mapping

License

MIT, see LICENSE. Security issues: see the core package's security policy.


All versions of keycloak-bundle with dependencies

PHP Build Version
Package Version
Requires php Version ^8.5
bannerstop/keycloak Version ^10.1
symfony/config Version ^7.4 || ^8.0
symfony/dependency-injection Version ^7.4 || ^8.0
symfony/framework-bundle Version ^7.4 || ^8.0
symfony/http-foundation Version ^7.4 || ^8.0
symfony/http-kernel Version ^7.4 || ^8.0
symfony/routing Version ^7.4 || ^8.0
symfony/security-bundle Version ^7.4 || ^8.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 bannerstop/keycloak-bundle contains the following files

Loading the files please wait ...