Skip to content

Commit

Permalink
Fix scope separator (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
akondas authored Apr 2, 2020
1 parent 1fb21e9 commit 874c0fd
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 1 deletion.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
23 changes: 23 additions & 0 deletions buddy.yml
Original file line number Diff line number Diff line change
@@ -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"
30 changes: 29 additions & 1 deletion src/Provider/Buddy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -73,4 +96,9 @@ protected function createResourceOwner(array $response, AccessToken $token)
{
return new BuddyResourceOwner($response);
}

protected function getScopeSeparator()
{
return self::SCOPE_SEPARATOR;
}
}

0 comments on commit 874c0fd

Please sign in to comment.