diff --git a/.gitignore b/.gitignore new file mode 100755 index 0000000..5826402 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/vendor +composer.phar +composer.lock +.DS_Store diff --git a/composer.json b/composer.json new file mode 100755 index 0000000..7ff8264 --- /dev/null +++ b/composer.json @@ -0,0 +1,31 @@ +{ + "name": "tjarksaul/oauth2-dlrg", + "license": "MIT", + "authors": [ + { + "name": "Tjark Saul" + } + ], + "keywords": [ + "oauth", + "oauth2", + "client", + "authorization", + "authentication", + "dlrg.net" + ], + "require": { + "php": "^5.6 || ^7.0", + "league/oauth2-client": "^2.0" + }, + "autoload": { + "psr-4": { + "League\\OAuth2\\Client\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "League\\OAuth2\\Client\\Test\\": "tests/src/" + } + } +} diff --git a/phpunit.xml b/phpunit.xml new file mode 100755 index 0000000..3347b75 --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,18 @@ + + + + + ./tests/ + + + diff --git a/src/Provider/AppSecretProof.php b/src/Provider/AppSecretProof.php new file mode 100755 index 0000000..f83229b --- /dev/null +++ b/src/Provider/AppSecretProof.php @@ -0,0 +1,19 @@ +data = $response; + } + + /** + * Returns the ID for the user as a string if present. + * + * @return string|null + */ + public function getId() { + return $this->getField('sub'); + } + + /** + * Returns the name for the user as a string if present. + * + * @return string|null + */ + public function getName() { + return $this->getField('name'); + } + + /** + * Returns the first name for the user as a string if present. + * + * @return string|null + */ + public function getFirstName() { + return $this->getField('given_name'); + } + + /** + * Returns the last name for the user as a string if present. + * + * @return string|null + */ + public function getLastName() { + return $this->getField('family_name'); + } + + /** + * Returns the email for the user as a string if present. + * + * @return string|null + */ + public function getEmail() { + return $this->getField('email'); + } + + /** + * Returns if the user's email has been verified + * + * @return boolean + */ + public function isEmailVerified() { + return !!$this->getField('email_verified'); + } + + /** + * Returns the preferred username for the user as a string if present. + * + * @return string|null + */ + public function getPreferredUsername() { + return $this->getField('preferred_username'); + } + + /** + * Returns all the data obtained about the user. + * + * @return array + */ + public function toArray() { + return $this->data; + } + + /** + * Returns a field from the Graph node data. + * + * @param string $key + * + * @return mixed|null + */ + private function getField($key) { + return isset($this->data[$key]) ? $this->data[$key] : null; + } +}