定制 liblynx-llc/liblynx-connect-php 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

liblynx-llc/liblynx-connect-php

Composer 安装命令:

composer require liblynx-llc/liblynx-connect-php

包简介

PHP client for LibLynx Connect identity and access management API

README 文档

README

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

This is a PHP client library for the LibLynx Connect identity and access management API. The API allows a publisher to control access to electronic resources without being concerned about the method used, e.g. IP, Shibboleth, SAML, OpenID Connect etc.

This library is open source, but access to the API requires a commercial agreement with LibLynx - contact us at info@liblynx.com to discuss your requirements.

Install

Via Composer

$ composer require liblynx-llc/liblynx-connect-php

Setting API credentials

In order to use this, you will need an API client id and client secret from LibLynx. These can be passed to the API client in one of two ways

Set API credentials through environment variables

You can set the following environment variables to avoid placing credentials in your code

  • LIBLYNX_CLIENT_ID
  • LIBLYNX_CLIENT_SECRET

Set API credentials through code

Alternatively, you can set the credentials directly, e.g.

$liblynx=new Liblynx\Connect\Client;
$liblynx->setCredentials('your client id', 'your client secret');

Caching

To work as efficiently as possible, the client caches API responses such as the entrypoint resource. Any PSR-16 compatible cache can be used, for example symfony/cache

For testing, you could use the ArrayCache from symfony/cache - install as follows:

$ composer require symfony/cache

Then create and use an ArrayCache as follows

$cache=new \Symfony\Component\Cache\Simple\ArrayCache;
$liblynx->setCache($cache);

Diagnostic logging

Detailed information on API usage can be obtained by passing a PSR-3 compatible logger to the client. This package includes a useful DiagnosticLogger class which can be used to store logs and then output them for console or HTML reading.

$logger = new \LibLynx\Connect\DiagnosticLogger;
$liblynx->setLogger($logger);

Examples

A simple integration involves obtaining an account from data provided in the current request superglobals

try {
    $identification = $liblynx->authorize(IdentificationRequest::fromArray($_SERVER));
    if ($identification->isIdentified()) {
        //visitor is identified, you can now check their access rights
    } elseif ($identification->requiresWAYF()) {
         //to find our who the visitor is, redirect to WAYF page
         $url = $identification->getWayfUrl();
         header("Location: $url");
         exit;
    } else {
        //liblynx failed - check diagnostic logs
    }
} catch (LibLynx\Connect\Exception\LibLynxException $e) {
    //exceptions are throw for API failures and erroneous integrations
    throw $e;
}    

See the examples folder for other examples:

  • examples\example.php is a console application which prompts for an IP and URL performs an identification.

Change log

Please see CHANGELOG for more information on what has changed recently.

Testing

$ composer test

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email security@liblynx.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 2.8k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-02-16