74 $this->authSessionTimestamp = 0;
75 [ $rcode, $rdesc, $rhdrs, , ] = $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();
100 public function onRequests( array $reqs, Closure $idGeneratorFunc ) {
102 $firstReq = reset( $reqs );
103 if ( $firstReq && count( $reqs ) == 1 && isset( $firstReq[
'isAuth'] ) ) {
109 if ( $needsAuth ===
true ) {
113 $idGeneratorFunc() => [
115 'url' => $this->params[
'swiftAuthUrl'] .
"/v1.0",
117 'x-auth-user' => $this->params[
'swiftUser'],
118 'x-auth-key' => $this->params[
'swiftKey'] ],
123 } elseif ( $needsAuth !==
false ) {
127 foreach ( $reqs as $key => $req ) {
135 $result[$key] = $req;
140 foreach ( $reqs as $key => $req ) {
144 $parts = array_map(
'rawurlencode', explode(
'/', $req[
'url'] ) );
145 $req[
'url'] = $this->authCreds[
'storage_url'] .
'/' . implode(
'/', $parts );
146 $req[
'headers'][
'x-auth-token'] = $this->authCreds[
'auth_token'];
147 $result[$key] = $req;