PHPackages                             sergic/api-authentication-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. sergic/api-authentication-bundle

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

sergic/api-authentication-bundle
================================

Symfony2 api authentication bundle

033PHP

Since Oct 28Pushed 12y ago1 watchersCompare

[ Source](https://github.com/Sergic/INBApiAuthenticationBundle)[ Packagist](https://packagist.org/packages/sergic/api-authentication-bundle)[ RSS](/packages/sergic-api-authentication-bundle/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependenciesVersions (1)Used By (0)

INBApiAuthenticationBundle
==========================

[](#inbapiauthenticationbundle)

Api authentication bundle for Symfony2

Installation
============

[](#installation)

### 1. Add this bundle to your composer.json:

[](#1-add-this-bundle-to-your-composerjson)

```
{
    "require": {
        "sergic/api-authentication-bundle": "0.1.*@dev"
    }
}
```

Now tell composer to download the bundle by running the command:

```
$ php composer.phar update sergic/api-authentication-bundle
```

### 2. Add this bundle to your application's kernel:

[](#2-add-this-bundle-to-your-applications-kernel)

```
// application/ApplicationKernel.php
public function registerBundles()
{
    return array(
      // ...
        new INB\Bundle\ApiAuthenticationBundle\INBApiAuthenticationBundle(),
      // ...
    );
}
```

### Step 3: Create your User class

[](#step-3-create-your-user-class)

with token parameter

```
// src/Acme/AcmeBundle/Entity/User.php
/**
 * User Api token
 *
 * @var string
 */
protected $token;

public function __construct()
{
    $this->token = null;
}

/**
 * {@inheritdoc}
 */
public function getToken()
{
    return $this->token;
}

/**
 * {@inheritdoc}
 */
public function setToken($token)
{
    $this->token = $token;

    return $this;
}

/**
 * {@inheritdoc}
 */
public function generateApiToken()
{
    $this->token = md5(md5(time() + rand(11111, 99999)));

    return $this;
}
```

### Step 4: Create your User repository class and init it as a service

[](#step-4-create-your-user-repository-class-and-init-it-as-a-service)

```
// src/Acme/AcmeBundle/Repositroy/UserRepository.php
use Ft\Bundle\CoreBundle\Doctrine\ORM\EntityRepository;

class UserRepository extends EntityRepository
{
    /**
     * Constructor.
     *
     * @param EncoderFactoryInterface $encoderFactory
     * @param EntityManager $em    The EntityManager to use.
     * @param ClassMetadata $class The class descriptor.
     */
    public function __construct($em, ClassMetadata $class, EncoderFactoryInterface $encoderFactory = null)
    {
        parent::__construct($em, $class);
        $this->encoderFactory = $encoderFactory;
    }
}
```

```
# src/Acme/AcmeBundle/Resources/config/services.yml
parameters:
    acme.user.class: Acme\AcmeBundle\Entity\User
    acme.repository.user.class: Acme\AcmeBundle\Repositroy\UserRepository
services:
    user_metadata:
        class: Doctrine\ORM\Mapping\ClassMetadata
        factory-method: getClassMetadata
        arguments: [%acme.user.class%]
    acme.repository.user:
        class: %acme.repository.user.class%
        arguments: [@doctrine.orm.entity_manager, @user_metadata, @security.encoder_factory]
```

### Step 4: Configure your application's security.yml

[](#step-4-configure-your-applications-securityyml)

```
# app/config/security.yml
security:
    providers:
        api_provider:
            id: inb_api_auth.provider
    firewalls:
        api:
            provider: api_provider
            pattern: ^(/[^\/]+)/api|^/api
            access_denied_url: ^(/[^\/]+)/api|^/api/unauthorized
            api: { lifetime: '30D' }
            stateless: true
            anonymous: true
    encoders:
        Acme\AcmeBundle\Entity\User: sha512
    access_control:
        - { path: ^(/[^\/]+)/api/*|^/api/*, roles: [ROLE_USER] }
```

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/2cb23c7e4a47194405589e279e344e3300286e07a8928f5a879ee144dd26640e?d=identicon)[Sergic](/maintainers/Sergic)

---

Top Contributors

[![Sergic](https://avatars.githubusercontent.com/u/860167?v=4)](https://github.com/Sergic "Sergic (6 commits)")

### Embed Badge

![Health badge](/badges/sergic-api-authentication-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/sergic-api-authentication-bundle/health.svg)](https://phpackages.com/packages/sergic-api-authentication-bundle)
```

###  Alternatives

[namshi/jose

JSON Object Signing and Encryption library for PHP.

1.8k99.6M101](/packages/namshi-jose)[league/oauth1-client

OAuth 1.0 Client Library

99698.8M106](/packages/league-oauth1-client)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[gesdinet/jwt-refresh-token-bundle

Implements a refresh token system over Json Web Tokens in Symfony

70516.4M35](/packages/gesdinet-jwt-refresh-token-bundle)[league/oauth2-google

Google OAuth 2.0 Client Provider for The PHP League OAuth2-Client

41721.2M118](/packages/league-oauth2-google)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)

PHPackages © 2026

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