PHPackages                             alcalyn/silex-wsse - 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. alcalyn/silex-wsse

ActiveLibrary

alcalyn/silex-wsse
==================

WSSE implementation based on Silex examples in documentation.

1.1.0(8y ago)2117MITPHPPHP &gt;=5.3.2

Since Sep 22Pushed 8y agoCompare

[ Source](https://github.com/alcalyn/silex-wsse)[ Packagist](https://packagist.org/packages/alcalyn/silex-wsse)[ Docs](https://github.com/alcalyn/silex-wsse)[ RSS](/packages/alcalyn-silex-wsse/feed)WikiDiscussions master Synced 1mo ago

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

Silex WSSE
==========

[](#silex-wsse)

[![Latest Stable Version](https://camo.githubusercontent.com/07729454c5201b95acc20460c85c63f5416c535fa0f5e3f88ed48938324c69d3/68747470733a2f2f706f7365722e707567782e6f72672f616c63616c796e2f73696c65782d777373652f762f737461626c65)](https://packagist.org/packages/alcalyn/silex-wsse)[![License](https://camo.githubusercontent.com/2c782e2cda027d7e72f058e5244bf1ab025ade107b9a82503f20a7206b8a25f4/68747470733a2f2f706f7365722e707567782e6f72672f616c63616c796e2f73696c65782d777373652f6c6963656e7365)](https://packagist.org/packages/alcalyn/silex-wsse)

Provides a Silex provider in order to implement a [WSSE authentication](http://silex.sensiolabs.org/doc/providers/security.html#defining-a-custom-authentication-provider).

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

[](#installation)

Via Composer

```
{
    "require": {
        "alcalyn/silex-wsse": "~1.0.0"
    }
}
```

Usage
-----

[](#usage)

```
// Register Silex security
$app->register(new Silex\Provider\SecurityServiceProvider(), array(
    'security.firewalls' => array(
        'api' => array(
            'pattern' => '^/api',
            'wsse' => true,
            'stateless' => true,
            'users' => $myUserProvider,
        ),
    ),
));

// SilexWsse needs a token validator service with a path where to store Wsse tokens
$app['security.wsse.token_validator'] = function () {
    $wsseCacheDir = 'var/cache/wsse-tokens';

    return new PasswordDigestValidator($wsseCacheDir);
};

// Register Wsse provider
$app->register(new WsseServiceProvider('api'));
```

Then you can retrieve your authenticated user in controller like that:

```
$app->get('api/auth', function () use ($app) {
    $authenticatedUser = $app['user'];

    return 'Hello '.$app->escape($authenticatedUser->getUsername());
});
```

### Full example

[](#full-example)

Using a plain password encoder, and an user `toto` with password `pass`:

```
use Symfony\Component\Security\Core\User\InMemoryUserProvider;
use Symfony\Component\Security\Core\Encoder\PlaintextPasswordEncoder;
use Alcalyn\Wsse\Security\Authentication\Provider\PasswordDigestValidator;
use Alcalyn\SilexWsse\Provider\WsseServiceProvider;

$app = new Silex\Application();

$myUserProvider = function () {
    return new InMemoryUserProvider(array(
        'toto' => ['password' => 'pass'],
    ));
};

$app['security.default_encoder'] = function () {
    return new PlaintextPasswordEncoder();
};

// Register Silex security
$app->register(new Silex\Provider\SecurityServiceProvider(), array(
    'security.firewalls' => array(
        'api' => array(
            'pattern' => '^/api',
            'wsse' => true,
            'stateless' => true,
            'users' => $myUserProvider,
        ),
    ),
));

// SilexWsse needs a token validator service with a path where to store Wsse tokens
$app['security.wsse.token_validator'] = function () {
    $wsseCacheDir = 'var/cache/wsse-tokens';

    return new PasswordDigestValidator($wsseCacheDir);
};

// Register Wsse provider
$app->register(new WsseServiceProvider('api'));

$app->get('api/auth', function () use ($app) {
    $authenticatedUser = $app['user'];

    return 'Hello '.$app->escape($authenticatedUser->getUsername());
});

$app->run();
```

Then making the following http request with the `X-WSSE` header (generated [here](http://www.teria.com/~koseki/tools/wssegen/)):

```
GET http://localhost/my-app/index.php/api/auth
X-WSSE: UsernameToken Username="toto", PasswordDigest="ieIS4sijyAW2ZrnvhvDOqBH+aSQ=", Nonce="NDlhNWE2M2YxNWQ2ZDk1NA==", Created="2016-07-31T12:46:16Z"

```

Returns the response:

```
200 OK
Date:  Sun, 31 Jul 2016 12:46:25 GMT

Hello toto

```

### Debugging

[](#debugging)

While implementing Wsse authentication, you should experience some authentication fail with your Wsse token (date expired, already used nonce...).

To display the fail reason, you can display symfony authentication exception like that:

```
use Symfony\Component\Security\Core\Event\AuthenticationFailureEvent;

$app->on('security.authentication.failure', function(AuthenticationFailureEvent $event) {
    echo $event->getAuthenticationException()->getMessage();
});
```

See Symfony [documentation about authentication events](http://symfony.com/doc/current/components/security/authentication.html#authentication-events).

License
-------

[](#license)

This project is under [MIT License](LICENSE).

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity62

Established project with proven stability

 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 ~183 days

Total

5

Last Release

3157d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/17f0c4d65197a7aed6ecc8fdedd5a097c7238c9be19aca08c92c05d38fd8c29e?d=identicon)[alcalyn](/maintainers/alcalyn)

---

Top Contributors

[![alcalyn](https://avatars.githubusercontent.com/u/1588144?v=4)](https://github.com/alcalyn "alcalyn (17 commits)")

---

Tags

symfonyusersilexwsse

### Embed Badge

![Health badge](/badges/alcalyn-silex-wsse/health.svg)

```
[![Health](https://phpackages.com/badges/alcalyn-silex-wsse/health.svg)](https://phpackages.com/packages/alcalyn-silex-wsse)
```

###  Alternatives

[mailjet/mailjet-bundle

Symfony bundle for Mailjet API V3

34395.8k](/packages/mailjet-mailjet-bundle)[eole/sandstone

Silex RestApi with Websockets.

1115.2k1](/packages/eole-sandstone)[df/php-coverfish

lightweight static code analysis tool for class coverage check of PHPUnit's CodeCoverage

234.9k1](/packages/df-php-coverfish)

PHPackages © 2026

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