49 $mparams = array_merge( [
52 parent::__construct( $mparams );
59 if ( !$this->authCreds ) {
62 if ( $this->authErrorTimestamp !==
null ) {
63 if ( ( time() - $this->authErrorTimestamp ) < 60 ) {
66 $this->authErrorTimestamp =
null;
70 return ( ( time() - $this->authSessionTimestamp ) > $this->params[
'swiftAuthTTL'] );
74 $this->authSessionTimestamp = 0;
75 list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) =
$req[
'response'];
76 if ( $rcode >= 200 && $rcode <= 299 ) {
78 'auth_token' => $rhdrs[
'x-auth-token'],
79 'storage_url' => $rhdrs[
'x-storage-url']
81 $this->authSessionTimestamp = time();
83 } elseif ( $rcode === 403 ) {
84 $this->authCachedStatus = 401;
85 $this->authCachedReason =
'Authorization Required';
86 $this->authErrorTimestamp = time();
89 $this->authCachedStatus = $rcode;
90 $this->authCachedReason = $rdesc;
91 $this->authErrorTimestamp = time();
98 $firstReq = reset( $reqs );
99 if ( $firstReq &&
count( $reqs ) == 1 && isset( $firstReq[
'isAuth'] ) ) {
105 if ( $needsAuth ===
true ) {
109 $idGeneratorFunc() => [
111 'url' => $this->params[
'swiftAuthUrl'] .
"/v1.0",
113 'x-auth-user' => $this->params[
'swiftUser'],
114 'x-auth-key' => $this->params[
'swiftKey'] ],
119 } elseif ( $needsAuth !==
false ) {
123 foreach ( $reqs
as $key =>
$req ) {
136 foreach ( $reqs
as $key =>
$req ) {
140 $parts = array_map(
'rawurlencode', explode(
'/',
$req[
'url'] ) );
141 $req[
'url'] = $this->authCreds[
'storage_url'] .
'/' . implode(
'/', $parts );
142 $req[
'headers'][
'x-auth-token'] = $this->authCreds[
'auth_token'];
152 $firstReq = reset( $reqs );
153 if ( $firstReq &&
count( $reqs ) == 1 && isset( $firstReq[
'isAuth'] ) ) {
163 foreach ( $firstReq[
'chain']
as $key =>
$req ) {