76 $this->authSessionTimestamp = 0;
77 [ $rcode, $rdesc, $rhdrs, , ] = $req[
'response'];
78 if ( $rcode >= 200 && $rcode <= 299 ) {
80 'auth_token' => $rhdrs[
'x-auth-token'],
81 'storage_url' => $rhdrs[
'x-storage-url']
83 $this->authSessionTimestamp = time();
85 } elseif ( $rcode === 403 ) {
86 $this->authCachedStatus = 401;
87 $this->authCachedReason =
'Authorization Required';
88 $this->authErrorTimestamp = time();
91 $this->authCachedStatus = $rcode;
92 $this->authCachedReason = $rdesc;
93 $this->authErrorTimestamp = time();
102 public function onRequests( array $reqs, Closure $idGeneratorFunc ) {
104 $firstReq = reset( $reqs );
105 if ( $firstReq && count( $reqs ) == 1 && isset( $firstReq[
'isAuth'] ) ) {
111 if ( $needsAuth ===
true ) {
115 $idGeneratorFunc() => [
117 'url' => $this->params[
'swiftAuthUrl'] .
"/v1.0",
119 'x-auth-user' => $this->params[
'swiftUser'],
120 'x-auth-key' => $this->params[
'swiftKey'] ],
125 } elseif ( $needsAuth !==
false ) {
129 foreach ( $reqs as $key => $req ) {
137 $result[$key] = $req;
142 foreach ( $reqs as $key => $req ) {
146 $parts = array_map(
'rawurlencode', explode(
'/', $req[
'url'] ) );
147 $req[
'url'] = $this->authCreds[
'storage_url'] .
'/' . implode(
'/', $parts );
148 $req[
'headers'][
'x-auth-token'] = $this->authCreds[
'auth_token'];
149 $result[$key] = $req;