-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
79d9db3
commit 6589f24
Showing
4 changed files
with
346 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
<?php | ||
|
||
use Laravel\Fortify\Features; | ||
|
||
return [ | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Fortify Guard | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Here you may specify which authentication guard Fortify will use while | ||
| authenticating users. This value should correspond with one of your | ||
| guards that is already present in your "auth" configuration file. | ||
| | ||
*/ | ||
|
||
'guard' => 'web', | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Fortify Password Broker | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Here you may specify which password broker Fortify can use when a user | ||
| is resetting their password. This configured value should match one | ||
| of your password brokers setup in your "auth" configuration file. | ||
| | ||
*/ | ||
|
||
'passwords' => 'users', | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Username / Email | ||
|-------------------------------------------------------------------------- | ||
| | ||
| This value defines which model attribute should be considered as your | ||
| application's "username" field. Typically, this might be the email | ||
| address of the users but you are free to change this value here. | ||
| | ||
| Out of the box, Fortify expects forgot password and reset password | ||
| requests to have a field named 'email'. If the application uses | ||
| another name for the field you may define it below as needed. | ||
| | ||
*/ | ||
|
||
'username' => 'email', | ||
|
||
'email' => 'email', | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Lowercase Usernames | ||
|-------------------------------------------------------------------------- | ||
| | ||
| This value defines whether usernames should be lowercased before saving | ||
| them in the database, as some database system string fields are case | ||
| sensitive. You may disable this for your application if necessary. | ||
| | ||
*/ | ||
|
||
'lowercase_usernames' => true, | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Home Path | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Here you may configure the path where users will get redirected during | ||
| authentication or password reset when the operations are successful | ||
| and the user is authenticated. You are free to change this value. | ||
| | ||
*/ | ||
|
||
'home' => '/dashboard', | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Fortify Routes Prefix / Subdomain | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Here you may specify which prefix Fortify will assign to all the routes | ||
| that it registers with the application. If necessary, you may change | ||
| subdomain under which all of the Fortify routes will be available. | ||
| | ||
*/ | ||
|
||
'prefix' => '', | ||
|
||
'domain' => null, | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Fortify Routes Middleware | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Here you may specify which middleware Fortify will assign to the routes | ||
| that it registers with the application. If necessary, you may change | ||
| these middleware but typically this provided default is preferred. | ||
| | ||
*/ | ||
|
||
'middleware' => ['web'], | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Rate Limiting | ||
|-------------------------------------------------------------------------- | ||
| | ||
| By default, Fortify will throttle logins to five requests per minute for | ||
| every email and IP address combination. However, if you would like to | ||
| specify a custom rate limiter to call then you may specify it here. | ||
| | ||
*/ | ||
|
||
'limiters' => [ | ||
'login' => 'login', | ||
'two-factor' => 'two-factor', | ||
], | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Register View Routes | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Here you may specify if the routes returning views should be disabled as | ||
| you may not need them when building your own application. This may be | ||
| especially true if you're writing a custom single-page application. | ||
| | ||
*/ | ||
|
||
'views' => true, | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Features | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Some of the Fortify features are optional. You may disable the features | ||
| by removing them from this array. You're free to only remove some of | ||
| these features or you can even remove all of these if you need to. | ||
| | ||
*/ | ||
|
||
'features' => [ | ||
Features::registration(), | ||
Features::resetPasswords(), | ||
// Features::emailVerification(), | ||
Features::updateProfileInformation(), | ||
Features::updatePasswords(), | ||
Features::twoFactorAuthentication([ | ||
'confirm' => true, | ||
'confirmPassword' => true, | ||
// 'window' => 0, | ||
]), | ||
], | ||
|
||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<?php | ||
|
||
use Laravel\Jetstream\Features; | ||
use Laravel\Jetstream\Http\Middleware\AuthenticateSession; | ||
|
||
return [ | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Jetstream Stack | ||
|-------------------------------------------------------------------------- | ||
| | ||
| This configuration value informs Jetstream which "stack" you will be | ||
| using for your application. In general, this value is set for you | ||
| during installation and will not need to be changed after that. | ||
| | ||
*/ | ||
|
||
'stack' => 'inertia', | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Jetstream Route Middleware | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Here you may specify which middleware Jetstream will assign to the routes | ||
| that it registers with the application. When necessary, you may modify | ||
| these middleware; however, this default value is usually sufficient. | ||
| | ||
*/ | ||
|
||
'middleware' => ['web'], | ||
|
||
'auth_session' => AuthenticateSession::class, | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Jetstream Guard | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Here you may specify the authentication guard Jetstream will use while | ||
| authenticating users. This value should correspond with one of your | ||
| guards that is already present in your "auth" configuration file. | ||
| | ||
*/ | ||
|
||
'guard' => 'sanctum', | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Features | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Some of Jetstream's features are optional. You may disable the features | ||
| by removing them from this array. You're free to only remove some of | ||
| these features or you can even remove all of these if you need to. | ||
| | ||
*/ | ||
|
||
'features' => [ | ||
// Features::termsAndPrivacyPolicy(), | ||
// Features::profilePhotos(), | ||
// Features::api(), | ||
// Features::teams(['invitations' => true]), | ||
Features::accountDeletion(), | ||
], | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Profile Photo Disk | ||
|-------------------------------------------------------------------------- | ||
| | ||
| This configuration value determines the default disk that will be used | ||
| when storing profile photos for your application's users. Typically | ||
| this will be the "public" disk but you may adjust this if needed. | ||
| | ||
*/ | ||
|
||
'profile_photo_disk' => 'public', | ||
|
||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
use JoelButcher\Socialstream\Providers; | ||
|
||
return [ | ||
'middleware' => ['web'], | ||
'prompt' => 'Or Login Via', | ||
'providers' => [ | ||
// Providers::github(), | ||
], | ||
'component' => 'socialstream::components.socialstream', | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<?php | ||
|
||
namespace tests; | ||
|
||
use Illuminate\Foundation\Testing\RefreshDatabase; | ||
use Illuminate\Support\Facades\Session; | ||
use JoelButcher\Socialstream\Providers; | ||
use Laravel\Fortify\Features as FortifyFeatures; | ||
use Laravel\Socialite\Facades\Socialite; | ||
use Laravel\Socialite\Two\User; | ||
use Mockery; | ||
use Tests\TestCase; | ||
|
||
class SocialstreamRegistrationTest extends TestCase | ||
{ | ||
use RefreshDatabase; | ||
|
||
/** | ||
* @dataProvider socialiteProvidersDataProvider | ||
*/ | ||
public function test_users_get_redirected_correctly(string $provider): void | ||
{ | ||
if (! Providers::enabled($provider)) { | ||
$this->markTestSkipped("Registration support with the $provider provider is not enabled."); | ||
} | ||
|
||
config()->set("services.$provider", [ | ||
'client_id' => 'client-id', | ||
'client_secret' => 'client-secret', | ||
'redirect' => "http://localhost/oauth/$provider/callback", | ||
]); | ||
|
||
$response = $this->get("/oauth/$provider"); | ||
$response->assertRedirectContains($provider); | ||
} | ||
|
||
/** | ||
* @dataProvider socialiteProvidersDataProvider | ||
*/ | ||
public function test_users_can_register_using_socialite_providers(string $socialiteProvider) | ||
{ | ||
if (! FortifyFeatures::enabled(FortifyFeatures::registration())) { | ||
$this->markTestSkipped('Registration support is not enabled.'); | ||
} | ||
|
||
if (! Providers::enabled($socialiteProvider)) { | ||
$this->markTestSkipped("Registration support with the $socialiteProvider provider is not enabled."); | ||
} | ||
|
||
$user = (new User()) | ||
->map([ | ||
'id' => 'abcdefgh', | ||
'nickname' => 'Jane', | ||
'name' => 'Jane Doe', | ||
'email' => '[email protected]', | ||
'avatar' => null, | ||
'avatar_original' => null, | ||
]) | ||
->setToken('user-token') | ||
->setRefreshToken('refresh-token') | ||
->setExpiresIn(3600); | ||
|
||
$provider = Mockery::mock('Laravel\\Socialite\\Two\\'.$socialiteProvider.'Provider'); | ||
$provider->shouldReceive('user')->once()->andReturn($user); | ||
|
||
Socialite::shouldReceive('driver')->once()->with($socialiteProvider)->andReturn($provider); | ||
|
||
Session::put('socialstream.previous_url', route('register')); | ||
|
||
$response = $this->get("/oauth/$socialiteProvider/callback"); | ||
|
||
$this->assertAuthenticated(); | ||
$response->assertRedirect(route('dashboard', absolute: false)); | ||
} | ||
|
||
/** | ||
* @return array<int, array<int, string>> | ||
*/ | ||
public static function socialiteProvidersDataProvider(): array | ||
{ | ||
return [ | ||
[Providers::bitbucket()], | ||
[Providers::facebook()], | ||
[Providers::github()], | ||
[Providers::gitlab()], | ||
[Providers::google()], | ||
[Providers::linkedin()], | ||
[Providers::linkedinOpenId()], | ||
[Providers::slack()], | ||
[Providers::twitterOAuth1()], | ||
[Providers::twitterOAuth2()], | ||
]; | ||
} | ||
} |