]> BookStack Code Mirror - bookstack/commitdiff
Updated okta config keys, made SVG fully vector
authorDan Brown <redacted>
Sat, 9 Dec 2017 13:32:45 +0000 (13:32 +0000)
committerDan Brown <redacted>
Sat, 9 Dec 2017 13:32:45 +0000 (13:32 +0000)
Also added some additional error handling to login.

app/Http/Controllers/Auth/RegisterController.php
app/Services/SocialAuthService.php
config/services.php
resources/assets/icons/okta.svg
resources/lang/en/errors.php

index 0fa005e1fbe0b77fee9b997c186602121cdc58e9..5a7a5e971b5fcc86a0fcecd5ec4e2b4fec5820cf 100644 (file)
@@ -250,15 +250,27 @@ class RegisterController extends Controller
     /**
      * The callback for social login services.
      * @param $socialDriver
+     * @param Request $request
      * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
      * @throws SocialSignInException
+     * @throws UserRegistrationException
+     * @throws \BookStack\Exceptions\SocialDriverNotConfigured
+     * @throws ConfirmationEmailException
      */
-    public function socialCallback($socialDriver)
+    public function socialCallback($socialDriver, Request $request)
     {
         if (!session()->has('social-callback')) {
             throw new SocialSignInException(trans('errors.social_no_action_defined'), '/login');
         }
 
+        // Check request for error information
+        if ($request->has('error') && $request->has('error_description')) {
+            throw new SocialSignInException(trans('errors.social_login_bad_response', [
+                'socialAccount' => $socialDriver,
+                'error' => $request->get('error_description'),
+            ]), '/login');
+        }
+
         $action = session()->pull('social-callback');
         if ($action == 'login') return $this->socialAuthService->handleLoginCallback($socialDriver);
         if ($action == 'register') return $this->socialRegisterCallback($socialDriver);
@@ -279,7 +291,9 @@ class RegisterController extends Controller
      * Register a new user after a registration callback.
      * @param $socialDriver
      * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
+     * @throws ConfirmationEmailException
      * @throws UserRegistrationException
+     * @throws \BookStack\Exceptions\SocialDriverNotConfigured
      */
     protected function socialRegisterCallback($socialDriver)
     {
index 6286a601445463f6a222237c747e7e8e4fbaa065..d5246453997eac985ea944bfc65fffbfb22ba572 100644 (file)
@@ -1,5 +1,7 @@
 <?php namespace BookStack\Services;
 
+use BookStack\Http\Requests\Request;
+use GuzzleHttp\Exception\ClientException;
 use Laravel\Socialite\Contracts\Factory as Socialite;
 use BookStack\Exceptions\SocialDriverNotConfigured;
 use BookStack\Exceptions\SocialSignInException;
@@ -91,7 +93,6 @@ class SocialAuthService
     public function handleLoginCallback($socialDriver)
     {
         $driver = $this->validateDriver($socialDriver);
-
         // Get user details from social driver
         $socialUser = $this->socialite->driver($driver)->user();
         $socialId = $socialUser->getId();
@@ -135,7 +136,7 @@ class SocialAuthService
             $message .= trans('errors.social_account_register_instructions', ['socialAccount' => title_case($socialDriver)]);
         }
         
-        throw new SocialSignInException($message . '.', '/login');
+        throw new SocialSignInException($message, '/login');
     }
 
     /**
index 514720d72e1aac8e7697a4602d031c8efb05bbb4..ba9be69decb9a780a8052ed62d5fefaa78a9653c 100644 (file)
@@ -81,8 +81,8 @@ return [
     ],
 
     'okta' => [
-        'client_id' => env('OKTA_KEY'),
-        'client_secret' => env('OKTA_SECRET'),
+        'client_id' => env('OKTA_APP_ID'),
+        'client_secret' => env('OKTA_APP_SECRET'),
         'redirect' => env('APP_URL') . '/login/service/okta/callback', 
         'base_url' => env('OKTA_BASE_URL'), 
         'name'          => 'Okta',
index 3ae0d63a3c7d263a33d14b29a9ff4755da4d3954..b5f3b1d3f92e9f5438e4dc1bb4369e53796b9b7d 100644 (file)
@@ -1 +1 @@
-<svg viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:1.41421;"><use id="image0" xlink:href="#_Image1" x="0" y="0" width="64px" height="64px"/><defs><image id="_Image1" width="24px" height="24px" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAACXBIWXMAAA7EAAAOxAGVKw4bAAACU0lEQVRIiaWVTUiUURSGn3PnGyXDrAjaVEIlGG2ElhHjT4RR6aZFtGgR1KaNFBjliJg/lT9tohbtWlvQD4SLUMehVhFBm3IpQYlZljSOOXNPixl/596Z0d7VcJ7zvufeb+79PiGfrj8vI7w9jlAJVABBlvwFZrH2HWKa6Y6kfBHirEbHqhAZBvbnXcCK3qC2ie66H+uByWltj7UiMrGBcICjiJkhOnYm/4CO+BPg7gaC10rkBdGxm2tKy7/ax6+BDmw6fLVU6+muHV0Z0Bbfi7GThWyAzXpyH+162YUt9JxIZhqNfZWnNY3qcVTLmTQBidkAayuw6SvZoW5JyYPMDqIjO5BQzr+f1QTjI9XEOt1BrcNbKS37Clru5F0RMUjooXflU78OecMB+hr/YNV/2m68bjZAgxOqvcijJus1L6kn8h2Vp04WhPsM4Nqeouo2OWVbPKDCACUOsIglWXS+6m8PKTW4T4Igxv0acct3bNUACw4QBrYVH292esi8AX46kXCn6AFi3nrItMHqffeq5BJtowcLhnfEm1G728kSiUZDYu6e12zMZ6KxGi9vj53C2mceahk8+U2yjUPAWW+Q6geUcximsBiwBzChIaDS64FWuiL9mS9UKnWeIPAPEKlB+JTZFUAoTy4ASRJzA8vt3G5YRMyRQq4iZUmn9zF4WlcGANw69p5QcOE/w9PAYXrrp5cKuZcpOl6F6MTm4nUXvbUzq0vu23r1paGsvB+RFgp/XJJAJ10R570p/DpoG6lGQo8R9gCl2eo8qh9RvUxP3Zd89n+rAbY6AaOFBwAAAABJRU5ErkJggg=="/></defs></svg>
\ No newline at end of file
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414"><path d="M12 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0zm-.035 5.537a6.427 6.427 0 0 1 6.428 6.428 6.427 6.427 0 0 1-6.428 6.428 6.427 6.427 0 0 1-6.428-6.428 6.427 6.427 0 0 1 6.428-6.428z" fill="#007dc1"/></svg>
\ No newline at end of file
index 572bec42be148224767dec61f1268881f98c2ed9..18ed63c6050b6dee07818af6622cb96271c4d0ed 100644 (file)
@@ -20,6 +20,7 @@ return [
     'ldap_extension_not_installed' => 'LDAP PHP extension not installed',
     'ldap_cannot_connect' => 'Cannot connect to ldap server, Initial connection failed',
     'social_no_action_defined' => 'No action defined',
+    'social_login_bad_response' => "Error received during :socialAccount login: \n:error",
     'social_account_in_use' => 'This :socialAccount account is already in use, Try logging in via the :socialAccount option.',
     'social_account_email_in_use' => 'The email :email is already in use. If you already have an account you can connect your :socialAccount account from your profile settings.',
     'social_account_existing' => 'This :socialAccount is already attached to your profile.',