Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
66.67% covered (warning)
66.67%
2 / 3
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
AuthOptions
66.67% covered (warning)
66.67%
2 / 3
0.00% covered (danger)
0.00%
0 / 1
3.33
0.00% covered (danger)
0.00%
0 / 1
 __construct
66.67% covered (warning)
66.67%
2 / 3
0.00% covered (danger)
0.00%
0 / 1
3.33
1<?php
2namespace Ably\Models;
3
4use Ably\Log;
5use Ably\Models\TokenDetails;
6
7/**
8 * Client library options
9 */
10class AuthOptions extends BaseOptions {
11
12    /**
13     * @var string|null A client id, used for identifying this client for presence purposes.
14     * The clientId can be any string. This option is primarily intended to be used in situations where the library is instanced with a key;
15     * note that a clientId may also be implicit in a token used to instance the library; an error will be raised if a clientId specified here conflicts with the clientId implicit in the token.
16     */
17    public $clientId;
18
19    /**
20     * @var string|null The full key string, as obtained from the application dashboard.
21     * Use this option if you wish to use Basic authentication, or wish to be able to issue tokens without needing to defer to a separate entity to sign token requests.
22     */
23    public $key;
24
25    /**
26     * @var string|null Token string that should be used for authentificating all requests
27     */
28    public $token;
29    
30    /**
31     * @var \Ably\Models\TokenDetails|null Token that should be used for authentificating all requests
32     * If $token is provided $tokenDetails get populated automatically
33     */
34    public $tokenDetails;
35
36    /**
37     * @var bool Forces token auth to be used when true
38     */
39    public $useTokenAuth;
40
41    /**
42     * @var function|null A function to call when a new token is required.
43     * The role of the callback is to generate a signed token request which may then be submitted by the library to the requestToken API.
44     * See authentication for details of the token request format and associated API calls.
45     */
46    public $authCallback;
47
48    /**
49     * @var string|null A URL that the library may use to obtain a signed token request.
50     * For example, this can be used by a client to obtain signed token requests from an application server.
51     */
52    public $authUrl;
53
54    /**
55     * @var array|null A set of headers to be added to any request made to the authUrl.
56     * Useful when an application requires these to be added to validate the request or implement the response.
57     */
58    public $authHeaders;
59
60    /**
61     * @var array|null A set of parameters to be submitted to any request made to the authUrl.
62     */
63    public $authParams;
64
65    /**
66     * @var array|null HTTP method to use with authUrl, defaults to GET
67     */
68    public $authMethod = 'GET';
69
70    /**
71     * @var boolean This may be set in instances that the library is to sign
72     * token requests based on a given key. If true, the library
73     * will query the Ably system for the current time instead of
74     * relying on a locally-available time of day.
75     */
76    public $queryTime;
77
78    public function __construct( $options = [] ) {
79        parent::__construct( $options );
80        
81        if ( empty( $this->tokenDetails ) && !empty( $this->token ) ) {
82            $this->tokenDetails = new TokenDetails( $this->token );
83        }
84    }
85}