Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Lint

on:
pull_request:
push:
branches: [ master ]

jobs:
pint:
runs-on: ubuntu-latest

name: Code style

steps:
- name: Checkout
uses: actions/checkout@v6

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
extensions: json, mbstring
coverage: none
tools: pint

- name: Check code style
run: pint --test
Comment thread
atymic marked this conversation as resolved.
15 changes: 9 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@ jobs:
max-parallel: 15
fail-fast: false
matrix:
php-versions: [ '8.3', '8.4' ]
coverage: [ 'none' ]
php-versions: [ '8.2', '8.3', '8.4', '8.5' ]
exclude:
- php-versions: '8.5'
include:
- php-versions: '8.5'
coverage: 'xdebug'
Expand All @@ -30,17 +28,22 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: json, mbstring, xdebug
extensions: json, mbstring
coverage: ${{ matrix.coverage }}

- name: Install dependencies
run: composer update --no-interaction --prefer-dist --no-suggest --prefer-stable
run: composer update --no-interaction --prefer-dist --prefer-stable

- name: Lint composer.json
run: composer validate --strict

- name: Run Tests
run: vendor/bin/phpunit -v
if: matrix.coverage == 'none'
run: vendor/bin/phpunit

- name: Run Tests with coverage
if: matrix.coverage != 'none'
run: vendor/bin/phpunit --coverage-clover build/logs/clover.xml --coverage-text

- name: Upload coverage results
if: matrix.coverage != 'none'
Expand Down
17 changes: 6 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# Socialite Providers Manager

