PHPackages                             tourze/access-key-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. tourze/access-key-bundle

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

tourze/access-key-bundle
========================

2.0.0(5mo ago)01954MITPHPCI passing

Since Nov 1Pushed 5mo agoCompare

[ Source](https://github.com/tourze/access-key-bundle)[ Packagist](https://packagist.org/packages/tourze/access-key-bundle)[ RSS](/packages/tourze-access-key-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (36)Versions (4)Used By (4)

Access Key Bundle
=================

[](#access-key-bundle)

[English](README.md) | [中文](README.zh-CN.md)

Symfony Bundle for API access key management with signature verification, IP whitelist, and AES encryption support.

Features
--------

[](#features)

- **Access Key Management**: AppID/AppSecret key pair management
- **Signature Verification**: Configurable signature timeout (default 180 seconds)
- **IP Whitelist**: Restrict access to specific IPs
- **AES Encryption**: Support for AES key configuration
- **Statistics**: Success/failure call statistics
- **EasyAdmin Integration**: Admin panel interface
- **Access Control**: Requires ROLE\_ADMIN permission

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

[](#installation)

```
composer require tourze/access-key-bundle
```

Configuration
-------------

[](#configuration)

Register in `config/bundles.php`:

```
return [
    // ...
    Tourze\AccessKeyBundle\AccessKeyBundle::class => ['all' => true],
];
```

Run database migrations:

```
php bin/console doctrine:migrations:migrate
```

Usage
-----

[](#usage)

### 1. Get Valid Access Key

[](#1-get-valid-access-key)

```
use Tourze\AccessKeyBundle\Service\ApiCallerService;

class YourController
{
    public function __construct(
        private ApiCallerService $apiCallerService
    ) {}

    public function someAction(Request $request): Response
    {
        $appId = $request->headers->get('X-App-Id');
        $accessKey = $this->apiCallerService->findValidApiCallerByAppId($appId);

        if (!$accessKey) {
            throw new UnauthorizedHttpException('Invalid app id');
        }

        // Use $accessKey
    }
}
```

### 2. Record Call Statistics

[](#2-record-call-statistics)

```
// Record successful call
$this->apiCallerService->recordSuccess($accessKey);

// Record failed call
$this->apiCallerService->recordFailure($accessKey);
```

### 3. Get Statistics Data

[](#3-get-statistics-data)

```
use Tourze\AccessKeyBundle\Service\StatisticsService;

class StatisticsController
{
    public function __construct(
        private StatisticsService $statisticsService
    ) {}

    public function getStats(AccessKey $accessKey): array
    {
        // Today's statistics
        $todayStats = $this->statisticsService->getTodayStatistics($accessKey);

        // Weekly statistics
        $weeklyStats = $this->statisticsService->getWeeklyStatistics($accessKey);

        // Monthly statistics
        $monthlyStats = $this->statisticsService->getMonthlyStatistics($accessKey);

        // Custom date range statistics
        $customStats = $this->statisticsService->getSummary(
            $accessKey,
            new \DateTimeImmutable('2023-01-01'),
            new \DateTimeImmutable('2023-12-31')
        );

        return compact('todayStats', 'weeklyStats', 'monthlyStats', 'customStats');
    }
}
```

Data Models
-----------

[](#data-models)

### AccessKey Entity

[](#accesskey-entity)

- `title`: Name (required, max 60 characters)
- `appId`: Application ID (required, max 64 characters, unique)
- `appSecret`: Application secret (optional, max 120 characters)
- `allowIps`: Allowed IP list (JSON array)
- `signTimeoutSecond`: Signature timeout in seconds (default 180)
- `aesKey`: AES encryption key (optional)
- `remark`: Remarks (optional)
- `valid`: Is valid (boolean, default false)
- `owner`: Owner (user reference)

### AccessKeyStatistics Entity

[](#accesskeystatistics-entity)

- `accessKey`: Associated access key
- `hour`: Statistics time (hourly)
- `successCount`: Success count
- `failureCount`: Failure count
- `totalCount`: Total count
- `successRate`: Success rate

Admin Panel
-----------

[](#admin-panel)

Bundle integrates with EasyAdmin for management interface:

- Create, edit, delete access keys
- View usage statistics
- Manage IP whitelist
- Configure signature parameters

Access path: `/admin` -&gt; Access Keys

Permission Requirements
-----------------------

[](#permission-requirements)

- All operations require `ROLE_ADMIN` permission
- Ensure users have appropriate permissions to access management features

Bundle Dependencies
-------------------

[](#bundle-dependencies)

- `doctrine/orm`: Database ORM
- `easycorp/easyadmin-bundle`: Admin panel
- `tourze/doctrine-snowflake-bundle`: Snowflake ID
- `tourze/doctrine-timestamp-bundle`: Timestamps
- `tourze/doctrine-track-bundle`: Change tracking

License
-------

[](#license)

MIT

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance73

Regular maintenance activity

Popularity10

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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 ~23 days

Total

3

Last Release

150d ago

Major Versions

1.0.1 → 2.0.02025-12-19

### Community

Maintainers

![](https://www.gravatar.com/avatar/e354fdb316da535dfa8ba2e9193a473c403b6bc6fb9170778d1dc50e304c6e9d?d=identicon)[tourze](/maintainers/tourze)

---

Top Contributors

[![tourze](https://avatars.githubusercontent.com/u/13899502?v=4)](https://github.com/tourze "tourze (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/tourze-access-key-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/tourze-access-key-bundle/health.svg)](https://phpackages.com/packages/tourze-access-key-bundle)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[sulu/sulu

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

1.3k1.3M152](/packages/sulu-sulu)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

7310.3k29](/packages/open-dxp-opendxp)

PHPackages © 2026

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