PHPackages                             danskernesdigitalebibliotek/agency-auth-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. danskernesdigitalebibliotek/agency-auth-bundle

ActiveSymfony-bundle[Authentication &amp; Authorization](/categories/authentication)

danskernesdigitalebibliotek/agency-auth-bundle
==============================================

Agency authentication against the Open Platform

3.0.0(3y ago)03.9kAGPL-3.0-onlyPHPPHP ^8.1CI failing

Since Jun 24Pushed 3y ago3 watchersCompare

[ Source](https://github.com/danskernesdigitalebibliotek/agency-auth-bundle)[ Packagist](https://packagist.org/packages/danskernesdigitalebibliotek/agency-auth-bundle)[ RSS](/packages/danskernesdigitalebibliotek-agency-auth-bundle/feed)WikiDiscussions develop Synced 3w ago

READMEChangelog (7)Dependencies (12)Versions (11)Used By (0)

Agency Auth Bundle
==================

[](#agency-auth-bundle)

[![Github](https://camo.githubusercontent.com/8190d597e3a3e6872c0a4b9f8c833dd786786bea04b2b0bdd525312cf30759ae/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f736f757263652d64616e736b65726e65736469676974616c656269626c696f74656b2f6167656e63792d2d617574682d2d62756e646c652d626c75653f7374796c653d666c61742d737175617265)](https://github.com/danskernesdigitalebibliotek/agency-auth-bundle)[![Release](https://camo.githubusercontent.com/901d2a79c0181aaae4df2e3933198e572f86695093976b0c9936e87fbc9a318a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f64616e736b65726e65736469676974616c656269626c696f74656b2f6167656e63792d617574682d62756e646c652e7376673f7374796c653d666c61742d737175617265266c6162656c3d72656c65617365)](https://packagist.org/packages/danskernesdigitalebibliotek/agency-auth-bundle)[![PHP Version](https://camo.githubusercontent.com/41b25b3144a386af81c9ab7f8b5746355d4de000e47fced04944d1491393cba3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f64616e736b65726e65736469676974616c656269626c696f74656b2f6167656e63792d617574682d62756e646c652e7376673f7374796c653d666c61742d73717561726526636f6c6f72423d253233383839324246)](https://www.php.net/downloads)[![Build Status](https://camo.githubusercontent.com/51153d324549559debec437599148d06474a9f5e7f3691515f3ac9bd3e4bacae/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f64616e736b65726e65736469676974616c656269626c696f74656b2f6167656e63792d617574682d62756e646c652f54657374253230253236253230436f64652532305374796c652532305265766965773f6c6162656c3d4349266c6f676f3d676974687562267374796c653d666c61742d737175617265)](https://github.com/danskernesdigitalebibliotek/agency-auth-bundle/actions?query=workflow%3A%22Test+%26+Code+Style+Review%22)[![Codecov Code Coverage](https://camo.githubusercontent.com/b2cfe2aeaac28b67bc652e5c50b8bb74a0d88e6a5a1aa6c64e9b94bbdeae91e2/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f67682f64616e736b65726e65736469676974616c656269626c696f74656b2f6167656e63792d617574682d62756e646c653f6c6162656c3d636f6465636f76266c6f676f3d636f6465636f76267374796c653d666c61742d737175617265)](https://codecov.io/gh/danskernesdigitalebibliotek/agency-auth-bundle)[![Read License](https://camo.githubusercontent.com/393244a5d375cbda044cc499c1c2cca88ec00704aef783eb07f2d3b31f9b901c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f64616e736b65726e65736469676974616c656269626c696f74656b2f6167656e63792d617574682d62756e646c652e7376673f7374796c653d666c61742d73717561726526636f6c6f72423d6461726b6379616e)](https://github.com/danskernesdigitalebibliotek/agency-auth-bundle/blob/master/LICENSE.txt)[![Package downloads on Packagist](https://camo.githubusercontent.com/01198fe0d58970dd8e14bb453481b52330222761d6e85bd91ffe38759dbbb8bc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f64616e736b65726e65736469676974616c656269626c696f74656b2f6167656e63792d617574682d62756e646c652e7376673f7374796c653d666c61742d73717561726526636f6c6f72423d6461726b6d6167656e7461)](https://packagist.org/packages/danskernesdigitalebibliotek/agency-auth-bundle/stats)

This bundle enables *agency* ("library") authentication against the [Open Platform](https://openplatform.dbc.dk/v3/) (Shared API for danish public libraries). In order to use this bundle you must have a `CLIENT_ID / CLIENT_SECRET` pair from DBC.

The bundle validates *agency* access tokens against the Open Platform introspection endpoint. If a supplied token is valid a `User` object with `ROLE_OPENPLATFORM_AGENCY` will be available from Symfony's [security component](https://symfony.com/doc/4.4/security.html#b-fetching-the-user-from-a-service).

Note
----

[](#note)

If you need *user* ("personal") authentication you should use [danskernesdigitalebibliotek/oauth2-adgangsplatformen](https://github.com/danskernesdigitalebibliotek/oauth2-adgangsplatformen)

Installation
------------

[](#installation)

Use Composer to install the bundle: `composer require danskernesdigitalebibliotek/agency-auth-bundle`

Bundle Configuration
--------------------

[](#bundle-configuration)

Add a `config/packages/ddb_agency_auth.yaml` file:

```
ddb_agency_auth:
    # Your client id supplied by DBC
    openplatform_id: '%env(OPENPLATFORM_ID)%'

    # Your client secret supplied by DBC
    openplatform_secret: '%env(OPENPLATFORM_SECRET)%'

    # The introspection URL to query against
    openplatform_introspection_url: 'https://login.bib.dk/oauth/introspection'

    # A comma separated allow list of CLIENT_IDs. An empty list allows all.
    openplatform_allowed_clients: '%env(OPENPLATFORM_ALLOWED_CLIENTS)%'

    # [Optional] A service id for the cache service to use for caching token/user pairs
    auth_token_cache: token.cache

    # [Optional] A service id for the logger to use for error logging.
    auth_logger: logger
```

In your `.env` add:

```
###> Openplatform ###
OPENPLATFORM_ID=myId
OPENPLATFORM_SECRET=mySecret
OPENPLATFORM_INTROSPECTION_URL=https://login.bib.dk/oauth/introspection
OPENPLATFORM_ALLOWED_CLIENTS=''
###< Openplatform ###
```

Then set the actuel values in your `.env.local`. (See [configuration based on environment variables](https://symfony.com/doc/current/configuration.html#configuration-based-on-environment-variables))

Security Configuration
----------------------

[](#security-configuration)

Configure firewalls, access control and roles according to your needs in your `config/packages/security.yml`. The bundle provides a `TokenAuthenticator` you can use as a [custom authenticator](https://symfony.com/doc/current/security/custom_authenticator.html) and a `OpenPlatformUserProvider` you can use as a [custom user provider](https://symfony.com/doc/current/security/user_providers.html#creating-a-custom-user-provider). If authenticated it will return a [self validating passport](https://symfony.com/doc/current/security/custom_authenticator.html#self-validating-passport) with a `User` with the `ROLE_OPENPLATFORM_AGENCY`. You can use Symfonys [hierarchical roles](https://symfony.com/doc/4.4/security.html#hierarchical-roles)to map this role to your applications roles.

A working security configuration could be:

```
security:
    # https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
    providers:
        openplatform_provider:
            id: DanskernesDigitaleBibliotek\AgencyAuthBundle\Security\OpenPlatformUserProvider
    firewalls:
        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false
        main:
            stateless: true
            custom_authenticators:
                - DanskernesDigitaleBibliotek\AgencyAuthBundle\Security\TokenAuthenticator

    access_control:
        # Allows accessing the Swagger UI
        - { path: '^/api/docs', roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: '^/api', roles: ROLE_API_USER }

    role_hierarchy:
        ROLE_OPENPLATFORM_AGENCY: [ROLE_API_USER, ROLE_ENTRY_READ]
```

Development Setup
-----------------

[](#development-setup)

A `docker-compose.yml` file with a PHP 7.4 image is included in this project. To install the dependencies you can run

```
docker compose up -d
docker compose exec phpfpm composer install
```

### Unit Testing

[](#unit-testing)

A PhpUnit setup is included in this library. To run the unit tests:

```
docker compose exec phpfpm composer install
docker compose exec phpfpm ./vendor/bin/simple-phpunit
```

### Psalm static analysis

[](#psalm-static-analysis)

We are using [Psalm](https://psalm.dev/) for static analysis. To run psalm do

```
docker compose exec phpfpm composer install
docker compose exec phpfpm ./vendor/bin/psalm
```

### Check Coding Standard

[](#check-coding-standard)

The following command let you test that the code follows the coding standard for the project.

- PHP files (PHP-CS-Fixer)

    ```
    docker compose exec phpfpm composer check-coding-standards
    ```
- Markdown files (markdownlint standard rules)

    ```
    docker run -v ${PWD}:/app itkdev/yarn:latest install
    docker run -v ${PWD}:/app itkdev/yarn:latest check-coding-standards
    ```

### Apply Coding Standards

[](#apply-coding-standards)

To attempt to automatically fix coding style

- PHP files (PHP-CS-Fixer)

    ```
    docker compose exec phpfpm composer apply-coding-standards
    ```
- Markdown files (markdownlint standard rules)

    ```
    docker run -v ${PWD}:/app itkdev/yarn:14 install
    docker run -v ${PWD}:/app itkdev/yarn:14 apply-coding-standards
    ```

CI
--

[](#ci)

Github Actions are used to run the test suite and code style checks on all PR's.

If you wish to test against the jobs locally you can install [act](https://github.com/nektos/act). Then do:

```
act -P ubuntu-latest=shivammathur/node:latest pull_request
```

Versioning
----------

[](#versioning)

We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/itk-dev/openid-connect/tags).

License
-------

[](#license)

This project is licensed under the AGPL-3.0 License - see the [LICENSE.md](LICENSE.md) file for details

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 99.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~92 days

Recently: every ~166 days

Total

9

Last Release

1453d ago

Major Versions

0.3.0 → 1.0.02020-06-29

1.0.1 → 2.0.02021-07-06

2.1.1 → 3.0.02022-07-05

PHP version history (3 changes)0.1.0PHP ^7.3

2.0.0PHP ^7.4 | ^8.0

3.0.0PHP ^8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/33924554?v=4)[ITK Development](/maintainers/itk-dev)[@itk-dev](https://github.com/itk-dev)

---

Top Contributors

[![turegjorup](https://avatars.githubusercontent.com/u/5631988?v=4)](https://github.com/turegjorup "turegjorup (117 commits)")[![cableman](https://avatars.githubusercontent.com/u/111397?v=4)](https://github.com/cableman "cableman (1 commits)")

###  Code Quality

Static AnalysisPsalm

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/danskernesdigitalebibliotek-agency-auth-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/danskernesdigitalebibliotek-agency-auth-bundle/health.svg)](https://phpackages.com/packages/danskernesdigitalebibliotek-agency-auth-bundle)
```

###  Alternatives

[symfony/security-bundle

Provides a tight integration of the Security component into the Symfony full-stack framework

2.5k181.3M2.2k](/packages/symfony-security-bundle)[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.5M376](/packages/easycorp-easyadmin-bundle)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.4M196](/packages/sulu-sulu)[web-auth/webauthn-framework

FIDO2/Webauthn library for PHP and Symfony Bundle.

51390.8k2](/packages/web-auth-webauthn-framework)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.4M519](/packages/shopware-core)[chameleon-system/chameleon-base

The Chameleon System core.

1027.9k4](/packages/chameleon-system-chameleon-base)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
