PHPackages                             kba-team/micro-auth-lib - 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. kba-team/micro-auth-lib

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

kba-team/micro-auth-lib
=======================

External micro-service authentication library used by the service and the clients.

v1.1.1(1y ago)01.6kMITPHPPHP ^7.4|^8.1CI passing

Since May 27Pushed 1y ago2 watchersCompare

[ Source](https://github.com/the-kbA-team/micro-auth-lib)[ Packagist](https://packagist.org/packages/kba-team/micro-auth-lib)[ RSS](/packages/kba-team-micro-auth-lib/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (6)Dependencies (2)Versions (7)Used By (0)

Micro Auth Lib
==============

[](#micro-auth-lib)

[![License: MIT](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE)[![Build Status](https://camo.githubusercontent.com/41579b872e4067d2a2f1b524e402980ff13be05c66078ad8bbe9cb97ca408c16/68747470733a2f2f6170692e7472617669732d63692e636f6d2f7468652d6b62412d7465616d2f6d6963726f2d617574682d6c69622e7376673f6272616e63683d6d61696e)](https://travis-ci.org/the-kbA-team/micro-auth-lib)[![Maintainability](https://camo.githubusercontent.com/e49794cb045e6aca48424a94ec9e51ccd5a9d9a77eb263d96658747403bc6329/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f34613437366238663432663966366466653839632f6d61696e7461696e6162696c697479)](https://api.codeclimate.com/v1/badges/4a476b8f42f9f6dfe89c/maintainability)[![Test Coverage](https://camo.githubusercontent.com/664e3c828f3b11d7ad3505081eb3d3b544f9e83ce7111747d87420d35bbf99a3/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f34613437366238663432663966366466653839632f746573745f636f766572616765)](https://codeclimate.com/github/the-kbA-team/micro-auth-lib/test_coverage)

External micro-service authentication library used by the service and the clients.

[![Sequence diagram for this library](https://camo.githubusercontent.com/a0ef7e126d3bf3d007efdf16fa0f3b24c9fd95a48d5938b6d68e2e617be9988a/68747470733a2f2f7777772e706c616e74746578742e636f6d2f6170692f706c616e74756d6c2f7376672f625046565179386d344356562d7253534b6770326a43456e6271427a4349574a6e6658697450696d696c517331636a5161676c2d2d786c4d725a63726374693962796c54397654797877513658415059644c6559707555345863306d586952736d394f6e2d41323559646c7a6652387256673136784954346b5635536a6d6271327546514a524446674a5767495a31512d4f616d4953797338594b4f4c586e5577746e363649493869636d6234525149615a42302d6237336453777333464c5737654f426b4261555749576536523968386f44716771735576394562615a756454784e5671426b486c6f6c31696366386f5569536661446c62576b4536564b78376a6d37384c6f365173467970677a445534337a5a5a657049704e5a4b3547613871346f4b5f5f59426b5142616b617931757a464f5633732d583879456f55304167577a5549444936476c32746b76544c7a326761617453372d6b534d79314873545058486f6171526d2d6b526d486478706439516d3952504d675f6c54504a6d506a327a6741474e2d4577584c5f5870616c7a7452774c6a3473464e654776466d505f5f545a48385f61596974554567782d3330546d51507241546946575147487074466e5f36633242586f4d31434b534b7965727930)](https://camo.githubusercontent.com/a0ef7e126d3bf3d007efdf16fa0f3b24c9fd95a48d5938b6d68e2e617be9988a/68747470733a2f2f7777772e706c616e74746578742e636f6d2f6170692f706c616e74756d6c2f7376672f625046565179386d344356562d7253534b6770326a43456e6271427a4349574a6e6658697450696d696c517331636a5161676c2d2d786c4d725a63726374693962796c54397654797877513658415059644c6559707555345863306d586952736d394f6e2d41323559646c7a6652387256673136784954346b5635536a6d6271327546514a524446674a5767495a31512d4f616d4953797338594b4f4c586e5577746e363649493869636d6234525149615a42302d6237336453777333464c5737654f426b4261555749576536523968386f44716771735576394562615a756454784e5671426b486c6f6c31696366386f5569536661446c62576b4536564b78376a6d37384c6f365173467970677a445534337a5a5a657049704e5a4b3547613871346f4b5f5f59426b5142616b617931757a464f5633732d583879456f55304167577a5549444936476c32746b76544c7a326761617453372d6b534d79314873545058486f6171526d2d6b526d486478706439516d3952504d675f6c54504a6d506a327a6741474e2d4577584c5f5870616c7a7452774c6a3473464e654776466d505f5f545a48385f61596974554567782d3330546d51507241546946575147487074466e5f36633242586f4d31434b534b7965727930)

Usage
-----

[](#usage)

Require `kba-team/micro-auth-lib` using [composer](https://getcomposer.org/).

### Server

[](#server)

The browser gets redirected to the protected authentication micro-service. The micro-service reads the request and redirects the browser back to the specified referer with the authenticated result.

In this example the micro-service is protected by a kerberos authentication. After successful authentication Apache2 writes the authenticated name to the `REMOTE_USER` server variable.

Create a keytab file for the authentication, enable the *auth\_kerb* Apache2 module and add the following to your (virtual hosts) configuration.

```

    AuthName "Kerberos Login"
    AuthType Kerberos
    Krb5Keytab /etc/apache2/keytabs/auth.service.test.keytab
    KrbSaveCredentials off
    KrbVerifyKDC off
    KrbMethodNegotiate on
    KrbMethodK5Passwd on
    KrbServiceName HTTP
    KrbLocalUserMapping on
    Require valid-user
    Require env
    Options FollowSymLinks
    AllowOverride All

```

The micro-service itself is just the following PHP file.

```
