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();
96 public function onRequests( array $reqs, Closure $idGeneratorFunc ) {
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 ) {
131 $result[$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'];
143 $result[$key] = $req;