PHPackages                             black-bits/key-secret-api-authentication - 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. black-bits/key-secret-api-authentication

AbandonedLibrary

black-bits/key-secret-api-authentication
========================================

Key Secret Api Authentication extension for Laravel

0.0.2(8y ago)0344MITPHPPHP &gt;=7.1.0

Since Oct 10Pushed 8y ago1 watchersCompare

[ Source](https://github.com/black-bits/key-secret-api-authentication)[ Packagist](https://packagist.org/packages/black-bits/key-secret-api-authentication)[ Docs](https://github.com/black-bits/key-secret-api-authentication)[ RSS](/packages/black-bits-key-secret-api-authentication/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (3)Versions (3)Used By (0)

KeySecretApiAuthentication
==========================

[](#keysecretapiauthentication)

[![Latest Version on Packagist](https://camo.githubusercontent.com/04c74567cc16e333a8b6f78802da423a91dfeb5165482e064827dcf11264018f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f626c61636b2d626974732f6b65792d7365637265742d6170692d61757468656e7469636174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/black-bits/key-secret-api-authentication)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/46d53665c35a46eaeddd2e34dba05877d66a78e437b3078ac0e75340933b1fa1/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f626c61636b2d626974732f6b65792d7365637265742d6170692d61757468656e7469636174696f6e2f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/black-bits/key-secret-api-authentication)[![Total Downloads](https://camo.githubusercontent.com/1a7be3cb17a514bfde5901eebd7d985ea3bba7e4329711680480d8b6a454feda/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f626c61636b2d626974732f6b65792d7365637265742d6170692d61757468656e7469636174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/black-bits/key-secret-api-authentication)

Key Secret Api Authentication extension for Laravel

How to use
----------

[](#how-to-use)

### 1. Require the package

[](#1-require-the-package)

```
composer require black-bits/key-secret-api-authentication
```

### 2. Extend your model (with key and secret fields)

[](#2-extend-your-model-with-key-and-secret-fields)

In our case we want a project model, that has a key and a secret field, for api authentication. Therefore a user can have different projects, each with it's own key-secret pair for authentication. Instead of "extends Model", use "extends KeySecretAuthenticatableModel".

```
class Project extends KeySecretAuthenticatableModel
{
    // ...
}
```

### 3. Configure config/auth.php

[](#3-configure-configauthphp)

Change the guard for api to the following...

```
'guards' => [
    // ...

    'api' => [
        'driver' => 'key_secret',
        'provider' => 'key_secret',
    ],
],
```

... and add a new provider "key\_secret" with reference to your Model

```
'providers' => [
    'users' => [
        'driver' => 'eloquent',
        'model' => App\User::class,
    ],

    'key_secret' => [
        'driver' => 'eloquent',
        'model' => App\Project::class,
    ],
],
```

### 4. Modify MiddlewareGroup in App\\Http\\Kernel.php

[](#4-modify-middlewaregroup-in-apphttpkernelphp)

Change the MiddlewareGroup in the Kernel as you would for usage for api\_token. Set the "auth" to "auth:api".

```
protected $middlewareGroups = [
    'web' => [
       // ...
    ],

    'api' => [
        'auth:api',
        'throttle:60,1',
        'bindings',
    ],
];
```

### 5. Start Using it

[](#5-start-using-it)

In "routes/api.php" create a route and start using it.

```
Route::get('test', function (Request $request) {
    return "hello world - " . $request->user()->name;
});

// Be aware, that "$request->user()->name" will return the property "name" from our Project-Model and not from the referenced User-Model.
```

Add a new Header to your API Call with a key "Authorization" and a value "Bearer xyz". xyz should be replaced with your base64\_encoded key:secret pair.

```
$key    = 'abc'
$secret = '12345'
$token  = base64_encode($key . ':' . $secret);
```

ToDo's
------

[](#todos)

- The token should be refactored to use jwt.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 75% 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 ~1 days

Total

2

Last Release

3136d ago

### Community

Maintainers

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

![](https://www.gravatar.com/avatar/12f99b0d20f4c0281e21cd28d12a44d2789c673a5bacade150d0e1150bdd9464?d=identicon)[oheck](/maintainers/oheck)

---

Top Contributors

[![oheck](https://avatars.githubusercontent.com/u/10670394?v=4)](https://github.com/oheck "oheck (3 commits)")[![aprzywara](https://avatars.githubusercontent.com/u/10901792?v=4)](https://github.com/aprzywara "aprzywara (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/black-bits-key-secret-api-authentication/health.svg)

```
[![Health](https://phpackages.com/badges/black-bits-key-secret-api-authentication/health.svg)](https://phpackages.com/packages/black-bits-key-secret-api-authentication)
```

###  Alternatives

[fumeapp/modeltyper

Generate TypeScript interfaces from Laravel Models

196277.9k](/packages/fumeapp-modeltyper)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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