]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/OpenID/OpenIDPlugin.php
XSS vulnerability when remote-subscribing
[quix0rs-gnu-social.git] / plugins / OpenID / OpenIDPlugin.php
1 <?php
2 /**
3  * StatusNet, the distributed open-source microblogging tool
4  *
5  * PHP version 5
6  *
7  * LICENCE: This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Affero General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU Affero General Public License for more details.
16  *
17  * You should have received a copy of the GNU Affero General Public License
18  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19  *
20  * @category  Plugin
21  * @package   StatusNet
22  * @author    Evan Prodromou <evan@status.net>
23  * @author    Craig Andrews <candrews@integralblue.com>
24  * @copyright 2009-2010 StatusNet, Inc.
25  * @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
26  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
27  * @link      http://status.net/
28  */
29
30 if (!defined('STATUSNET')) {
31     exit(1);
32 }
33
34 /**
35  * Plugin for OpenID authentication and identity
36  *
37  * This class enables consumer support for OpenID, the distributed authentication
38  * and identity system.
39  *
40  * Depends on: WebFinger plugin for HostMeta-lookup (user@host format)
41  *
42  * @category Plugin
43  * @package  StatusNet
44  * @author   Evan Prodromou <evan@status.net>
45  * @author   Craig Andrews <candrews@integralblue.com>
46  * @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
47  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
48  * @link     http://status.net/
49  * @link     http://openid.net/
50  */
51 class OpenIDPlugin extends Plugin
52 {
53     // Plugin parameter: set true to disallow non-OpenID logins
54     // If set, overrides the setting in database or $config['site']['openidonly']
55     public $openidOnly = null;
56
57     function initialize()
58     {
59         parent::initialize();
60         if ($this->openidOnly !== null) {
61             global $config;
62             $config['site']['openidonly'] = (bool)$this->openidOnly;
63         }
64     }
65
66     /**
67      * Add OpenID-related paths to the router table
68      *
69      * Hook for RouterInitialized event.
70      *
71      * @param URLMapper $m URL mapper
72      *
73      * @return boolean hook return
74      */
75     public function onStartInitializeRouter(URLMapper $m)
76     {
77         $m->connect('main/openid', array('action' => 'openidlogin'));
78         $m->connect('main/openidtrust', array('action' => 'openidtrust'));
79         $m->connect('settings/openid', array('action' => 'openidsettings'));
80         $m->connect('index.php?action=finishopenidlogin',
81                     array('action' => 'finishopenidlogin'));
82         $m->connect('index.php?action=finishaddopenid',
83                     array('action' => 'finishaddopenid'));
84         $m->connect('main/openidserver', array('action' => 'openidserver'));
85         $m->connect('panel/openid', array('action' => 'openidadminpanel'));
86
87         return true;
88     }
89
90     /**
91      * In OpenID-only mode, disable paths for password stuff
92      *
93      * @param string $path     path to connect
94      * @param array  $defaults path defaults
95      * @param array  $rules    path rules
96      * @param array  $result   unused
97      *
98      * @return boolean hook return
99      */
100     function onStartConnectPath(&$path, &$defaults, &$rules, &$result)
101     {
102         if (common_config('site', 'openidonly')) {
103             // Note that we should not remove the login and register
104             // actions. Lots of auth-related things link to them,
105             // such as when visiting a private site without a session
106             // or revalidating a remembered login for admin work.
107             //
108             // We take those two over with redirects to ourselves
109             // over in onArgsInitialize().
110             static $block = array('main/recoverpassword',
111                                   'settings/password');
112
113             if (in_array($path, $block)) {
114                 return false;
115             }
116         }
117
118         return true;
119     }
120
121     /**
122      * If we've been hit with password-login args, redirect
123      *
124      * @param array $args args (URL, Get, post)
125      *
126      * @return boolean hook return
127      */
128     function onArgsInitialize($args)
129     {
130         if (common_config('site', 'openidonly')) {
131             if (array_key_exists('action', $args)) {
132                 $action = trim($args['action']);
133                 if (in_array($action, array('login', 'register'))) {
134                     common_redirect(common_local_url('openidlogin'));
135                 } else if ($action == 'passwordsettings') {
136                     common_redirect(common_local_url('openidsettings'));
137                 } else if ($action == 'recoverpassword') {
138                     // TRANS: Client exception thrown when an action is not available.
139                     throw new ClientException(_m('Unavailable action.'));
140                 }
141             }
142         }
143         return true;
144     }
145
146     /**
147      * Public XRDS output hook
148      *
149      * Puts the bits of code needed by some OpenID providers to show
150      * we're good citizens.
151      *
152      * @param Action       $action         Action being executed
153      * @param XMLOutputter &$xrdsOutputter Output channel
154      *
155      * @return boolean hook return
156      */
157     function onEndPublicXRDS(Action $action, &$xrdsOutputter)
158     {
159         $xrdsOutputter->elementStart('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)',
160                                                   'xmlns:simple' => 'http://xrds-simple.net/core/1.0',
161                                                   'version' => '2.0'));
162         $xrdsOutputter->element('Type', null, 'xri://$xrds*simple');
163         //consumer
164         foreach (array('finishopenidlogin', 'finishaddopenid') as $finish) {
165             $xrdsOutputter->showXrdsService(Auth_OpenID_RP_RETURN_TO_URL_TYPE,
166                                             common_local_url($finish));
167         }
168         //provider
169         $xrdsOutputter->showXrdsService('http://specs.openid.net/auth/2.0/server',
170                                         common_local_url('openidserver'),
171                                         null,
172                                         null,
173                                         'http://specs.openid.net/auth/2.0/identifier_select');
174         $xrdsOutputter->elementEnd('XRD');
175     }
176
177     /**
178      * If we're in OpenID-only mode, hide all the main menu except OpenID login.
179      *
180      * @param Action $action Action being run
181      *
182      * @return boolean hook return
183      */
184     function onStartPrimaryNav($action)
185     {
186         if (common_config('site', 'openidonly') && !common_logged_in()) {
187             // TRANS: Tooltip for main menu option "Login"
188             $tooltip = _m('TOOLTIP', 'Login to the site.');
189             $action->menuItem(common_local_url('openidlogin'),
190                               // TRANS: Main menu option when not logged in to log in
191                               _m('MENU', 'Login'),
192                               $tooltip,
193                               false,
194                               'nav_login');
195             // TRANS: Tooltip for main menu option "Help"
196             $tooltip = _m('TOOLTIP', 'Help me!');
197             $action->menuItem(common_local_url('doc', array('title' => 'help')),
198                               // TRANS: Main menu option for help on the StatusNet site
199                               _m('MENU', 'Help'),
200                               $tooltip,
201                               false,
202                               'nav_help');
203             if (!common_config('site', 'private')) {
204                 // TRANS: Tooltip for main menu option "Search"
205                 $tooltip = _m('TOOLTIP', 'Search for people or text.');
206                 $action->menuItem(common_local_url('peoplesearch'),
207                                   // TRANS: Main menu option when logged in or when the StatusNet instance is not private
208                                   _m('MENU', 'Search'), $tooltip, false, 'nav_search');
209             }
210             Event::handle('EndPrimaryNav', array($action));
211             return false;
212         }
213         return true;
214     }
215
216     /**
217      * Menu for login
218      *
219      * If we're in openidOnly mode, we disable the menu for all other login.
220      *
221      * @param Action $action Action being executed
222      *
223      * @return boolean hook return
224      */
225     function onStartLoginGroupNav($action)
226     {
227         if (common_config('site', 'openidonly')) {
228             $this->showOpenIDLoginTab($action);
229             // Even though we replace this code, we
230             // DON'T run the End* hook, to keep others from
231             // adding tabs. Not nice, but.
232             return false;
233         }
234
235         return true;
236     }
237
238     /**
239      * Menu item for login
240      *
241      * @param Action $action Action being executed
242      *
243      * @return boolean hook return
244      */
245     function onEndLoginGroupNav($action)
246     {
247         $this->showOpenIDLoginTab($action);
248
249         return true;
250     }
251
252     /**
253      * Show menu item for login
254      *
255      * @param Action $action Action being executed
256      *
257      * @return void
258      */
259     function showOpenIDLoginTab($action)
260     {
261         $action_name = $action->trimmed('action');
262
263         $action->menuItem(common_local_url('openidlogin'),
264                           // TRANS: OpenID plugin menu item on site logon page.
265                           _m('MENU', 'OpenID'),
266                           // TRANS: OpenID plugin tooltip for logon menu item.
267                           _m('Login or register with OpenID.'),
268                           $action_name === 'openidlogin');
269     }
270
271     /**
272      * Show menu item for password
273      *
274      * We hide it in openID-only mode
275      *
276      * @param Action $menu    Widget for menu
277      * @param void   &$unused Unused value
278      *
279      * @return void
280      */
281     function onStartAccountSettingsPasswordMenuItem($menu, &$unused) {
282         if (common_config('site', 'openidonly')) {
283             return false;
284         }
285         return true;
286     }
287
288     /**
289      * Menu item for OpenID settings
290      *
291      * @param Action $action Action being executed
292      *
293      * @return boolean hook return
294      */
295     function onEndAccountSettingsNav($action)
296     {
297         $action_name = $action->trimmed('action');
298
299         $action->menuItem(common_local_url('openidsettings'),
300                           // TRANS: OpenID plugin menu item on user settings page.
301                           _m('MENU', 'OpenID'),
302                           // TRANS: OpenID plugin tooltip for user settings menu item.
303                           _m('Add or remove OpenIDs.'),
304                           $action_name === 'openidsettings');
305
306         return true;
307     }
308
309     /**
310      * Autoloader
311      *
312      * Loads our classes if they're requested.
313      *
314      * @param string $cls Class requested
315      *
316      * @return boolean hook return
317      */
318     function onAutoload($cls)
319     {
320         switch ($cls)
321         {
322         case 'Auth_OpenID_TeamsExtension':
323         case 'Auth_OpenID_TeamsRequest':
324         case 'Auth_OpenID_TeamsResponse':
325             require_once dirname(__FILE__) . '/extlib/teams-extension.php';
326             return false;
327         }
328
329         return parent::onAutoload($cls);
330     }
331
332     /**
333      * Sensitive actions
334      *
335      * These actions should use https when SSL support is 'sometimes'
336      *
337      * @param Action  $action Action to form an URL for
338      * @param boolean &$ssl   Whether to mark it for SSL
339      *
340      * @return boolean hook return
341      */
342     function onSensitiveAction($action, &$ssl)
343     {
344         switch ($action)
345         {
346         case 'finishopenidlogin':
347         case 'finishaddopenid':
348             $ssl = true;
349             return false;
350         default:
351             return true;
352         }
353     }
354
355     /**
356      * Login actions
357      *
358      * These actions should be visible even when the site is marked private
359      *
360      * @param Action  $action Action to show
361      * @param boolean &$login Whether it's a login action
362      *
363      * @return boolean hook return
364      */
365     function onLoginAction($action, &$login)
366     {
367         switch ($action)
368         {
369         case 'openidlogin':
370         case 'finishopenidlogin':
371         case 'openidserver':
372             $login = true;
373             return false;
374         default:
375             return true;
376         }
377     }
378
379     /**
380      * We include a <meta> element linking to the webfinger resource page,
381      * for OpenID client-side authentication.
382      *
383      * @param Action $action Action being shown
384      *
385      * @return void
386      */
387     function onEndShowHeadElements(Action $action)
388     {
389         if ($action instanceof ShowstreamAction) {
390             $action->element('link', array('rel' => 'openid2.provider',
391                                            'href' => common_local_url('openidserver')));
392             $action->element('link', array('rel' => 'openid2.local_id',
393                                            'href' => $action->getTarget()->getUrl()));
394             $action->element('link', array('rel' => 'openid.server',
395                                            'href' => common_local_url('openidserver')));
396             $action->element('link', array('rel' => 'openid.delegate',
397                                            'href' => $action->getTarget()->getUrl()));
398         }
399
400         if ($action instanceof SitestreamAction) {
401             $action->element('meta', array('http-equiv' => 'X-XRDS-Location',
402                                          'content' => common_local_url('publicxrds')));
403         }
404         return true;
405     }
406
407     /**
408      * Redirect to OpenID login if they have an OpenID
409      *
410      * @param Action $action Action being executed
411      * @param User   $user   User doing the action
412      *
413      * @return boolean whether to continue
414      */
415     function onRedirectToLogin($action, $user)
416     {
417         if (common_config('site', 'openid_only') || (!empty($user) && User_openid::hasOpenID($user->id))) {
418             common_redirect(common_local_url('openidlogin'), 303);
419         }
420         return true;
421     }
422
423     /**
424      * Show some extra instructions for using OpenID
425      *
426      * @param Action $action Action being executed
427      *
428      * @return boolean hook value
429      */
430     function onEndShowPageNotice($action)
431     {
432         $name = $action->trimmed('action');
433
434         switch ($name)
435         {
436         case 'register':
437             if (common_logged_in()) {
438                 // TRANS: Page notice for logged in users to try and get them to add an OpenID account to their StatusNet account.
439                 // TRANS: This message contains Markdown links in the form (description)[link].
440                 $instr = _m('(Have an [OpenID](http://openid.net/)? ' .
441                   '[Add an OpenID to your account](%%action.openidsettings%%)!');
442             } else {
443                 // TRANS: Page notice for anonymous users to try and get them to register with an OpenID account.
444                 // TRANS: This message contains Markdown links in the form (description)[link].
445                 $instr = _m('(Have an [OpenID](http://openid.net/)? ' .
446                   'Try our [OpenID registration]'.
447                   '(%%action.openidlogin%%)!)');
448             }
449             break;
450         case 'login':
451             // TRANS: Page notice on the login page to try and get them to log on with an OpenID account.
452             // TRANS: This message contains Markdown links in the form (description)[link].
453             $instr = _m('(Have an [OpenID](http://openid.net/)? ' .
454               'Try our [OpenID login]'.
455               '(%%action.openidlogin%%)!)');
456             break;
457         default:
458             return true;
459         }
460
461         $output = common_markup_to_html($instr);
462         $action->raw($output);
463         return true;
464     }
465
466     /**
467      * Load our document if requested
468      *
469      * @param string &$title  Title to fetch
470      * @param string &$output HTML to output
471      *
472      * @return boolean hook value
473      */
474     function onStartLoadDoc(&$title, &$output)
475     {
476         if ($title == 'openid') {
477             $filename = INSTALLDIR.'/plugins/OpenID/doc-src/openid';
478
479             $c      = file_get_contents($filename);
480             $output = common_markup_to_html($c);
481             return false; // success!
482         }
483
484         return true;
485     }
486
487     /**
488      * Add our document to the global menu
489      *
490      * @param string $title   Title being fetched
491      * @param string &$output HTML being output
492      *
493      * @return boolean hook value
494      */
495     function onEndDocsMenu(&$items) {
496         $items[] = array('doc', 
497                          array('title' => 'openid'),
498                          _m('MENU', 'OpenID'),
499                          _('Logging in with OpenID'),
500                          'nav_doc_openid');
501         return true;
502     }
503
504     /**
505      * Data definitions
506      *
507      * Assure that our data objects are available in the DB
508      *
509      * @return boolean hook value
510      */
511     function onCheckSchema()
512     {
513         $schema = Schema::get();
514         $schema->ensureTable('user_openid', User_openid::schemaDef());
515         $schema->ensureTable('user_openid_trustroot', User_openid_trustroot::schemaDef());
516         $schema->ensureTable('user_openid_prefs', User_openid_prefs::schemaDef());
517
518         /* These are used by JanRain OpenID library */
519
520         $schema->ensureTable('oid_associations',
521                              array(
522                                  'fields' => array(
523                                      'server_url' => array('type' => 'blob', 'not null' => true),
524                                      'handle' => array('type' => 'varchar', 'length' => 191, 'not null' => true, 'default' => ''), // character set latin1,
525                                      'secret' => array('type' => 'blob'),
526                                      'issued' => array('type' => 'int'),
527                                      'lifetime' => array('type' => 'int'),
528                                      'assoc_type' => array('type' => 'varchar', 'length' => 64),
529                                  ),
530                                  'primary key' => array(array('server_url', 191), 'handle'),
531                              ));
532         $schema->ensureTable('oid_nonces',
533                              array(
534                                  'fields' => array(
535                                      'server_url' => array('type' => 'varchar', 'length' => 2047),
536                                      'timestamp' => array('type' => 'int'),
537                                      'salt' => array('type' => 'char', 'length' => 40),
538                                  ),
539                                  'unique keys' => array(
540                                      'oid_nonces_server_url_timestamp_salt_key' => array(array('server_url', 191), 'timestamp', 'salt'),
541                                  ),
542                              ));
543
544         return true;
545     }
546
547     /**
548      * Add our tables to be deleted when a user is deleted
549      *
550      * @param User  $user    User being deleted
551      * @param array &$tables Array of table names
552      *
553      * @return boolean hook value
554      */
555     function onUserDeleteRelated($user, &$tables)
556     {
557         $tables[] = 'User_openid';
558         $tables[] = 'User_openid_trustroot';
559         return true;
560     }
561
562     /**
563      * Add an OpenID tab to the admin panel
564      *
565      * @param Widget $nav Admin panel nav
566      *
567      * @return boolean hook value
568      */
569     function onEndAdminPanelNav($nav)
570     {
571         if (AdminPanelAction::canAdmin('openid')) {
572
573             $action_name = $nav->action->trimmed('action');
574
575             $nav->out->menuItem(
576                 common_local_url('openidadminpanel'),
577                 // TRANS: OpenID configuration menu item.
578                 _m('MENU','OpenID'),
579                 // TRANS: Tooltip for OpenID configuration menu item.
580                 _m('OpenID configuration.'),
581                 $action_name == 'openidadminpanel',
582                 'nav_openid_admin_panel'
583             );
584         }
585
586         return true;
587     }
588
589     /**
590      * Add OpenID information to the Account Management Control Document
591      * Event supplied by the Account Manager plugin
592      *
593      * @param array &$amcd Array that expresses the AMCD
594      *
595      * @return boolean hook value
596      */
597
598     function onEndAccountManagementControlDocument(&$amcd)
599     {
600         $amcd['auth-methods']['openid'] = array(
601             'connect' => array(
602                 'method' => 'POST',
603                 'path' => common_local_url('openidlogin'),
604                 'params' => array(
605                     'identity' => 'openid_url'
606                 )
607             )
608         );
609     }
610
611     /**
612      * Add our version information to output
613      *
614      * @param array &$versions Array of version-data arrays
615      *
616      * @return boolean hook value
617      */
618     function onPluginVersion(array &$versions)
619     {
620         $versions[] = array('name' => 'OpenID',
621                             'version' => GNUSOCIAL_VERSION,
622                             'author' => 'Evan Prodromou, Craig Andrews',
623                             'homepage' => 'http://status.net/wiki/Plugin:OpenID',
624                             'rawdescription' =>
625                             // TRANS: Plugin description.
626                             _m('Use <a href="http://openid.net/">OpenID</a> to login to the site.'));
627         return true;
628     }
629
630     function onStartOAuthLoginForm($action, &$button)
631     {
632         if (common_config('site', 'openidonly')) {
633             // Cancel the regular password login form, we won't need it.
634             $this->showOAuthLoginForm($action);
635             // TRANS: button label for OAuth authorization page when needing OpenID authentication first.
636             $button = _m('BUTTON', 'Continue');
637             return false;
638         } else {
639             // Leave the regular password login form in place.
640             // We'll add an OpenID link at bottom...?
641             return true;
642         }
643     }
644
645     /**
646      * @fixme merge with common code for main OpenID login form
647      * @param HTMLOutputter $action
648      */
649     protected function showOAuthLoginForm($action)
650     {
651         $action->elementStart('fieldset');
652         // TRANS: OpenID plugin logon form legend.
653         $action->element('legend', null, _m('LEGEND','OpenID login'));
654
655         $action->elementStart('ul', 'form_data');
656         $action->elementStart('li');
657         $provider = common_config('openid', 'trusted_provider');
658         $appendUsername = common_config('openid', 'append_username');
659         if ($provider) {
660             // TRANS: Field label.
661             $action->element('label', array(), _m('OpenID provider'));
662             $action->element('span', array(), $provider);
663             if ($appendUsername) {
664                 $action->element('input', array('id' => 'openid_username',
665                                               'name' => 'openid_username',
666                                               'style' => 'float: none'));
667             }
668             $action->element('p', 'form_guide',
669                            // TRANS: Form guide.
670                            ($appendUsername ? _m('Enter your username.') . ' ' : '') .
671                            // TRANS: Form guide.
672                            _m('You will be sent to the provider\'s site for authentication.'));
673             $action->hidden('openid_url', $provider);
674         } else {
675             // TRANS: OpenID plugin logon form field label.
676             $action->input('openid_url', _m('OpenID URL'),
677                          '',
678                         // TRANS: OpenID plugin logon form field instructions.
679                          _m('Your OpenID URL.'));
680         }
681         $action->elementEnd('li');
682         $action->elementEnd('ul');
683
684         $action->elementEnd('fieldset');
685     }
686
687     /**
688      * Handle a POST user credential check in apioauthauthorization.
689      * If given an OpenID URL, we'll pass us over to the regular things
690      * and then redirect back here on completion.
691      *
692      * @fixme merge with common code for main OpenID login form
693      * @param HTMLOutputter $action
694      */
695     function onStartOAuthLoginCheck($action, &$user)
696     {
697         $provider = common_config('openid', 'trusted_provider');
698         if ($provider) {
699             $openid_url = $provider;
700             if (common_config('openid', 'append_username')) {
701                 $openid_url .= $action->trimmed('openid_username');
702             }
703         } else {
704             $openid_url = $action->trimmed('openid_url');
705         }
706
707         if ($openid_url) {
708             require_once dirname(__FILE__) . '/openid.php';
709             oid_assert_allowed($openid_url);
710
711             $returnto = common_local_url(
712                 'ApiOAuthAuthorize',
713                 array(),
714                 array(
715                     'oauth_token' => $action->arg('oauth_token'),
716                     'mode'        => $action->arg('mode')
717                 )
718             );
719             common_set_returnto($returnto);
720
721             // This will redirect if functional...
722             $result = oid_authenticate($openid_url,
723                                        'finishopenidlogin');
724             if (is_string($result)) { # error message
725                 throw new ServerException($result);
726             } else {
727                 exit(0);
728             }
729         }
730
731         return true;
732     }
733
734     /**
735      * Add link in user's XRD file to allow OpenID login.
736      *
737      * This link in the XRD should let users log in with their
738      * Webfinger identity to services that support it. See
739      * http://webfinger.org/login for an example.
740      *
741      * @param XML_XRD   $xrd    Currently-displaying resource descriptor
742      * @param Profile   $target The profile that it's for
743      *
744      * @return boolean hook value (always true)
745      */
746
747     function onEndWebFingerProfileLinks(XML_XRD $xrd, Profile $target)
748     {
749         $xrd->links[] = new XML_XRD_Element_Link(
750                             'http://specs.openid.net/auth/2.0/provider',
751                             $target->profileurl);
752
753         return true;
754     }
755
756     /**
757      * Add links in the user's profile block to their OpenID URLs.
758      *
759      * @param Profile $profile The profile being shown
760      * @param Array   &$links  Writeable array of arrays (href, text, image).
761      *
762      * @return boolean hook value (true)
763      */
764     
765     function onOtherAccountProfiles($profile, &$links)
766     {
767         $prefs = User_openid_prefs::getKV('user_id', $profile->id);
768
769         if (empty($prefs) || !$prefs->hide_profile_link) {
770
771             $oid = new User_openid();
772
773             $oid->user_id = $profile->id;
774
775             if ($oid->find()) {
776                 while ($oid->fetch()) {
777                     $links[] = array('href' => $oid->display,
778                                      'text' => _('OpenID'),
779                                      'image' => $this->path("icons/openid-16x16.gif"));
780                 }
781             }
782         }
783
784         return true;
785     }
786 }