Exploring authentication patterns
The power of SPAs becomes apparent when there is also a server behind them providing additional services. One such service is authentication. In most applications, there will be the need to identify users and provide additional services based on their rights, status, privacy, group, or any other category pertaining to the context of the application. A clear example of this is webmail applications, such as Outlook or Gmail.
Current web standards provide us with several options to perform asynchronous communications with a server. These are often called AJAX (AJAX stands for Asynchronous JavaScript and XML). In the most basic form, we could use the XMLHttpRequest
object for these network communications, but the new specifications provide us with a direct function, fetch()
, which is more convenient and standard between browsers. While these methods are perfectly valid, for other uses than simple needs, it is better to use a library that provides more...