JTracker/jissues — pull request #78 by elkuku (2013-01-25 01:16:37+00:00)
Title: Add Github authentication

This will add the possibility to authenticate a user with his/her GitHub account.

More than a possibility, it's a requirement - to be discussed ?

Currently supported:

* Login.
* Posting comments.

#### Testing login
In order to test the login feature in your local environment you will need to create an application `key` and `secret` for your (local) JTrackerApplication instance:

* Sail to your account on GitHub ⇒ "Edit your Profile".
* Go to "Applications" - "Developer applications" and "Register new application"
* Fill in some name and some main url. Those will be presented to the user when authorizing the application.
* Fill in a domain for callback URL. This must match the domain the application is running.
**Hint** This may be `http://localhost` or a virtual host.
* Hit "Save" and copy the client_id and client_secret.
* Checkout the branch at https://github.com/JTracker/jissues/tree/github-auth
* Edit configuration.php and fill in the client_id and client_secret.
* Install as usual.
* Sail to your localhosts JTracker installation and click on "Login with GitHub"
* On the first attempt you will be redirected to GitHub where you have to confirm the access by your application.
* After a successful login, go to "Users" ⇒ "View Profile".
You may also try "Edit Profile", but saving is currently disabled.

#### Testing comments

Commenting is actually enabled only for the a project - to avoid spam...
This project is a "real" (testing) project located at: https://github.com/jtester/tests/
**Note**: GitHub allows the creation of "unconfirmed" accounts, so you may want to create a dummy user to avoid spamming your followers ;)

So if you have installed with the sql file from the branch you should see three projects.

* Run `retrieveissues.php` and `retrievecomments.php` for project No. 3.
* Log out.
* Select the project JTestS.
* Choose an issue.
* Click "Login with GitHub to add a comment" at the bottom of the comments section.
* A comment field should appear.
* Post a comment.
* Verify that the comment appears both on GitHub and in the application.

Note that this step will required the PHP exec() function to be enabled on your server, since I was lazy ;) - but this may change.

I admit that the code used for obtaining the oAuth token is far from being beautiful.
But since those are only about three lines of working code, we may wait to see what the platform will offer us in the future regarding oAuth authentication.