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

Commit

Permalink
Merge branch 'feature/mfa' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Retterer committed Oct 17, 2016
2 parents 3f4922c + dbdb079 commit 83627d5
Show file tree
Hide file tree
Showing 30 changed files with 2,476 additions and 52 deletions.
1 change: 1 addition & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<testsuites>
<testsuite name="Stormpath SDK Test Suite">
<directory suffix="Test.php">./tests</directory>
<exclude>./tests/Mfa/Physical</exclude>
</testsuite>
</testsuites>

Expand Down
10 changes: 10 additions & 0 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ public function __construct(ApiKey $apiKey, $cacheManager, $cacheManagerOptions,
}

$this->dataStore = new DefaultDataStore($apiKey, $auth, $this->cachePool, $httpClient, $messageFactory, $uriFactory, $baseUrl);


}

public static function get($href, $className, $path = null, array $options = array())
Expand Down Expand Up @@ -242,6 +244,14 @@ public function getCachePool()
public static function tearDown()
{
static::$instance = NULL;
static::$apiKeyFileLocation;
static::$apiKeyProperties;
static::$apiKeyIdPropertyName = "apiKey.id";
static::$apiKeySecretPropertyName = "apiKey.secret";
static::$baseUrl;
static::$cacheManager = 'Array';
static::$cacheManagerOptions = array();
static::$authenticationScheme = Stormpath::SAUTHC1_AUTHENTICATION_SCHEME;
}


Expand Down
2 changes: 2 additions & 0 deletions src/ClientBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,8 @@ public function build()

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

Client::$apiKeyProperties = "apiKey.id=".$apiKeyId."\napiKey.secret=".$apiKeySecret;

return new Client(
$apiKey,
$this->cacheManager,
Expand Down
1 change: 1 addition & 0 deletions src/DataStore/DefaultDataStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ private function executeRequest($httpMethod, $href, $body = '', array $query = a
$uri = $this->uriFactory->createUri($href);
$uri = $uri->withQuery(self::appendQueryValues($uri->getQuery(), $query));
$request = $this->messageFactory->createRequest($httpMethod, $uri, $headers, $body);

$response = $this->httpClient->sendRequest($request);

$result = $response->getBody() ? json_decode($response->getBody()) : null;
Expand Down
144 changes: 144 additions & 0 deletions src/Mfa/Challenge.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
<?php
/**
* Copyright 2016 Stormpath, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

namespace Stormpath\Mfa;

use Stormpath\Client;
use Stormpath\Resource\Account;
use Stormpath\Resource\Deletable;
use Stormpath\Resource\InstanceResource;
use Stormpath\Stormpath;

abstract class Challenge extends InstanceResource implements Deletable
{
const CODE = "code";
const FACTOR = "factor";
const STATUS = "status";
const ACCOUNT = "account";
const MESSAGE = "message";
const CREATED_AT = "createdAt";
const MODIFIED_AT = "modifiedAt";

const PATH = "challenges";


public abstract function validate($code);

/**
* Gets the createdAt property.
*
* @return string
*/
public function getCreatedAt()
{
return $this->getProperty(self::CREATED_AT);
}

/**
* Gets the modifiedAt property.
*
* @return string
*/
public function getModifiedAt()
{
return $this->getProperty(self::MODIFIED_AT);
}

/**
* Gets the status property.
*
* @return string
*/
public function getStatus()
{
return $this->getProperty(self::STATUS);
}

/**
* Gets the factor resource property.
*
* @param array $options array of options.
* @return Factor
*/
public function getFactor(array $options = [])
{
return $this->getResourceProperty(self::FACTOR, Stormpath::FACTOR, $options);
}

/**
* Sets the factor resource property.
*
* @param Factor $factor The factor of the object.
* @return self
*/
public function setFactor(Factor $factor)
{
$this->setResourceProperty(self::FACTOR, $factor);

return $this;
}

/**
* Gets the account resource property.
*
* @param array $options array of options.
* @return Account
*/
public function getAccount(array $options = [])
{
return $this->getResourceProperty(self::ACCOUNT, Stormpath::ACCOUNT, $options);
}

/**
* Sets the account resource property.
*
* @param Account $account The account of the object.
* @return self
*/
public function setAccount(Account $account)
{
$this->setResourceProperty(self::ACCOUNT, $account);

return $this;
}

/**
* Sets the code property.
*
* @param string $code The code of the object.
* @return self
*/
public function setCode($code)
{
$this->setProperty(self::CODE, $code);

return $this;
}


/**
* Delete the challenge.
*
* @return string
*/
public function delete()
{
return $this->getDataStore()->delete($this);
}

}
36 changes: 36 additions & 0 deletions src/Mfa/ChallengeList.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
/**
* Copyright 2016 Stormpath, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

namespace Stormpath\Mfa;

use Stormpath\Resource\AbstractCollectionResource;
use Stormpath\Stormpath;

class ChallengeList extends AbstractCollectionResource {


/**
* Returns the class name for the Challenge.
*
* @return string
*/
function getItemClassName()
{
return Stormpath::CHALLENGE;
}
}
155 changes: 155 additions & 0 deletions src/Mfa/Factor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
<?php
/**
* Copyright 2016 Stormpath, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

namespace Stormpath\Mfa;

use Stormpath\Resource\Account;
use Stormpath\Resource\Deletable;
use Stormpath\Resource\InstanceResource;
use Stormpath\Stormpath;

abstract class Factor extends InstanceResource implements Deletable
{
const PATH = 'factors';

const TYPE = 'type';
const CREATED_AT = 'createdAt';
const MODIFIED_AT = 'modifiedAt';
const STATUS = 'status';
const VERIFICATION_STATUS = 'verificationStatus';
const ACCOUNT = 'account';
const CHALLENGES = 'challenges';
const MOST_RECENT_CHALLENGE = "mostRecentChallenge";

/**
* Gets the type property.
*
* @return string
*/
public function getType()
{
return $this->getProperty(self::TYPE);
}

