Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

Commit 03da6ae

Browse files
author
Brian Retterer
committed
SMS MFA
1 parent 3f4922c commit 03da6ae

27 files changed

+2001
-52
lines changed

phpunit.xml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<testsuites>
77
<testsuite name="Stormpath SDK Test Suite">
88
<directory suffix="Test.php">./tests</directory>
9+
<exclude>./tests/Mfa/Physical</exclude>
910
</testsuite>
1011
</testsuites>
1112

src/Client.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ public function __construct(ApiKey $apiKey, $cacheManager, $cacheManagerOptions,
160160
}
161161

162162
$this->dataStore = new DefaultDataStore($apiKey, $auth, $this->cachePool, $httpClient, $messageFactory, $uriFactory, $baseUrl);
163+
164+
163165
}
164166

165167
public static function get($href, $className, $path = null, array $options = array())
@@ -242,6 +244,14 @@ public function getCachePool()
242244
public static function tearDown()
243245
{
244246
static::$instance = NULL;
247+
static::$apiKeyFileLocation;
248+
static::$apiKeyProperties;
249+
static::$apiKeyIdPropertyName = "apiKey.id";
250+
static::$apiKeySecretPropertyName = "apiKey.secret";
251+
static::$baseUrl;
252+
static::$cacheManager = 'Array';
253+
static::$cacheManagerOptions = array();
254+
static::$authenticationScheme = Stormpath::SAUTHC1_AUTHENTICATION_SCHEME;
245255
}
246256

247257

src/ClientBuilder.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,8 @@ public function build()
300300

301301
$apiKey = new ApiKey($apiKeyId, $apiKeySecret);
302302

303+
Client::$apiKeyProperties = "apiKey.id=".$apiKeyId."\napiKey.secret=".$apiKeySecret;
304+
303305
return new Client(
304306
$apiKey,
305307
$this->cacheManager,

src/DataStore/DefaultDataStore.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ private function executeRequest($httpMethod, $href, $body = '', array $query = a
268268
$uri = $this->uriFactory->createUri($href);
269269
$uri = $uri->withQuery(self::appendQueryValues($uri->getQuery(), $query));
270270
$request = $this->messageFactory->createRequest($httpMethod, $uri, $headers, $body);
271+
271272
$response = $this->httpClient->sendRequest($request);
272273

273274
$result = $response->getBody() ? json_decode($response->getBody()) : null;

src/Mfa/Challenge.php

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
<?php
2+
/**
3+
* Copyright 2016 Stormpath, Inc.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
19+
namespace Stormpath\Mfa;
20+
21+
use Stormpath\Client;
22+
use Stormpath\Resource\Account;
23+
use Stormpath\Resource\Deletable;
24+
use Stormpath\Resource\InstanceResource;
25+
use Stormpath\Stormpath;
26+
27+
abstract class Challenge extends InstanceResource implements Deletable
28+
{
29+
const CODE = "code";
30+
const FACTOR = "factor";
31+
const STATUS = "status";
32+
const ACCOUNT = "account";
33+
const MESSAGE = "message";
34+
const CREATED_AT = "createdAt";
35+
const MODIFIED_AT = "modifiedAt";
36+
37+
const PATH = "challenges";
38+
39+
public abstract static function instantiate($properties = null);
40+
41+
public abstract function validate($code);
42+
43+
/**
44+
* Gets the createdAt property.
45+
*
46+
* @return string
47+
*/
48+
public function getCreatedAt()
49+
{
50+
return $this->getProperty(self::CREATED_AT);
51+
}
52+
53+
/**
54+
* Gets the modifiedAt property.
55+
*
56+
* @return string
57+
*/
58+
public function getModifiedAt()
59+
{
60+
return $this->getProperty(self::MODIFIED_AT);
61+
}
62+
63+
/**
64+
* Gets the status property.
65+
*
66+
* @return string
67+
*/
68+
public function getStatus()
69+
{
70+
return $this->getProperty(self::STATUS);
71+
}
72+
73+
/**
74+
* Gets the factor resource property.
75+
*
76+
* @param array $options array of options.
77+
* @return Factor
78+
*/
79+
public function getFactor(array $options = [])
80+
{
81+
return $this->getResourceProperty(self::FACTOR, Stormpath::FACTOR, $options);
82+
}
83+
84+
/**
85+
* Sets the factor resource property.
86+
*
87+
* @param Factor $factor The factor of the object.
88+
* @return self
89+
*/
90+
public function setFactor(Factor $factor)
91+
{
92+
$this->setResourceProperty(self::FACTOR, $factor);
93+
94+
return $this;
95+
}
96+
97+
/**
98+
* Gets the account resource property.
99+
*
100+
* @param array $options array of options.
101+
* @return Account
102+
*/
103+
public function getAccount(array $options = [])
104+
{
105+
return $this->getResourceProperty(self::ACCOUNT, Stormpath::ACCOUNT, $options);
106+
}
107+
108+
/**
109+
* Sets the account resource property.
110+
*
111+
* @param Account $account The account of the object.
112+
* @return self
113+
*/
114+
public function setAccount(Account $account)
115+
{
116+
$this->setResourceProperty(self::ACCOUNT, $account);
117+
118+
return $this;
119+
}
120+
121+
/**
122+
* Sets the code property.
123+
*
124+
* @param string $code The code of the object.
125+
* @return self
126+
*/
127+
public function setCode($code)
128+
{
129+
$this->setProperty(self::CODE, $code);
130+
131+
return $this;
132+
}
133+
134+
135+
/**
136+
* Delete the challenge.
137+
*
138+
* @return string
139+
*/
140+
public function delete()
141+
{
142+
return $this->getDataStore()->delete($this);
143+
}
144+
145+
}

src/Mfa/ChallengeList.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
/**
3+
* Copyright 2016 Stormpath, Inc.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
19+
namespace Stormpath\Mfa;
20+
21+
use Stormpath\Resource\AbstractCollectionResource;
22+
use Stormpath\Stormpath;
23+
24+
class ChallengeList extends AbstractCollectionResource {
25+
26+
/**
27+
* Returns the class name for the Challenge.
28+
*
29+
* @return string
30+
*/
31+
function getItemClassName()
32+
{
33+
return Stormpath::CHALLENGE;
34+
}
35+
}

