Skip to content

Commit 8a3b365

Browse files
committed
Fix typos and improve wording
1 parent 2a22c17 commit 8a3b365

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

views/md/introduction.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
## What is JSON Web Token?
2-
JSON Web Token (JWT) is an open standard ([RFC 7519](https://tools.ietf.org/html/rfc7519)) that defines a compact and self-contained way for securely transmitting information between parties as a JSON object. This information can be verified and trusted because it is digitally signed. JWTs can be signed using a secret (with **HMAC** algorithm) or a public/private key pair using **RSA**.
2+
JSON Web Token (JWT) is an open standard ([RFC 7519](https://tools.ietf.org/html/rfc7519)) that defines a compact and self-contained way for securely transmitting information between parties as a JSON object. This information can be verified and trusted because it is digitally signed. JWTs can be signed using a secret (with the **HMAC** algorithm) or a public/private key pair using **RSA**.
33

44
Let's explain some concepts of this definition further.
55

6-
- **Compact**: Because of its size, it can be sent through an URL, POST parameter, or inside an HTTP header. Additionally, due to its size its transmission is fast.
6+
- **Compact**: Because of its smaller size, JWTs can be sent through an URL, POST parameter, or inside an HTTP header. Additionally, the smaller size means transmission is fast.
77

8-
- **Self-contained**: The payload contains all the required information about the user, to avoid querying the database more than once.
8+
- **Self-contained**: The payload contains all the required information about the user, avoiding the need to query the database more than once.
99

1010
## When should you use JSON Web Tokens?
11-
There are some scenarios where JSON Web Tokens are useful:
11+
Here are some scenarios where JSON Web Tokens are useful:
1212

13-
- **Authentication**: This is the typical scenario for using JWT, once the user is logged in, each subsequent request will include the JWT, allowing the user to access routes, services, and resources that are permitted with that token. Single Sign On is a feature that widely uses JWT nowadays, because of its small overhead and its ability to be easily used among systems of different domains.
13+
- **Authentication**: This is the most common scenario for using JWT. Once the user is logged in, each subsequent request will include the JWT, allowing the user to access routes, services, and resources that are permitted with that token. Single Sign On is a feature that widely uses JWT nowadays, because of its small overhead and its ability to be easily used across different domains.
1414

15-
- **Information Exchange**: JSON Web Tokens are a good way of securely transmitting information between parties, because as they can be signed, for example using public/private key pairs, you can be sure that the senders are who they say they are. Additionally, as the signature is calculated using the header and the payload, you can also verify that the content hasn't changed.
15+
- **Information Exchange**: JSON Web Tokens are a good way of securely transmitting information between parties, because as they can be signed, for example using public/private key pairs, you can be sure that the senders are who they say they are. Additionally, as the signature is calculated using the header and the payload, you can also verify that the content hasn't been tampered with.
1616

17-
## Which is the JSON Web Token structure?
17+
## What is the JSON Web Token structure?
1818
JSON Web Tokens consist of three parts separated by dots (`.`), which are:
1919

2020
- Header
@@ -29,7 +29,7 @@ Let's break down the different parts.
2929

3030
### Header
3131

32-
The header *typically* consists of two parts: the type of the token, which is JWT, and the hashing algorithm such as HMAC SHA256 or RSA.
32+
The header *typically* consists of two parts: the type of the token, which is JWT, and the hashing algorithm being used, such as HMAC SHA256 or RSA.
3333

3434
For example:
3535

@@ -47,7 +47,7 @@ Then, this JSON is **Base64Url** encoded to form the first part of the JWT.
4747
The second part of the token is the payload, which contains the claims. Claims are statements about an entity (typically, the user) and additional metadata.
4848
There are three types of claims: *reserved*, *public*, and *private* claims.
4949

50-
- **Reserved claims**: These are a set of predefined claims, which are not mandatory but recommended, thought to provide a set of useful, interoperable claims. Some of them are: **iss** (issuer), **exp** (expiration time), **sub** (subject), **aud** (audience), among others.
50+
- **Reserved claims**: These is a set of predefined claims which are not mandatory but recommended, to provide a set of useful, interoperable claims. Some of them are: **iss** (issuer), **exp** (expiration time), **sub** (subject), **aud** (audience), and others.
5151

5252
> Notice that the claim names are only three characters long as JWT is meant to be compact.
5353

@@ -70,7 +70,7 @@ The payload is then **Base64Url** encoded to form the second part of the JSON We
7070
### Signature
7171
To create the signature part you have to take the encoded header, the encoded payload, a secret, the algorithm specified in the header, and sign that.
7272

73-
For example if you want to use the HMAC SHA256 algorithm, the signature will be created in the following way.
73+
For example if you want to use the HMAC SHA256 algorithm, the signature will be created in the following way:
7474

7575
```
7676
HMACSHA256(
@@ -79,51 +79,51 @@ HMACSHA256(
7979
secret)
8080
```
8181

82-
The signature is used to verify that the sender of the JWT is who it says it is and to ensure that the message was't changed in the way.
82+
The signature is used to verify that the sender of the JWT is who it says it is and to ensure that the message wasn't changed along the way.
8383

8484
### Putting all together
8585

86-
The output is three Base64 strings separated by dots that can be easily passed in HTML and HTTP environments, while being more compact compared to XML-based standards such as SAML.
86+
The output is three Base64 strings separated by dots that can be easily passed in HTML and HTTP environments, while being more compact when compared to XML-based standards such as SAML.
8787

8888
The following shows a JWT that has the previous header and payload encoded, and it is signed with a secret.
8989
![Encoded JWT](https://cdn.auth0.com/content/jwt/encoded-jwt3.png)
9090

91-
If you want to play with JWT and put these concepts to practice, you can use [jwt.io Debugger](http://jwt.io) to decode, verify and generate JWTs.
91+
If you want to play with JWT and put these concepts into practice, you can use [jwt.io Debugger](http://jwt.io) to decode, verify, and generate JWTs.
9292

9393
![JWT.IO Debugger](https://cdn.auth0.com/blog/legacy-app-auth/legacy-app-auth-5.png)
9494

9595
## How do JSON Web Tokens work?
9696
In authentication, when the user successfully logs in using his credentials, a JSON Web Token will be returned and must be saved locally (typically in local storage, but cookies can be also used), instead of the traditional approach of creating a session in the server and returning a cookie.
9797

98-
Whenever the user wants to access a protected route or resource, it should send the JWT, typically in the **Authorization** header using the **Bearer** schema. Therefore the content of the header should look like the following.
98+
Whenever the user wants to access a protected route or resource, the user agent should send the JWT, typically in the **Authorization** header using the **Bearer** schema. The content of the header should look like the following:
9999

100100
```
101101
Authorization: Bearer <token>
102102
```
103103

104-
This is a stateless authentication mechanism as the user state is never saved in the server memory.
105-
The server's protected routes will check for a valid JWT in the Authorization header, and if there is, the user will be allowed. As JWTs are self-contained, all the necessary information is there, reducing the need of going back and forward to the database.
104+
This is a stateless authentication mechanism as the user state is never saved in server memory.
105+
The server's protected routes will check for a valid JWT in the Authorization header, and if it's present, the user will be allowed to access protected resources. As JWTs are self-contained, all the necessary information is there, reducing the need to query the database multiple times.
106106

107-
This allows to fully rely on data APIs that are stateless and even make requests to downstream services. It doesn't matter which domains are serving your APIs, as Cross-Origin Resource Sharing (CORS) won't be an issue as it doesn't use cookies.
107+
This allows you to fully rely on data APIs that are stateless and even make requests to downstream services. It doesn't matter which domains are serving your APIs, so Cross-Origin Resource Sharing (CORS) won't be an issue as it doesn't use cookies.
108108

109109
The following diagram shows this process:
110110

111111
![How does a JSON Web Token works](https://cdn.auth0.com/content/jwt/jwt-diagram.png)
112112

113113
## Why should we use JSON Web Tokens?
114114

115-
Let's talk about the benefits of **JSON Web Tokens (JWT)** comparing it to **Simple Web Tokens (SWT)** and **Security Assertion Markup Language Tokens (SAML)**.
115+
Let's talk about the benefits of **JSON Web Tokens (JWT)** when compared to **Simple Web Tokens (SWT)** and **Security Assertion Markup Language Tokens (SAML)**.
116116

117-
As JSON is less verbose than XML, when it is encoded its size is also smaller; making JWT more compact than SAML. This makes JWT a good choice to be passed in HTML and HTTP environments.
117+
As JSON is less verbose than XML, when it is encoded its size is also smaller, making JWT more compact than SAML. This makes JWT a good choice to be passed in HTML and HTTP environments.
118118

119-
Security-wise, SWT can only be symmetric signed by a shared secret using the HMAC algorithm. While JWT and SAML tokens can also use a public/private key pair in the form of a X.509 certificate to sign them. However, signing XML with XML Digital Signature without introducing obscure security holes is very difficult compared to the simplicity of signing JSON.
119+
Security-wise, SWT can only be symmetricly signed by a shared secret using the HMAC algorithm. However, JWT and SAML tokens can use a public/private key pair in the form of a X.509 certificate for signing. Signing XML with XML Digital Signature without introducing obscure security holes is very difficult when compared to the simplicity of signing JSON.
120120

121-
JSON parsers are common in most programming languages, because they map directly to objects, conversely XML doesn't have a natural document-to-object mapping. This makes it easier to work with JWT than SAML assertions.
121+
JSON parsers are common in most programming languages because they map directly to objects. Conversely, XML doesn't have a natural document-to-object mapping. This makes it easier to work with JWT than SAML assertions.
122122

123-
Regarding usage, JWT is used at an Internet scale. This highlights the ease of client side processing of the JSON Web token on multiple platforms, especially, mobile.
123+
Regarding usage, JWT is used at Internet scale. This highlights the ease of client-side processing of the JSON Web token on multiple platforms, especially mobile.
124124

125125
![Comparing the length of an encoded JWT and an encoded SAML](https://cdn.auth0.com/content/jwt/comparing-jwt-vs-saml2.png)
126126
_Comparison of the length of an encoded JWT and an encoded SAML_
127127

128128

129-
If you want to read more about JSON Web Tokens and even start using them to perform authentication in your own applications, browse to the [JSON Web Token landing page](http://auth0.com/learn/json-web-tokens) in Auth0.
129+
If you want to read more about JSON Web Tokens and even start using them to perform authentication in your own applications, browse to the [JSON Web Token landing page](http://auth0.com/learn/json-web-tokens) at Auth0.

0 commit comments

Comments
 (0)