- Go Programming Blueprints(Second Edition)
- Mat Ryer
- 395字
- 2021-07-08 10:40:01
Chapter 2. Adding User Accounts
The chat application we built in the previous chapter focused on high performance transmission of messages from the clients to the server and back again. However, the way things stand, our users have no way of knowing who they would be talking to. One solution to this problem is building some kind of sign-up and login functionality and letting our users create accounts and authenticate themselves before they can open the chat page.
Whenever we are about to build something from scratch, we must ask ourselves how others have solved this problem before (it is extremely rare to encounter genuinely original problems) and whether any open solutions or standards already exist that we can make use of. Authorization and authentication can hardly be considered new problems, especially in the world of the Web, with many different protocols out there to choose from. So how do we decide the best option to pursue? As always, we must look at this question from the point of view of the user.
A lot of websites these days allow you to sign in using your accounts that exist elsewhere on a variety of social media or community websites. This saves users the tedious job of entering all of their account information over and over again as they decide to try out different products and services. It also has a positive effect on the conversion rates for new sites.
In this chapter, we will enhance our chat codebase to add authorization, which will allow our users to sign in using Google, Facebook, or GitHub, and you'll see how easy it is to add other sign-in portals too. In order to join the chat, users must first sign in. Following this, we will use the authorized data to augment our user experience so everyone knows who is in the room and who said what.
In this chapter, you will learn to:
- Use the decorator pattern to wrap
http.Handler
types in order to add additional functionality to handlers - Serve HTTP endpoints with dynamic paths
- Use the
gomniauth
open source project to access authentication services - Get and set cookies using the
http
package - Encode objects as Base64 and back to normal again
- Send and receive JSON data over a web socket
- Give different types of data to templates
- Work with the channels of your own types
- 軟件安全技術(shù)
- JBoss Weld CDI for Java Platform
- Learn Blockchain Programming with JavaScript
- Java Web開發(fā)學(xué)習(xí)手冊
- Mastering AWS Lambda
- 測試驅(qū)動開發(fā):入門、實戰(zhàn)與進階
- Power Up Your PowToon Studio Project
- Rust編程:入門、實戰(zhàn)與進階
- C# Programming Cookbook
- Vue.js 3.x從入門到精通(視頻教學(xué)版)
- Java FX應(yīng)用開發(fā)教程
- The Computer Vision Workshop
- UML 基礎(chǔ)與 Rose 建模案例(第3版)
- Extending Puppet(Second Edition)
- 深度探索Go語言:對象模型與runtime的原理特性及應(yīng)用