osTicket / osTicket-plugins

Core plugins for osTicket (v1.8+)
GNU General Public License v2.0
149 stars 162 forks source link

How to enable Google sign in (auth-oauth) #107

Open maheshkalal opened 8 years ago

maheshkalal commented 8 years ago

I want to enable Google sign in on customer portal to allow ticket creation.

I have tried to create phar file using "php make.php hydrate auth-oauth" and "php make.php hydrate" command but I am getting below exception. can you please help me with this or is there any detailed documentation for creating this phar file. create phar file using "php make.php hydrate auth-oauth" and "php make.php hydrate" command but I am getting below exception. can you please help me with this or is there any detailed documentation for creating this phar file.

Error: D:\supportdesk\include\plugins>php make.php hydrate auth-oauth Hydrating :: lib/jasig/phpcas/source => auth-cas/lib/jasig/phpcas

Fatal error: Uncaught exception 'UnexpectedValueException' with message 'Recursi veDirectoryIterator::__construct(D:\supportdesk\include\plugins/lib/jasig/phpcas /source,D:\supportdesk\include\plugins/lib/jasig/phpcas/source): The system cann ot find the path specified. (code: 3)' in D:\supportdesk\include\plugins\make.ph p:481 Stack trace:

0 D:\supportdesk\include\plugins\make.php(481): RecursiveDirectoryIterator->__c

onstruct('D:\supportdesk...', 4096)

1 D:\supportdesk\include\plugins\make.php(340): PluginBuilder->_hydrate(Array)

2 D:\supportdesk\include\plugins\make.php(240): PluginBuilder->run(Array, Array

)

3 D:\supportdesk\include\plugins\make.php(704): Module->_run('make.php')

4 {main}

thrown in D:\supportdesk\include\plugins\make.php on line 481

Any help on this would be highly appreciated.

sasiryu commented 7 years ago

I have same issue can anyone help please.

sasiryu commented 7 years ago

