monkdev / monk-id
Integrate Monk ID authentication and single sign-on for apps and websites on the server-side.
Installs: 9 046
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 20
Forks: 0
Open Issues: 0
Requires
- php: >=5.3.0
Requires (Dev)
- phpdocumentor/phpdocumentor: ~2.9.0
- phploc/phploc: ~3.0.1
- phpmd/phpmd: ~2.5.0
- phpunit/phpunit: ~5.7.5
- satooshi/php-coveralls: ~1.0.1
- sebastian/phpcpd: ~2.0.4
- sensiolabs/security-checker: ~4.0.0
- squizlabs/php_codesniffer: ~2.7.1
This package is auto-updated.
Last update: 2024-10-07 15:08:59 UTC
README
Integrate Monk ID authentication and single sign-on for apps and websites on the server-side.
Overview
Install
Using Composer, add monkdev/monk-id
to your
composer.json
:
{ "require": { "monkdev/monk-id": "~1.0" } }
$ composer update
Or:
$ composer require monkdev/monk-id:~1.0
Configure
Configuration is done in an external INI file. There's a sample file in this
repository: config/monkId.sample.yml
. Copy this file to your codebase, then
load the config in your code during initialization:
Monk\Id::loadConfig('/path/to/monkId.ini', 'development');
Remember, replace the sample values with your own, and keep the file safe as it contains your app secret.
Access
If you have Monk ID JS configured to store the payload automatically in a cookie (the default), you can skip the next part as the cookie is also loaded automatically.
If not, the encoded payload can be passed directly, which is useful if you're sending it in a GET/POST request instead:
Monk\Id::loadPayload($monkIdPayload);
Loading the payload must be done before trying to access any values stored in
the payload. In an MVC framework, this usually means placing it in a method in
your ApplicationController
that's executed before the specific action is
processed.
Once the payload is loaded, you can ask whether the user is logged in:
Monk\Id::loggedIn()
Or for their ID and email:
Monk\Id::userId() Monk\Id::userEmail()
null
is returned if the user isn't logged in or the payload can't be decoded
and verified.
Development
Composer is used for dependency management and task running. Start by installing the dependencies:
$ composer install
Tests
Testing is done with PHPUnit. To run the tests:
$ composer test
Continuous integration is setup through Travis CI to run the tests against PHP v5.6, v7.0, and v7.1. (Circle CI is also setup to run the tests against PHP v5.6, but is backup for now until multiple versions can easily be specified.) The code coverage results are sent to Codecov during CI for tracking over time. Badges for both are dispayed at the top of this README.
While the test suite is complete, it's not a bad idea to also test changes manually in real-world integrations.
Documentation
phpDocumentor is used for code documentation. To build:
$ composer phpdoc
This creates a doc
directory (that is ignored by git).
Quality
A number of code quality tools are configured to aid in development. To run them all at once:
$ composer quality
Each tool can also be run individually:
- php -l:
$ composer phplint
- PHP_CodeSniffer:
$ composer phpcs
- PHP Copy/Paste Detector:
$ composer phpcpd
- PHPLOC:
$ composer phploc
- PHP Mess Detector:
$ composer phpmd
- SensioLabs Security Checker:
$ composer security-checker
Deployment
Publishing a release to Packagist simply requires creating a git tag:
$ git tag -a vMAJOR.MINOR.PATCH -m "Version MAJOR.MINOR.PATCH"
$ git push origin vMAJOR.MINOR.PATCH
Be sure to choose the correct version by following Semantic Versioning.
Publish Documentation
After releasing a new version, the documentation must be manually built and
published to the gh-pages
branch.