Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

bacondrinker's avatar

OAuth2 Implicit Grant Type Without Authorisation Controller

Hi Guys,

At the company I work for we are currently working on bringing a web application we created for a client into the modern world, with the eventual goal of turning it into a commercial product. The project is currently an old style PHP program which is basically an assortment of PHP files, pseudo models/services and ajax posts to PHP files.

We are looking to bring this project into the modern day and so have begun working on separating the front and backend into their own components, with the eventuality of the backend turning into a kind of MVC application which is a REST api (I know, it's buzzword galore).

The problem we are facing is the current authentication system will not be secure enough to work with this new style of program, and so it needs an overhaul. We were thinking of going for OAuth2 with the Implicit Grant Type; however this is presenting us with a problem, we don't want to use an Authorisation controller as there will only be one application accessing the API, ours.

My question to the community is has anybody else designed or worked on a similar system, or problem and how have you solved it? Is there a way to use Implicit Grant Flow without using the Authorisation controller, and if not what is a better way to deal with authentication in this style of application. We do not want to store any username / password type information on the client side for security purposes.

Thanks ever so much for your time. Carwyn Nelson (Bacondrinker)

TLDR: Basically, we are looking for a way to authenticate a client (javascript web interface) with a REST api securely, where the client is not trusted to store the user data locally. Is OAuth2 Implicit Grant Type a good implementation, and can we use it without the Authorisation controller.

0 likes
9 replies
mosaiqo's avatar

Here it's is very basic explanation of OAuth2

http://aaronparecki.com/articles/2012/07/29/1/oauth2-simplified

I think you can go with the password grant type which is a simple POST request with username and password to create a session token. This is mostly used by very trusted application, it means the Resource Server trusts the Client.

Oauth 2 comes with Authentication server and Resource server you need both.

Here is a very good package and easy to install, I just tested around 20 min with it but it is very powerful

https://github.com/lucadegasperi/oauth2-server-laravel

bacondrinker's avatar

Hi @boudydegeer Thanks for the answer and sorry for the late reply. I have been very busy on a project (only a week to build an MVP from the ground up, without Laravel (sadface) )

The consumers of this API are going to be SPA Javascript apps (Emberjs, probably going to phonegap them). My team and I were thinking of using Implicit grant type because these are Javscript clients and are therefore not usually said to be trusted clients?

The application we are developing is unfortunately a legacy page-based application, so unfortunately no Laravel goodness for the moment.

I am currently working on moving it over to the MVC design pattern, by pretty much building a framework very much like Silex around it. This should allow us to eventually move the app over to Laravel.

Hopefully that is a bit more descriptive?

This boils down to: Are Javascript clients that we create trusted? If we send everything over HTTPS then should the username / password method for an API token be an okay way of doing it?

Thanks very much for your reply

mosaiqo's avatar
mosaiqo
Best Answer
Level 9

Hy @bacondrinker, I think there are no more trusted clients , even JS ones, that yours.

So if you are going to send everything over HTTPS than is ok to send user / password a correct way to do that.

I go on the password grant type is this kind of OAuth way to do this.

bacondrinker's avatar

I just got an email from Jeffrey, and I thought it was freakin' awesome:

Yo! Sorry to fill up your inbox. Imma let you finish, but @boudydegeer just left one of the best replies of all time on the Laracasts forum!

I think you should be feeling awesome right now that @JeffreyWay thinks that this post is so awesome :P

1 like
mosaiqo's avatar

Hey, I got the same mail, I think it's just an automatic email. But thanks :D

bacondrinker's avatar

Oh yeah that would make total sense. I feel kind of like an idiot now :P

1 like
teejten's avatar

haha o'well I think it's an awesome post anyway. @boudydegeer thanks for the sweet link on oauth2

1 like

Please or to participate in this conversation.