Hi i followed this [ http://www.webpreprod.com/issue/utiliser-protocole-oauth-20-osticket-se-connecter-compte-google-facebook ] and added the files to /lib/... folder manually and it worked.

But still after successful google authentication i get a blank page http://mysite.com/api/auth/ext?state=ecd83dfb85a228a34178e7&code=4/WcNrjffotr5dweggVyyl6VtttydRoybEJTVFE3TE#

can any one help.

ntozier commented 7 years ago

@sasiryu if you are getting a white page, then you have a PHP error being logged. Please consult your PHP error logs and provide the error. Also please provide information about your server environment.

FossPrime commented 7 years ago

It looks like the installation script has a directory separator problem on windows.

Should be an easy fix, a quick work around would be to build it in a POSIX compliant machine (Linux, BSD or MacOS).

Related/duplicate issues: #95 #84 #79 95 has a partial? fix.

sasiryu commented 7 years ago

Hi @ntozier Sorry for the delay there is no error log i use Windows and XAMPP osticket

I follow the exact instructions as informed in forums and plugin page but it always redirects to blank page http://mysite.com/login.php?do=ext&bk=google.client

I followed 1> Clone this repo or download the zip file and place the contents into your include/plugins folder 2> php make.php hydrate 3> Gets the below error

Fatal error: Uncaught exception 'UnexpectedValueException' with message 'RecursiveDirectoryIterator::__construct(C:\xampp\htdocs\support\include\plugins/lib/jasig/phpcas/source,C:\xampp\htdocs\support\include\plugins/lib/jasig/phpcas/source): The system cannot find the path specified. (code: 3)' in C:\xampp\htdocs\support\include\plugins\make.php:481 Stack trace:

0 C:\xampp\htdocs\support\include\plugins\make.php(481): RecursiveDirectoryIterator->__construct('C:\xampp\htdocs...', 4096)

1 C:\xampp\htdocs\support\include\plugins\make.php(340): PluginBuilder->_hydrate(Array)

2 C:\xampp\htdocs\support\include\plugins\make.php(240): PluginBuilder->run(Array, Array)

3 C:\xampp\htdocs\support\include\plugins\make.php(704): Module->_run('make.php')

4 {main}

thrown in C:\xampp\htdocs\support\include\plugins\make.php on line 481

I see when cloning the /lib/ file is empty is this ok ?

sasiryu commented 7 years ago

@rayfoss Thanks for the info i tried Change: $php = defined('PHP_BINARY') ? PHP_BINARY : 'php'; To: $php = defined("'PHP_BINARY'") ? PHP_BINARY : 'php'; as per #95 same issue

84 did not help #79 no info i get same issue

sasiryu commented 7 years ago

If i get the Authentication :: OAuth2 (Only Google+ Currently) Release Candidate, Requires osTicket 1.9, Released April 29th, 2014 plugin from http://osticket.com/download-edge

I am able to contact the google app to authenticate and once authenticated i get the error 500 kindly see below.

1

2

Thanks a lot

ntozier commented 7 years ago

@sasiryu just because you use use Windows and XAMPP doesnt mean that there would be no error log. If you are getting a white page, then you have a PHP error being logged. Please consult your PHP error logs and provide the error. Also this plugin was never technically released and hasn't been updated in about 2 years... so I imagine that it isn't compatible with any version newer then 2 years ago.

sasiryu commented 7 years ago

Hi @ntozier thanks, Sure i have tested the same under Linux/Ubuntu and the error that i get is as below, after all authentication happens the final page i get the error (screenshot attached)

`[Tue Dec 27 05:40:55.634539 2016] [:error] [pid 12495] [client 000.00.00.00:57713] PHP Warning: session_destroy(): Session callback expects true/false return value in /var/www/html/osticket/scp/logout.php on line 30, referer: http://site.com/osticket/scp/plugins.php [Tue Dec 27 05:40:55.634561 2016] [:error] [pid 12495] [client 000.00.00.00:57713] PHP Warning: session_destroy(): Session object destruction failed in /var/www/html/osticket/scp/logout.php on line 30, referer: http://site.com/osticket/scp/plugins.php

Environment: osTicket Version - v1.10 — Up to date Web Server Software - Apache/2.4.18 (Ubuntu) MySQL Version - 5.7.16 PHP Version - 7.0.8-0ubuntu0.16.04.3

2016-12-27_113006

FossPrime commented 7 years ago

You may need to allow overrides and enable mod_rewrite http://osticket.com/forum/discussion/comment/75721/#Comment_75721

sasiryu commented 7 years ago

Hi @rayfoss thanks for the details will check on this before that just to double check on what need to be changed i need to do the following right ?

run the following command in Linux

sudo a2enmod rewrite sudo systemctrl apache2 restart

then should i create a .htaccess under /osticket/ folder or edit default Apache 000-default.conf file with the following ?

RewriteEngine on
<Directory /path/to/osticket/>
AllowOverride All
</Directory>

or i have to edit the .htaccess file under osticket/api/.htaccess with the above RewriteEngine ?

Thanks a lot for the detail. Since there are another 3 sites running i don't want to mess up :(

sasiryu commented 7 years ago

Hi i have added the redirect rule inside the .htaccess file in /api/ folder now the file looks as below

RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} (.*/api) RewriteRule ^(.*)$ http://localhost/osticket/api/http.php/$1 [L]

Now when i try to login i get the blank white page. When i see the php error log i have the following errors in it.

[02-Jan-2017 07:15:41] PHP Warning: include(phar://C:/xampp/htdocs/osticket/include/plugins/auth-cas.phar/plugin.php) [function.include]: failed to open stream: phar error: invalid url or non-existent phar "phar://C:/xampp/htdocs/osticket/include/plugins/auth-cas.phar/plugin.php" in C:\xampp\htdocs\osticket\include\class.plugin.php on line 280

[02-Jan-2017 07:15:41] PHP Warning: include() [function.include]: Failed opening 'phar://C:/xampp/htdocs/osticket/include/plugins/auth-cas.phar/plugin.php' for inclusion (include_path='./;C:/xampp/htdocs/osticket/include/;C:/xampp/htdocs/osticket/include/pear/') in C:\xampp\htdocs\osticket\include\class.plugin.php on line 280

[02-Jan-2017 07:15:41] PHP Warning: array_merge() [function.array-merge]: Argument #2 is not an array in C:\xampp\htdocs\osticket\include\class.plugin.php on line 280

[02-Jan-2017 07:15:41] PHP Warning: Invalid CRT parameters detected in C:\xampp\htdocs\osticket\include\class.translation.php on line 832`

Note: Apache log has no error now. can any one help this get fixed please or point to the issue.

Thanks,

sasiryu commented 7 years ago

Hi any help on this ? Any one succeed in making SSO for google app work ?

Technowise commented 7 years ago

I was able to successfully install the OAuth plugin for Google login by following this article in french.

I have documented the steps for installing this in my blog post here: http://www.technowise.in/2017/01/osticket-googlegmail-login-integration.html

Please note: You may not be able to get it it to work on NGinx as the callback URL from oAuth depends on URL rewrite specified in .htaccess in api folder. So I would recommend you use Apache server if you intend to install and use this plugin.

hitalz commented 5 years ago

Hi any help on this ? Any one succeed in making SSO for google app work ?

Hey @sasiryu, don't know if you still need help with this but I got it to work by doing the following:

My environment osTicket Version - v1.10.4 - Up to date Web Server Software - Apache/2.4.29 (Ubuntu) MySQL Version - 5.7.24 PHP Version - 7.2.10-0ubuntu0.18.04.1

1> sudo a2enmod rewrite sudo service apache2 restart

2> In /etc/apache2/apache.conf

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>

and remove # before AccessFileName .htaccess

3> Just to be sure, also in /etc/apache2/sites-available/000-default.conf I added

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>

inside <VirtualHost *:80>

4> Create .htaccess inside api/ with the following:

<IfModule mod_rewrite.c>

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.*/api)

