Skip to content

Commit

Permalink
ajustes
Browse files Browse the repository at this point in the history
  • Loading branch information
marcossaoleo committed Jun 26, 2024
1 parent c626210 commit 7ff7cd3
Show file tree
Hide file tree
Showing 23 changed files with 39 additions and 179 deletions.
119 changes: 0 additions & 119 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,119 +0,0 @@
# Change Log
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/).

## [Unreleased]

## [1.13.0] - 2023-02-27
### Added
- Support Laravel 9-10

### Removed
- Some older versions

## [1.12.0] - 2021-03-07
### Added
- A check that we are not on the callback route to prevent infinite looping in case the middleware is added globally
- Logout method to Guard

## [1.11.0] - 2021-03-06
### Added
- Laravel 8 / PHP 8 support

### Changed
- Use GitHub actions instead of Travis

### Removed
- Laravel 5 / PHP <= 7.2 support

## [1.10.0] - 2020-05-12
### Added
- Laravel 7 support
- PHP 7.4 coverage

## [1.9.0] - 2019-09-23
### Added
- Laravel 6 support

### Removed
- Laravel 5.4 / PHP 5.6 support

## [1.8.0] - 2019-06-01
### Added
- Alternative middleware that only checks but doesn't redirect if not logged
- PHP 7.3 Travis coverage

## [1.7.1] - 2019-03-23
### Fixed
- No longer attempt refresh_token grant without token
- Handle errors during refresh_token (same as invalid access-token -> Redirect to IP authorize)

## [1.7.0] - 2019-03-10
### Added
- Laravel 5.8 support

## [1.6.0] - 2018-12-30
### Added
- Possibility to specify an "AuthWrapperFactory" allowing custom creation of the User object

## [1.5.0] - 2018-11-03
### Added
- Laravel 5.7 support

### Changed
- Tests: Assign the middleware as route-middleware

### Fixed
- Readme: Config publish command quotes (otherwise would need to use `\\` in namespace)

## [1.4.0] - 2018-04-19
### Added
- Laravel 5.6 support

### Fixed
- Readme: composer require package name

## [1.3.0] - 2017-09-19
### Added
- Laravel 5.5 support
- Package Auto-Discovery

### Changed
- Travis build matrix
- Improved dependency version constraints
- Allow `league/oauth2-client` also at v1 - even though I don't recommend it a short test showed no problems/incompatibilities

### Fixed
- PHP 5.6 install stuck because of (loose) testbench constraints

## [1.2.0] - 2017-06-29
### Added
- `Auth`-driver *viaRequest* & `Authenticatable` wrapper

## [1.1.0] - 2017-05-25
### Added
- Configuration option to specify a custom OAuth2 provider class

## 1.0.0 - 2017-05-21
### Added
- Basic Project setup
- OAuth2 client middleware & callback
- Keeps token in session
- Refreshes expired tokens
- (Cached) resource owner info

[Unreleased]: https://github.com/kronthto/laravel-oauth2-login/compare/v1.12.0...HEAD
[1.12.0]: https://github.com/kronthto/laravel-oauth2-login/compare/v1.11.0...v1.12.0
[1.11.0]: https://github.com/kronthto/laravel-oauth2-login/compare/v1.10.0...v1.11.0
[1.10.0]: https://github.com/kronthto/laravel-oauth2-login/compare/v1.9.0...v1.10.0
[1.9.0]: https://github.com/kronthto/laravel-oauth2-login/compare/v1.8.0...v1.9.0
[1.8.0]: https://github.com/kronthto/laravel-oauth2-login/compare/v1.7.1...v1.8.0
[1.7.1]: https://github.com/kronthto/laravel-oauth2-login/compare/v1.7.0...v1.7.1
[1.7.0]: https://github.com/kronthto/laravel-oauth2-login/compare/v1.6.0...v1.7.0
[1.6.0]: https://github.com/kronthto/laravel-oauth2-login/compare/v1.5.0...v1.6.0
[1.5.0]: https://github.com/kronthto/laravel-oauth2-login/compare/v1.4.0...v1.5.0
[1.4.0]: https://github.com/kronthto/laravel-oauth2-login/compare/v1.3.0...v1.4.0
[1.3.0]: https://github.com/kronthto/laravel-oauth2-login/compare/v1.2.0...v1.3.0
[1.2.0]: https://github.com/kronthto/laravel-oauth2-login/compare/v1.1.0...v1.2.0
[1.1.0]: https://github.com/kronthto/laravel-oauth2-login/compare/v1.0.0...v1.1.0
21 changes: 0 additions & 21 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,21 +0,0 @@
# The MIT License (MIT)

