pbergman / php-docker-token-auth
a light weight docker token authentication build in php
Requires
- php: >=5.4.0
- christian-riesen/base32: 1.*@stable
- firebase/php-jwt: 3.*@stable
- silex/silex: 1.*@stable
- symfony/options-resolver: 2.*@stable
Suggests
- symfony/yaml: Used for YamlAuthListener, where you can define users/rights in a yaml files
This package is auto-updated.
Last update: 2024-11-29 13:24:37 UTC
README
##PHP docker registry 2 token authentication
This is a light weight docker token authentication build in php to the specs of the docs.
https://docs.docker.com/registry/spec/auth/token
It can be used to validate push/pull and registration us users for you private registry.
###Configuring
the config should be given as argument with the constructor:
$app = new DockerToken\Application([
'public_key' => dirname(__FILE__) . '/public.key',
'private_key' => dirname(__FILE__) . '/private.key',
'audience' => 'registry.docker.com',
'issuer' => 'auth.docker.com',
])
###Validating
There are some listeners defined in src\DockerToken\Listener that can be used for validation (see) example.php or the tests.
To communicate between handlers you can use the (is|set)Access(Granted|Denied) methods (see LdapAuthListener or YamlAuthListener).
By default the flag is set to abstain en when finished when the flag is not granted it will see it as the authentiaction is not succesfull and throws a InvalidAccessException.
If you want to stop on success you can use the stopPropagation method because from the event because the set methods won`t do that. And on failure you can just call the InvalidAccessException that will resolve in a 401 status.
When using DockerToken\Listener\YamlAuthListener you also need symfony/yaml.
###Running
php -S 127.0.0.1:9999 example.php
###Keys
to generate keys, see:
php bin/CreateKeys.php