RewriteRule ^(.*)$ %1/http.php/$1 [L]

</IfModule>

5> Another restart just in case sudo service apache2 restart

Hopefully you get it to work in your environment.

visiniaga commented 4 years ago

testing with: osTicket Version | v1.14.2 (cba6035) —  Up to date Web Server Software | Apache MySQL Version | 10.4.13 PHP Version | 7.2.31 Centos 7.x with updates

experiencing problem just now, some user report that cannot use sign in with google

checking that redirection from apache showing different result in the url login with a selection list of google account more than 1 GET /api/http.php/auth/ext?state=fca983d3adf31684a

only 1 google account signed, showing in apache logs GET /api/auth/ext?state=fca983d3adf31684a while with selection list of google account having correct url http.php GET /api/http.php/auth/ext?state=fca983d3adf31684a

so fix is replacing google.php line 19: . ROOT_PATH . 'api/http.php/auth/ext') to . ROOT_PATH . 'api/auth/ext')

full function triggerAuth() will be: function triggerAuth() { $self = $this; return Auth2::legs(3) ->set('id', $this->config->get('g-client-id')) ->set('secret', $this->config->get('g-client-secret')) ->set('redirect', 'https://' . $_SERVER['HTTP_HOST'] . ROOT_PATH . 'api/http.php/auth/ext') ->set('scope', 'profile email')

        ->authorize('https://accounts.google.com/o/oauth2/auth')
        ->access('https://accounts.google.com/o/oauth2/token')

        ->finally(function($data) use ($self) {
            $self->access_token = $data['access_token'];
        });
}

}

hope this help

note: changing this url also require change in console developer in google: https://console.developers.google.com/apis/credentials

Authorized redirect URIs For use with requests from a web server URIs https://domain.com/api/http.php/auth/ext

GamingSanctum commented 2 years ago

Is this still working for anyone running the current version of osTicket (1.15)? I was able to install this plugin but the "Login with Google" link only shows up for admins at the /scp/ link. The Google sign-in option is not showing for end users on their login page.

visiniaga commented 2 years ago

in osticket 1.14 it should enable in plugin setting

image

GamingSanctum commented 2 years ago

in osticket 1.14 it should enable in plugin setting

image

Yes, I have that option set in the settings. However, the login button is not available on the client's end. osticket-clientlogin

But it IS showing and working for the agent login: osticket-agentlogin .