src/Mfa/Factor.php

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
<?php
2+
/**
3+
* Copyright 2016 Stormpath, Inc.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
19+
namespace Stormpath\Mfa;
20+
21+
use Stormpath\Resource\Account;
22+
use Stormpath\Resource\Deletable;
23+
use Stormpath\Resource\InstanceResource;
24+
use Stormpath\Stormpath;
25+
26+
abstract class Factor extends InstanceResource implements Deletable
27+
{
28+
const PATH = 'factors';
29+
30+
const TYPE = 'type';
31+
const CREATED_AT = 'createdAt';
32+
const MODIFIED_AT = 'modifiedAt';
33+
const STATUS = 'status';
34+
const VERIFICATION_STATUS = 'verificationStatus';
35+
const ACCOUNT = 'account';
36+
const CHALLENGES = 'challenges';
37+
const MOST_RECENT_CHALLENGE = "mostRecentChallenge";
38+
39+
/**
40+
* Gets the type property.
41+
*
42+
* @return string
43+
*/
44+
public function getType()
45+
{
46+
return $this->getProperty(self::TYPE);
47+
}
48+
49+
/**
50+
* Sets the type property.
51+
*
52+
* @param string $type The type of the object.
53+
* @return self
54+
*/
55+
protected function setType($type)
56+
{
57+
$this->setProperty(self::TYPE, $type);
58+
59+
return $this;
60+
}
61+
62+
63+
64+
/**
65+
* Gets the createdAt property.
66+
*
67+
* @return string
68+
*/
69+
public function getCreatedAt()
70+
{
71+
return $this->getProperty(self::CREATED_AT);
72+
}
73+
74+
/**
75+
* Gets the modifiedAt property.
76+
*
77+
* @return string
78+
*/
79+
public function getModifiedAt()
80+
{
81+
return $this->getProperty(self::MODIFIED_AT);
82+
}
83+
84+
/**
85+
* Gets the status property.
86+
*
87+
* @return string
88+
*/
89+
public function getStatus()
90+
{
91+
return $this->getProperty(self::STATUS);
92+
}
93+
94+
/**
95+
* Gets the verificationStatus property.
96+
*
97+
* @return string
98+
*/
99+
public function getVerificationStatus()
100+
{
101+
return $this->getProperty(self::VERIFICATION_STATUS);
102+
}
103+
104+
/**
105+
* Gets the account resource property.
106+
*
107+
* @param array $options array of options.
108+
* @return Account
109+
*/
110+
public function getAccount(array $options = [])
111+
{
112+
return $this->getResourceProperty(self::ACCOUNT, Stormpath::ACCOUNT, $options);
113+
}
114+
115+
/**
116+
* Gets the challenges resource property.
117+
*
118+
* @param array $options array of options.
119+
* @return ChallengeList
120+
*/
121+
public function getChallenges(array $options = [])
122+
{
123+
return $this->getResourceProperty(self::CHALLENGES, Stormpath::CHALLENGES, $options);
124+
}
125+
126+
/**
127+
* Gets the mostRecentChallenge resource property.
128+
*
129+
* @param array $options array of options.
130+
* @return Challenge
131+
*/
132+
public abstract function getMostRecentChallenge(array $options = []);
133+
134+
135+
public function delete()
136+
{
137+
return $this->getDataStore()->delete($this);
138+
}
139+
140+
141+
142+
}

0 commit comments

Comments
 (0)