I have an application on AngularJS. It is necessary to implement in it reading, writing and changing some data to / from the database. For this, as far as I understand, you need to create a REST server. My application will use server methods and thus realizes the task.
The application will be hosted on a cheap hosting, where only PHP is available from PL. I chose Yii2 as a framework because worked with him before. It turned out to sketch a minimal implementation of the REST server, but it came to authentication and problems started here. There are three authentication methods in Yii2:
- HTTP Basic Auth: the access token is sent as the username. This approach should be used only when the access token can be safely stored on the subscriber side of the API. For example, if the API is used by a program running on a server.
- Request parameter: The access token is sent as a request parameter in the API URL, i.e. approximately like this: https://example.com/users?access-token=xxxxxxxx . Since most Web servers store request parameters in their logs, this approach should be used only when working with JSONP requests that cannot send access tokens in HTTP headers.
- OAuth 2: The access token is issued to the API subscriber by the authorization server and sent to the API server via HTTP Bearer Tokens, in accordance with the OAuth2 protocol.
I still do not understand which way to choose me? The API will be used only by my JS application, which will be hosted on the same hosting as the REST server.