[![Build Status](https://travis-ci.org/SocialiteProviders/Manager.svg)](https://travis-ci.org/SocialiteProviders/Manager)
[![Test](https://github.com/SocialiteProviders/Manager/actions/workflows/test.yml/badge.svg)](https://github.com/SocialiteProviders/Manager/actions/workflows/test.yml)
[![codecov](https://codecov.io/gh/SocialiteProviders/Manager/branch/master/graph/badge.svg)](https://codecov.io/gh/SocialiteProviders/Manager)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/SocialiteProviders/Manager/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/SocialiteProviders/Manager/?branch=master)
[![Latest Stable Version](https://poser.pugx.org/socialiteproviders/manager/v/stable.svg)](https://packagist.org/packages/socialiteproviders/manager)
[![Total Downloads](https://poser.pugx.org/socialiteproviders/manager/downloads.svg)](https://packagist.org/packages/socialiteproviders/manager)
[![Latest Unstable Version](https://poser.pugx.org/socialiteproviders/manager/v/unstable.svg)](https://packagist.org/packages/socialiteproviders/manager)
[![License](https://poser.pugx.org/socialiteproviders/manager/license.svg)](https://packagist.org/packages/socialiteproviders/manager)
[![StyleCI](https://github.styleci.io/repos/30993504/shield?branch=master)](https://github.styleci.io/repos/30993504?branch=master)
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/ddb2f0df-6d85-431c-8e68-6164b08dd852/small.png)](https://insight.sensiolabs.com/projects/ddb2f0df-6d85-431c-8e68-6164b08dd852)

## About

Expand All @@ -20,7 +19,6 @@ A package for Laravel Socialite that allows you to easily add new providers or o
* Instantiation is deferred until Socialite is called
* You can override current providers
* You can create new providers
* Lumen usage is easy
* `stateless()` can be set to `true` or `false`
* You can override a config dynamically
* It retrieves environment variables directly from the `.env` file instead of also having to configure the services array.
Expand All @@ -33,17 +31,15 @@ A package for Laravel Socialite that allows you to easily add new providers or o

## Reference

* [Laravel docs about events](https://laravel.com/docs/7.x/events)
* [Laracasts video on events in Laravel 5](https://laracasts.com/lessons/laravel-5-events)
* [Laravel Socialite Docs](https://github.com/laravel/socialite)
* [Laracasts Socialite video](https://laracasts.com/series/whats-new-in-laravel-5/episodes/9)
* [Laravel docs about events](https://laravel.com/docs/13.x/events)
* [Laravel Socialite Docs](https://laravel.com/docs/13.x/socialite)


## Creating a Handler

Below is an example handler. You need to add this full class name to the `listen[]` in the `EventServiceProvider`.

* [See also the Laravel docs about events](https://laravel.com/docs/7.x/events).
* [See also the Laravel docs about events](https://laravel.com/docs/13.x/events).
* `providername` is the name of the provider such as `meetup`.
* You will need to change your the namespacing and class names of course.

Expand All @@ -65,8 +61,7 @@ class ProviderNameExtendSocialite

## Creating a Provider

* Look at the already created [providers](https://socialiteproviders.netlify.app/) for inspiration.
* [See this article on Medium](https://medium.com/@morrislaptop/adding-auth-providers-to-laravel-socialite-ca0335929e42)
* Look at the already created [providers](https://socialiteproviders.com/) for inspiration.

## Overriding a Built-in Provider

Expand All @@ -91,7 +86,7 @@ return Socialite::with('provider-name')->setConfig($config)->redirect();

## Creating an OAuth1 Server Class

Take a look at the other [OAuth1 providers](https://socialiteproviders.netlify.app/) for inspiration.
Take a look at the other [OAuth1 providers](https://socialiteproviders.com/) for inspiration.

## Getting the Access Token Response Body

Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@
"source": "https://github.com/socialiteproviders/manager"
},
"require": {
"php": "^8.2",
"illuminate/support": "^11.0 || ^12.0 || ^13.0",
"laravel/socialite": "^5.5"
"php": "^8.3",
"illuminate/support": "^12.0 || ^13.0",
"laravel/socialite": "^5.29"
},
"require-dev": {
"mockery/mockery": "^1.2",
"phpunit/phpunit": "^9.0"
"mockery/mockery": "^1.6",
"phpunit/phpunit": "^12.5"
},
"minimum-stability": "stable",
"autoload": {
Expand Down
15 changes: 3 additions & 12 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,31 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/12.5/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
beStrictAboutOutputDuringTests="true"
beStrictAboutTestsThatDoNotTestAnything="true"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
failOnRisky="true"
failOnWarning="true"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
verbose="true"
>

<coverage processUncoveredFiles="true">
<source>
<include>
<directory suffix=".php">src/</directory>
</include>
<report>
<clover outputFile="build/logs/clover.xml"/>
<text outputFile="php://stdout"/>
</report>
</coverage>
</source>

<testsuites>
<testsuite name="SocialiteProviders Manager Test Suite">
Expand Down
25 changes: 23 additions & 2 deletions src/OAuth1/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,27 @@ abstract class Server extends BaseServer
{
use ConfigTrait;

/**
* The client ID set via the dynamic config.
*
* @var string
*/
protected $clientId;

/**
* The client secret set via the dynamic config.
*
* @var string
*/
protected $clientSecret;

/**
* The redirect URL set via the dynamic config.
*
* @var string
*/
protected $redirectUrl;

/**
* The custom parameters to be sent with the request.
*
Expand All @@ -39,12 +60,12 @@ abstract class Server extends BaseServer
* the temporary credentials identifier as passed back by the server
* and finally the verifier code.
*
* @param \League\OAuth1\Client\Credentials\TemporaryCredentials $temporaryCredentials
* @param TemporaryCredentials $temporaryCredentials
* @param string $temporaryIdentifier
* @param string $verifier
* @return array
*
* @throws \InvalidArgumentException
* @throws InvalidArgumentException
*/
public function getTokenCredentials(TemporaryCredentials $temporaryCredentials, $temporaryIdentifier, $verifier)
{
Expand Down
20 changes: 3 additions & 17 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,9 @@ class ServiceProvider extends SocialiteServiceProvider
*/
public function boot()
{
if ($this->app instanceof \Illuminate\Foundation\Application) {
// Laravel
$this->app->booted(function () {
$socialiteWasCalled = app(SocialiteWasCalled::class);

event($socialiteWasCalled);
});
} else {
// Lumen
$socialiteWasCalled = app(SocialiteWasCalled::class);

event($socialiteWasCalled);
}
$this->app->booted(function () {
event(app(SocialiteWasCalled::class));
});
}

/**
Expand All @@ -35,10 +25,6 @@ public function register()
{
parent::register();

if (class_exists('Laravel\Lumen\Application') && ! defined('SOCIALITEPROVIDERS_STATELESS')) {
define('SOCIALITEPROVIDERS_STATELESS', true);
}

if (! $this->app->bound(ConfigRetrieverInterface::class)) {
$this->app->singleton(ConfigRetrieverInterface::class, fn () => new ConfigRetriever);
}
Expand Down
17 changes: 5 additions & 12 deletions tests/ConfigRetrieverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace SocialiteProviders\Manager\Test;

use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
use SocialiteProviders\Manager\Exception\MissingConfigException;
use SocialiteProviders\Manager\Helpers\ConfigRetriever;
Expand All @@ -10,9 +11,7 @@ class ConfigRetrieverTest extends TestCase
{
use ManagerTestTrait;

/**
* @test
*/
#[Test]
public function it_throws_if_there_is_a_problem_with_the_services_config(): void
{
$this->expectExceptionObject(new MissingConfigException('There is no services entry for test'));
Expand All @@ -28,9 +27,7 @@ public function it_throws_if_there_is_a_problem_with_the_services_config(): void
$configRetriever->fromServices($providerName)->get();
}

/**
* @test
*/
#[Test]
public function it_throws_if_there_are_missing_items_in_the_services_config(): void
{
$this->expectExceptionObject(new MissingConfigException('There is no services entry for test'));
Expand All @@ -46,9 +43,7 @@ public function it_throws_if_there_are_missing_items_in_the_services_config(): v
$configRetriever->fromServices($providerName)->get();
}

/**
* @test
*/
#[Test]
public function it_retrieves_a_config_from_the_services(): void
{
$providerName = 'test';
Expand Down Expand Up @@ -77,9 +72,7 @@ public function it_retrieves_a_config_from_the_services(): void
$this->assertSame($additionalConfigItem, $result['additional']);
}

/**
* @test
*/
#[Test]
public function it_retrieves_a_config_from_the_services_with_guzzle(): void
{
$providerName = 'test';
Expand Down
13 changes: 4 additions & 9 deletions tests/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

namespace SocialiteProviders\Manager;

use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;

class ConfigTest extends TestCase
{
/**
* @test
*/
#[Test]
public function it_returns_a_config_array(): void
{
$key = 'key';
Expand All @@ -25,9 +24,7 @@ public function it_returns_a_config_array(): void
$this->assertSame($result, $config->get());
}

/**
* @test
*/
#[Test]
public function it_allows_additional_config_items(): void
{
$key = 'key';
Expand All @@ -46,9 +43,7 @@ public function it_allows_additional_config_items(): void
$this->assertSame($result, $config->get());
}

/**
* @test
*/
#[Test]
public function it_allows_closure_config_redirect()
{
$key = 'key';
Expand Down
13 changes: 4 additions & 9 deletions tests/OAuth1ProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Laravel\Socialite\Contracts\Factory as SocialiteFactoryContract;
use Mockery as m;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
use SocialiteProviders\Manager\Exception\InvalidArgumentException;
use SocialiteProviders\Manager\SocialiteWasCalled;
Expand All @@ -12,9 +13,7 @@ class OAuth1ProviderTest extends TestCase
{
use ManagerTestTrait;

/**
* @test
*/
#[Test]
public function it_should_build_a_provider_and_extend_socialite(): void
{
$providerName = 'bar';
Expand Down Expand Up @@ -56,9 +55,7 @@ public function it_should_build_a_provider_and_extend_socialite(): void
);
}

/**
* @test
*/
#[Test]
public function it_throws_if_given_an_invalid_oauth1_provider(): void
{
$this->expectExceptionObject(new InvalidArgumentException("FooBar doesn't exist"));
Expand Down Expand Up @@ -87,9 +84,7 @@ public function it_throws_if_given_an_invalid_oauth1_provider(): void
);
}

/**
* @test
*/
#[Test]
public function it_throws_if_given_an_invalid_oauth1_server(): void
{
$this->expectExceptionObject(new InvalidArgumentException("FooBar doesn't exist"));
Expand Down
Loading
Loading