Initial Release - 2018-03-29Version .1Implementation of Open ID authentication for osTicket.Tested with personal and work accountsTested on LAMP stack with PHP 7.0.28, osTicket v1.10.1Tested on LEMP stack with PHP 7.2.3-1, osTicket v1.10.1osTicket on LEMP requires additional rewrite rules. This recipe is a good starting point. You'll want to change the following:location ~ ^/api/(?|tasks).*$ { try_files $uri $uri/ /api/http.php?$query_string;}to:location ~ ^/api/(?|tasks|auth).*$ { try_files $uri $uri/ /api/http.php?$query_string;}osTicket has other issues with PHP 7.2Configuration options for auth URL, endpoint, scope, client ID (application ID), and secretAdditional options for domain whitelists on staff and client logins, enabling the plugin separately on staff and client logins, plus hiding the local login sections.Hiding the local logins allows for public registration to be enabled so that accounts don't have to be created in advance Install - Upload the phar file to your osTicket/include/plugins directory.blank

    Basic SetupNavigate to https://apps.dev.microsoft.com and create a new applicationDon't use the guided setupGenerate a new password. This is the password for the "Client Secret" field.Add a platform and choose "Web"The Redirect URL should point to your osTicket URL. E.g. https://helpdesk.example.com/api/auth/extIt is strongly encouraged to use SSL. This has only been tested with SSL. Optional: Upload a logoSet the Home page URL. E.g. https://helpdesk.example.comCopy the Application Id and paste it into the "Client ID" field in the plugin. Use "https://login.microsoft.com/common" for the Authority URLUse "/oauth2/v2.0/authorize" for the Authorization EndpointUse "openid profile" for the scopes

    2 months later

    v .2 UpdateI added support for osTicket Awesome theme and corrected an issue with detecting the staff/client login page. I have only tested this on a LEMP stack with php 7.0.30 with and without osTicket Awesome installed. There's an issue in the instruction set above where I put the authority URL as login.microsoft.com it should be login.microsoftonline.com as is noted in the screenshot.

    2 months later

    Hello,  thank you for your plug-in.I installed the plug-in in OSTicket. (1.10.4)I followed your instructions for the setting.When I click on the button "Sign in Microsoft" in the page login.php, then I arrive on the page "https://login.microsoft.com/common/oauth2/v2.0/authorize?client_id=3b5dd93. .... ".  When I enter my email address name@company.ext,  I have a message that tells me he can not find my account."There was a problem finding your account, click Next to try again."Should we allow something in MS Azure?Thank you

      Hello, I have advanced a little,

      In the plug-in, in the "Authority URL" part, I replaced "" https://login.microsoft.com/common/ "with" https://login.microsoftonline.com/common "now my account office 365 Edu is recognized, however after having validated my password, I come across this page: "https: //mydomain.ext/osticket/api/auth/ext"

      "File not found"

      Do you have any idea what this could end?

      Thank you

      2 months later

      Hi cbasolutions,
      I went thru all the process you have shown but still stucked on "reply URL not matched error".
      I'm using osTicket Version v1.10.4 (035fd0a) on Apache with MySQL 5.7.23 & PHP 5.6.38. Here are the screenshots, could you please help me set up this thing.
      Many thanks


      7 months later

      Hi,
      Thank you for this helpful plugin, but i do have a question please.

      After following all of the instructions, the scenario is like this:
      - I sign in into my Microsoft account, success, then redirected to http://mydomain.com/api/auth/ext.
      - Now a blank page?! why doesn't it redirect to the main homepage or tickets page for example?
      - I need to get back to the homepage of 'OsTicket' myself and then click Sign in then Voila!, i am signed in!

      I have tried for a couple of days now, searching for a solution to no avail, I even downloaded your source code to try to understand what is going on and how to fix this, but also didn't get to any result.

      So if you could give me any hint bout why this is happening or what can i do to fix this i would be really grateful ?

      Thank you,

        a month later

        Hello,

        Also I am not clear about the correct setup. Does anyone can share its successful guide.

        Thanks!

        Hello,

        I also got same problem of error code AADSTS50011 as above.

        Did anyone can advise how to solve it?

        Thanks!

        13 days later

        M-elnady did you change your nginx config to reflect this:

        location ~ /api/(tickets|tasks)(.*)$ {

        to

        location ~ /api/(tickets|tasks|auth)(.*)$ {

        This should then pick up the /auth part in the URL and action it correctly.

          This plugin works well but did take a couple of attempts to get it working correctly. There does seem to be one item not working - logging out. Choosing logout does, indeed, log you out of OSTicket but does not log you out of your microsoft account. Not sure if this intended functionality.

          I also had to add the domain name into the allowed email domains for staff and had to create an agent login dropping the domain name e.g Microsoft login is bill@smith.com. You need to add smith.com to allowed email domains for staff and create an account with a username (no password needed) of bill.

          If you are providing client access then the same rules apply.

          babgond I had the same issue. I needed to do a couple of things.

          1. Add your domain name to "allowed email domains for staff"
          2. Make sure your username reflects the bit before the @ in your domain name eg. bill@smith.com requires you to have a username of bill

          Once I had done this I could use the plugin successfully

          4 days later

          Has anyone managed to get this to work with Office 365 & Apache? I can get it to redirect me to Microsoft to login, but then once I authenticate, I get trapped in a loop, it's as though it doesn't send me back to osTicket.

          System Info below.

          I also had to change the Endpoint to this as it wasn't happy that I was trying to use a public one with my O365 account.

            10 days later
            a month later

            Hello machihkfyg and mitchellk

            I had the same issue.

            I share my solution 🙂

            The main plugging configuration:

            Authority URL: * https://login.microsoftonline.com/common (multi tenant)
            or
            Authority URL: * https://login.microsoftonline.com/{Directory (tenant) ID} (Single tenant)

            Authorization Endpoint: /oauth2/v2.0/authorize

            And the bug with the url blank "api/auth/ext" with apache. The file .htaccess is fine, don't modify the file, the problem is the site location.

            I modified the code inside the auth-openid-MS.phar.

            The line with:
            if ($_SERVER['SCRIPT_NAME'] === '/login.php' || $_SERVER['SCRIPT_NAME'] === '/open.php')
            to
            if (strpos($_SERVER['SCRIPT_NAME'],'/login.php') !== false || strpos($_SERVER['SCRIPT_NAME'],'/open.php') !== false)

            Because, mi site work in domain.com/osTicket/, and the original condition don't match, and one Cookie param in never created.

            And

            The line with:
            if ($_COOKIE['LOGIN_TYPE'] === 'CLIENT') header('Location: /login.php');
            To

            $url_home = rtrim($ost->getConfig()->getURL(), '/');
            $sections = parse_url($url_home);
            $sub_dir = isset($sections["path"])?$sections["path"]:"";
              
            if ($_COOKIE['LOGIN_TYPE'] === 'CLIENT') header('Location: '.$sub_dir.'/login.php');

            Because my site work inside a sub-directory, and i need to get a good location.

            I hope this could be useful for your!

            My english is a work in progress 🙂

            Best wishes

              3 months later

              Hello Guys,
              I am encountering the same error.,..is there any clue how to fix it??

              Actually as redirect URI I inserted the URL of the website in azurewebsites (the Application is developed as App Service)...

              Nobody can collaborate? it seems totally usefulness this tool if there is no possibility to synchronize with Active Directory 🙁

              Are you adding "api/auth/ext" at the end of your URL?

              For example: https://yourdomain.com/api/auth/ext

              I use this url pattern at least in two project, running on Apache Server.

              The tool set this part of the url automatically when call the Active Directory Authentication. So, this URL must match with the info inserted in the section Redirect URI's

              You can use the dev console from Chrome, Firefox to find the URL send to Azure Active Directory.

              [UPDATE]

              I added some image for references. The field: redirect_uri is the url that you must insert in the list of Redirect's Uri's

              SO I setup my website in Azure App Registration as:

              https://mywebsite.azurewebsites.net/api/auth/ext

              but still I get this error: how did you setup the App Registrationtion redirect??

              AADSTS50011: The reply url specified in the request does not match the reply urls configured for the application: 'xxx...'