Copyright (c) 2023 Tobias Kronthaler <[email protected]>

> Permission is hereby granted, free of charge, to any person obtaining a copy
> of this software and associated documentation files (the "Software"), to deal
> in the Software without restriction, including without limitation the rights
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> copies of the Software, and to permit persons to whom the Software is
> furnished to do so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in
> all copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> THE SOFTWARE.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"autoload": {
"psr-4": {
"Kronthto\\LaravelOAuth2Login\\": "src/"
"Marcossaoleo\\LaravelOAuth2Login\\": "src/"
}
},
"autoload-dev": {
Expand All @@ -47,7 +47,7 @@
"extra": {
"laravel": {
"providers": [
"Kronthto\\LaravelOAuth2Login\\ServiceProvider"
"Marcossaoleo\\LaravelOAuth2Login\\ServiceProvider"
]
}
},
Expand Down
18 changes: 9 additions & 9 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ You could describe it as a bridge between Laravel and [league/oauth2-client](htt

## Install

* Using composer: `$ composer require kronthto/laravel-oauth2-login`
* Register the service provider (Auto-Discovery enabled): `Kronthto\LaravelOAuth2Login\ServiceProvider`
* Publish the config file: `$ artisan vendor:publish --provider="Kronthto\LaravelOAuth2Login\ServiceProvider"`
* Using composer: `$ composer require marcossaoleo/laravel-oauth2-login`
* Register the service provider (Auto-Discovery enabled): `Marcossaoleo\LaravelOAuth2Login\ServiceProvider`
* Publish the config file: `$ artisan vendor:publish --provider="Marcossaoleo\LaravelOAuth2Login\ServiceProvider"`
* Put the credentials of your OAuth Provider in the published config

## Usage

Add the `Kronthto\LaravelOAuth2Login\CheckOAuth2` middleware to the routes (-groups) you want to protect.
Add the `Marcossaoleo\LaravelOAuth2Login\CheckOAuth2` middleware to the routes (-groups) you want to protect.

**Bear in mind that this only ensures that some user is logged in**, if you require further authorization checks those will still have to be implemented. This package stores the resource owner info as an Request-attribute to enable you to do so.

This redirects unauthenticated users. If on some routes you only want to check whether a session by this package exists (for instance to display a login/logout button in your template) use `Kronthto\LaravelOAuth2Login\OnlyCheckOAuth`.
This redirects unauthenticated users. If on some routes you only want to check whether a session by this package exists (for instance to display a login/logout button in your template) use `Marcossaoleo\LaravelOAuth2Login\OnlyCheckOAuth`.
It will also refresh tokens and pull up to date resource owner data, but never redirect. On failure it just doesn't set the Request attribute.

### `Auth` guard
Expand Down Expand Up @@ -60,9 +60,9 @@ Please see the [CHANGELOG](CHANGELOG.md) for more information on what has change
The MIT License (MIT). Please see the [License File](LICENSE.md) for more information.

[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square
[ico-githubversion]: https://badge.fury.io/gh/kronthto%2Flaravel-oauth2-login.svg
[ico-build]: https://travis-ci.org/kronthto/laravel-oauth2-login.svg?branch=master
[ico-githubversion]: https://badge.fury.io/gh/marcossaoleo%2Flaravel-oauth2-login.svg
[ico-build]: https://travis-ci.org/marcossaoleo/laravel-oauth2-login.svg?branch=master

[link-releases]: https://github.com/kronthto/laravel-oauth2-login/releases
[link-releases]: https://github.com/marcossaoleo/laravel-oauth2-login/releases
[link-contributors]: ../../contributors
[link-build]: https://travis-ci.org/kronthto/laravel-oauth2-login
[link-build]: https://travis-ci.org/marcossaoleo/laravel-oauth2-login
4 changes: 2 additions & 2 deletions resources/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
'urlAccessToken' => 'http://brentertainment.com/oauth2/lockdin/token',
'urlResourceOwnerDetails' => 'http://brentertainment.com/oauth2/lockdin/resource',
],
'provider' => \Kronthto\LaravelOAuth2Login\OAuthProvider::class,
'provider' => \Marcossaoleo\LaravelOAuth2Login\OAuthProvider::class,

'oauth_redirect_path' => '/oauth2/callback',

Expand All @@ -19,7 +19,7 @@
'resource_owner_attribute' => 'oauth2_user',
'auth_driver_key' => 'oauth2',
'authWrapperFactory' => null, // Can be used to specify a factory with an __invoke (ResourceOwnerInterface passed as arg1) method to build a custom User object
'authWrapper' => \Kronthto\LaravelOAuth2Login\OAuthUserWrapper::class, // Ignored if authWrapperFactory is not null
'authWrapper' => \Marcossaoleo\LaravelOAuth2Login\OAuthUserWrapper::class, // Ignored if authWrapperFactory is not null

'cacheUserDetailsFor' => 30, // minutes
'cacheUserPrefix' => 'oauth_user_',
Expand Down
2 changes: 1 addition & 1 deletion resources/routes.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

Route::get(config('oauth2login.oauth_redirect_path'),
'Kronthto\LaravelOAuth2Login\OAuthLoginController@authorizeCallback')
'Marcossaoleo\LaravelOAuth2Login\OAuthLoginController@authorizeCallback')
->middleware('web')
->name('oauth2login.oauth_redirect_route')
;
2 changes: 1 addition & 1 deletion src/AuthFromRequest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Kronthto\LaravelOAuth2Login;
namespace Marcossaoleo\LaravelOAuth2Login;

use Illuminate\Http\Request;

Expand Down
2 changes: 1 addition & 1 deletion src/CheckOAuth2.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Kronthto\LaravelOAuth2Login;
namespace Marcossaoleo\LaravelOAuth2Login;

use Closure;
use Illuminate\Http\Request;
Expand Down
2 changes: 1 addition & 1 deletion src/OAuthGuard.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Kronthto\LaravelOAuth2Login;
namespace Marcossaoleo\LaravelOAuth2Login;

class OAuthGuard extends \Illuminate\Auth\RequestGuard
{
Expand Down
2 changes: 1 addition & 1 deletion src/OAuthLoginController.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Kronthto\LaravelOAuth2Login;
namespace Marcossaoleo\LaravelOAuth2Login;

use Illuminate\Http\Request;

Expand Down
4 changes: 2 additions & 2 deletions src/OAuthProvider.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Kronthto\LaravelOAuth2Login;
namespace Marcossaoleo\LaravelOAuth2Login;

use League\OAuth2\Client\Provider\GenericProvider;

Expand All @@ -10,7 +10,7 @@ protected function getDefaultHeaders()
{
return array_merge(parent::getDefaultHeaders(), [
'Accept' => 'application/json',
'User-Agent' => config('app.name', 'kronthto/laravel-oauth2-login'),
'User-Agent' => config('app.name', 'marcossaoleo/laravel-oauth2-login'),
]);
}
}
2 changes: 1 addition & 1 deletion src/OAuthProviderService.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Kronthto\LaravelOAuth2Login;
namespace Marcossaoleo\LaravelOAuth2Login;

use Carbon\Carbon;
use Illuminate\Support\Facades\Cache;
Expand Down
2 changes: 1 addition & 1 deletion src/OAuthUserWrapper.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Kronthto\LaravelOAuth2Login;
namespace Marcossaoleo\LaravelOAuth2Login;

use Illuminate\Contracts\Auth\Authenticatable;
use League\OAuth2\Client\Provider\ResourceOwnerInterface;
Expand Down
2 changes: 1 addition & 1 deletion src/OnlyCheckOAuth.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Kronthto\LaravelOAuth2Login;
namespace Marcossaoleo\LaravelOAuth2Login;

use Closure;
use Illuminate\Http\Request;
Expand Down
2 changes: 1 addition & 1 deletion src/ServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Kronthto\LaravelOAuth2Login;
namespace Marcossaoleo\LaravelOAuth2Login;

use Auth;
use Illuminate\Support\ServiceProvider as BaseServiceProvider;
Expand Down
4 changes: 2 additions & 2 deletions tests/CallbackTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace Tests;

use Illuminate\Foundation\Testing\Concerns\InteractsWithSession;
use Kronthto\LaravelOAuth2Login\OAuthProvider;
use Kronthto\LaravelOAuth2Login\OAuthProviderService;
use Marcossaoleo\LaravelOAuth2Login\OAuthProvider;
use Marcossaoleo\LaravelOAuth2Login\OAuthProviderService;
use League\OAuth2\Client\Token\AccessToken;

class CallbackTest extends TestCase
Expand Down
6 changes: 3 additions & 3 deletions tests/CheckOnlyMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
use Auth;
use Illuminate\Http\Request;
use Illuminate\Routing\Router;
use Kronthto\LaravelOAuth2Login\OAuthProvider;
use Kronthto\LaravelOAuth2Login\OAuthProviderService;
use Marcossaoleo\LaravelOAuth2Login\OAuthProvider;
use Marcossaoleo\LaravelOAuth2Login\OAuthProviderService;
use League\OAuth2\Client\Provider\Exception\IdentityProviderException;
use League\OAuth2\Client\Token\AccessToken;

class CheckOnlyMiddlewareTest extends MiddlewareTest
{
protected function addWebRoutes(Router $router)
{
$router->group(['middleware' => \Kronthto\LaravelOAuth2Login\OnlyCheckOAuth::class], function (Router $router) {
$router->group(['middleware' => \Marcossaoleo\LaravelOAuth2Login\OnlyCheckOAuth::class], function (Router $router) {
$router->get('web/ping', [
'as' => 'web.ping',
'uses' => function () {
Expand Down
2 changes: 1 addition & 1 deletion tests/CustomAuthFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Tests;

use Kronthto\LaravelOAuth2Login\OAuthProviderService;
use Marcossaoleo\LaravelOAuth2Login\OAuthProviderService;
use League\OAuth2\Client\Provider\GenericResourceOwner;
use League\OAuth2\Client\Provider\ResourceOwnerInterface;
use League\OAuth2\Client\Token\AccessToken;
Expand Down
2 changes: 1 addition & 1 deletion tests/GlobalMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Illuminate\Foundation\Testing\Concerns\InteractsWithSession;
use Illuminate\Routing\Router;
use Kronthto\LaravelOAuth2Login\CheckOAuth2;
use Marcossaoleo\LaravelOAuth2Login\CheckOAuth2;

class GlobalMiddlewareTest extends TestCase
{
Expand Down
4 changes: 2 additions & 2 deletions tests/LogoutTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Illuminate\Foundation\Testing\Concerns\InteractsWithSession;
use Illuminate\Http\Request;
use Illuminate\Routing\Router;
use Kronthto\LaravelOAuth2Login\OAuthProviderService;
use Marcossaoleo\LaravelOAuth2Login\OAuthProviderService;
use League\OAuth2\Client\Provider\GenericResourceOwner;
use League\OAuth2\Client\Token\AccessToken;

Expand All @@ -24,7 +24,7 @@ protected function getEnvironmentSetUp($app)

protected function addWebRoutes(Router $router)
{
$router->group(['middleware' => \Kronthto\LaravelOAuth2Login\CheckOAuth2::class], function (Router $router) {
$router->group(['middleware' => \Marcossaoleo\LaravelOAuth2Login\CheckOAuth2::class], function (Router $router) {
parent::addWebRoutes($router);
$router->get('web/email', [
'as' => 'web.email',
Expand Down
6 changes: 3 additions & 3 deletions tests/MiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
use Illuminate\Foundation\Testing\Concerns\InteractsWithSession;
use Illuminate\Http\Request;
use Illuminate\Routing\Router;
use Kronthto\LaravelOAuth2Login\OAuthProvider;
use Kronthto\LaravelOAuth2Login\OAuthProviderService;
use Marcossaoleo\LaravelOAuth2Login\OAuthProvider;
use Marcossaoleo\LaravelOAuth2Login\OAuthProviderService;
use League\OAuth2\Client\Provider\Exception\IdentityProviderException;
use League\OAuth2\Client\Provider\GenericResourceOwner;
use League\OAuth2\Client\Token\AccessToken;
Expand All @@ -27,7 +27,7 @@ protected function getEnvironmentSetUp($app)

protected function addWebRoutes(Router $router)
{
$router->group(['middleware' => \Kronthto\LaravelOAuth2Login\CheckOAuth2::class], function (Router $router) {
$router->group(['middleware' => \Marcossaoleo\LaravelOAuth2Login\CheckOAuth2::class], function (Router $router) {
parent::addWebRoutes($router);
$router->get('web/email', [
'as' => 'web.email',
Expand Down
Loading

0 comments on commit 7ff7cd3

Please sign in to comment.