It is important to understand the difference between web applications and web services. The web application supports markup, JavaScript, CSS, and image files and often uses cookie-based authentication (but can use any other implicit authentication mechanism). Any request that the browser makes is automatically authenticated.
Web services, on the other hand, often use bearer token authentication. When a client communicates with the API in a browser, a thick client, or on a mobile device, it sends a token in the Authorization header of the HTTP request. The header must be explicitly bound to the request in JavaScript or native code that executes the HTTP request.
One-page applications (SPAs) do not have a web application, and markup, JavaScript, CSS, and images are served in a browser without authentication. Only requests to web services are authenticated, usually using a JWT token.
In your case, if you want only authorized users to upload images and other files, you should consider creating a web application. Use a security protocol such as OpenID Connect to authenticate your users. Select an authorization server that supports both OpenID Connect for your web application and OAuth2 for your web service.
MvdD Dec 05 '15 at 23:54 on 2015-12-05 23:54
source share