From 874c0fd253f36466201de2a8cab19e56515fe701 Mon Sep 17 00:00:00 2001 From: Arkadiusz Kondas Date: Thu, 2 Apr 2020 07:46:06 +0200 Subject: [PATCH] Fix scope separator (#1) --- CHANGELOG.md | 19 +++++++++++++++++++ README.md | 1 + buddy.yml | 23 +++++++++++++++++++++++ src/Provider/Buddy.php | 30 +++++++++++++++++++++++++++++- 4 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 CHANGELOG.md create mode 100644 buddy.yml diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..584e9c3 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,19 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [0.1.1] - 2020-04-02 +### Added +- all scopes as const +- buddy.yml + +### Fixed +- scope separator +- fetch resource owner (missing token) - fixed with BearerAuthorizationTrait + +## [0.1.0] - 2020-04-01 +### Added +- First initial release diff --git a/README.md b/README.md index 47c81a1..64ee432 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # Buddy Provider for OAuth 2.0 Client [![Latest Version](https://img.shields.io/github/release/buddy-works/oauth2-client.svg?style=flat-square)](https://github.com/buddy-works/oauth2-client/releases) +[![buddy branch](https://app.buddy.works/buddy-works/oauth2-client/repository/branch/master/badge.svg?token=be04e77cb21d0e7e611853e903e521ba233e01d46699a1e6dc00f85a853cbdd6 "buddy branch")](https://app.buddy.works/buddy-works/oauth2-client/repository/branch/master) [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md) [![Total Downloads](https://img.shields.io/packagist/dt/buddy-works/oauth2-client.svg?style=flat-square)](https://packagist.org/packages/buddy-works/oauth2-client) diff --git a/buddy.yml b/buddy.yml new file mode 100644 index 0000000..e226ec4 --- /dev/null +++ b/buddy.yml @@ -0,0 +1,23 @@ +- pipeline: "test" + trigger_mode: "ON_EVERY_PUSH" + ref_name: "refs/*" + ref_type: "WILDCARD" + trigger_condition: "ALWAYS" + actions: + - action: "Execute: composer tests" + type: "BUILD" + working_directory: "/buddy/oauth2-client" + docker_image_name: "library/php" + docker_image_tag: "7.4" + execute_commands: + - "composer validate" + - "composer install" + - "composer tests" + setup_commands: + - "echo \"memory_limit=-1\" >> /usr/local/etc/php/conf.d/buddy.ini" + - "apt-get update && apt-get install -y git zip" + - "curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer" + volume_mappings: + - "/:/buddy/oauth2-client" + trigger_condition: "ALWAYS" + shell: "BASH" diff --git a/src/Provider/Buddy.php b/src/Provider/Buddy.php index 30e2efb..960ad8b 100644 --- a/src/Provider/Buddy.php +++ b/src/Provider/Buddy.php @@ -7,11 +7,34 @@ use Buddy\OAuth2\Client\Provider\Exception\BuddyIdentityProviderException; use League\OAuth2\Client\Provider\AbstractProvider; use League\OAuth2\Client\Token\AccessToken; +use League\OAuth2\Client\Tool\BearerAuthorizationTrait; use Psr\Http\Message\ResponseInterface; final class Buddy extends AbstractProvider { - public const SCOPE_USER_INFO = 'USER_INFO'; + use BearerAuthorizationTrait; + + public const SCOPE_WORKSPACE = 'SCOPE_WORKSPACE'; + public const SCOPE_PROJECT_DELETE = 'SCOPE_PROJECT_DELETE'; + public const SCOPE_REPOSITORY_READ = 'SCOPE_REPOSITORY_READ'; + public const SCOPE_REPOSITORY_WRITE = 'SCOPE_REPOSITORY_WRITE'; + public const SCOPE_EXECUTION_INFO = 'SCOPE_EXECUTION_INFO'; + public const SCOPE_EXECUTION_RUN = 'SCOPE_EXECUTION_RUN'; + public const SCOPE_EXECUTION_MANAGE = 'SCOPE_EXECUTION_MANAGE'; + public const SCOPE_USER_INFO = 'SCOPE_USER_INFO'; + public const SCOPE_USER_KEY = 'SCOPE_USER_KEY'; + public const SCOPE_USER_EMAIL = 'SCOPE_USER_EMAIL'; + public const SCOPE_INTEGRATION_INFO = 'SCOPE_INTEGRATION_INFO'; + public const SCOPE_MEMBER_EMAIL = 'SCOPE_MEMBER_EMAIL'; + public const SCOPE_MANAGE_EMAILS = 'SCOPE_MANAGE_EMAILS'; + public const SCOPE_WEBHOOK_INFO = 'SCOPE_WEBHOOK_INFO'; + public const SCOPE_WEBHOOK_ADD = 'SCOPE_WEBHOOK_ADD'; + public const SCOPE_WEBHOOK_MANAGE = 'SCOPE_WEBHOOK_MANAGE'; + public const SCOPE_VARIABLE_ADD = 'SCOPE_VARIABLE_ADD'; + public const SCOPE_VARIABLE_INFO = 'SCOPE_VARIABLE_INFO'; + public const SCOPE_VARIABLE_MANAGE = 'SCOPE_VARIABLE_MANAGE'; + + private const SCOPE_SEPARATOR = ' '; // will be encoded as + (Buddy use + as scope separator) /** * @var string @@ -73,4 +96,9 @@ protected function createResourceOwner(array $response, AccessToken $token) { return new BuddyResourceOwner($response); } + + protected function getScopeSeparator() + { + return self::SCOPE_SEPARATOR; + } }