From 8d59a55dfc0f20e5fc38506f917729faeda1eeb4 Mon Sep 17 00:00:00 2001 From: Joel Butcher Date: Fri, 8 Sep 2023 15:29:43 +0100 Subject: [PATCH] Added support for LinkedIn OpenID --- composer.json | 2 +- src/Providers.php | 20 +++++++++++++++ .../LinkedInOpenIdOauth2RefreshResolver.php | 25 +++++++++++++++++++ src/Socialstream.php | 8 ++++++ src/SocialstreamServiceProvider.php | 4 ++- .../js/Components/ConnectedAccount.vue | 17 +++++++++++-- .../resources/js/Components/Socialstream.vue | 5 ++++ .../components/connected-account.blade.php | 1 + .../views/components/socialstream.blade.php | 7 ++++++ .../SocialstreamRegistrationTest.php | 11 +++++--- stubs/tests/SocialstreamRegistrationTest.php | 11 +++++--- tests/Unit/ProvidersTest.php | 6 +++++ 12 files changed, 105 insertions(+), 12 deletions(-) create mode 100644 src/Resolvers/OAuth/LinkedInOpenIdOauth2RefreshResolver.php diff --git a/composer.json b/composer.json index 14083dbb..0f3e4289 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,7 @@ "require": { "php": "^8.1", "laravel/jetstream": "^3.0|^4.0", - "laravel/socialite": "^5.8.1" + "laravel/socialite": "^5.9" }, "require-dev": { "inertiajs/inertia-laravel": "^0.6.4", diff --git a/src/Providers.php b/src/Providers.php index 704afc98..7b99b134 100644 --- a/src/Providers.php +++ b/src/Providers.php @@ -63,6 +63,14 @@ public static function hasLinkedInSupport(): bool return static::enabled(static::linkedin()); } + /** + * Determine if the application has support for the LinkedIn OpenID provider. + */ + public static function hasLinkedInOpenIdSupport(): bool + { + return static::enabled(static::linkedinOpenId()); + } + /** * Determine if the application has support for the Slack provider. */ @@ -73,6 +81,8 @@ public static function hasSlackSupport(): bool /** * Determine if the application has support for the Twitter provider. + * + * @deprecated use `hasTwitterOAuth1Support` instead */ public static function hasTwitterSupport(): bool { @@ -144,6 +154,14 @@ public static function linkedin(): string return 'linkedin'; } + /** + * Enable the LinkedIn OpenID provider. + */ + public static function linkedinOpenId(): string + { + return 'linkedin-openid'; + } + /** * Enable the Slack provider. */ @@ -154,6 +172,8 @@ public static function slack(): string /** * Enable the Twitter provider. + * + * @deprecated use `twitterOAuth1` instead. */ public static function twitter(): string { diff --git a/src/Resolvers/OAuth/LinkedInOpenIdOauth2RefreshResolver.php b/src/Resolvers/OAuth/LinkedInOpenIdOauth2RefreshResolver.php new file mode 100644 index 00000000..05403450 --- /dev/null +++ b/src/Resolvers/OAuth/LinkedInOpenIdOauth2RefreshResolver.php @@ -0,0 +1,25 @@ + { + switch(this.provider) { + case 'twitter': + case 'twitter-oauth-2': + return 'Twitter' + case 'linkedin': + case 'linkedin-openid': + return 'LinkedIn' + default: + return name.charAt(0).toUpperCase() + provider.slice(1); + }; +});