/**
* Sets the type property.
*
* @param string $type The type of the object.
* @return self
*/
protected function setType($type)
{
$this->setProperty(self::TYPE, $type);

return $this;
}



/**
* Gets the createdAt property.
*
* @return string
*/
public function getCreatedAt()
{
return $this->getProperty(self::CREATED_AT);
}

/**
* Gets the modifiedAt property.
*
* @return string
*/
public function getModifiedAt()
{
return $this->getProperty(self::MODIFIED_AT);
}

/**
* Gets the status property.
*
* @return string
*/
public function getStatus()
{
return $this->getProperty(self::STATUS);
}

/**
* Sets the status property.
*
* @param string $status The status of the object.
* @return self
*/
public function setStatus($status)
{
$this->setProperty(self::STATUS, $status);

return $this;
}

/**
* Gets the verificationStatus property.
*
* @return string
*/
public function getVerificationStatus()
{
return $this->getProperty(self::VERIFICATION_STATUS);
}

/**
* Gets the account resource property.
*
* @param array $options array of options.
* @return Account
*/
public function getAccount(array $options = [])
{
return $this->getResourceProperty(self::ACCOUNT, Stormpath::ACCOUNT, $options);
}

/**
* Gets the challenges resource property.
*
* @param array $options array of options.
* @return ChallengeList
*/
public function getChallenges(array $options = [])
{
return $this->getResourceProperty(self::CHALLENGES, Stormpath::CHALLENGES, $options);
}

/**
* Gets the mostRecentChallenge resource property.
*
* @param array $options array of options.
* @return Challenge
*/
public abstract function getMostRecentChallenge(array $options = []);


public function delete()
{
return $this->getDataStore()->delete($this);
}



}
Loading

0 comments on commit 83627d5

Please sign in to comment.