A&A Interview questions
๐๐ฆ๐ข๐ก ๐ช๐ฒ๐ฏ ๐ง๐ผ๐ธ๐ฒ๐ป๐ (๐๐ช๐ง๐) are a compact and secure way to transmit information between two parties.
They are often used for authentication and authorization purposes in modern APIs.
The information in a JWT is stored as a JSON object, which is then encoded and signed with a secret key to ensure its integrity.
A JWT typically consists of three parts:
๐๐ฒ๐ฎ๐ฑ๐ฒ๐ฟ: This part contains information about the token, such as the algorithm used to sign it.
๐ฃ๐ฎ๐๐น๐ผ๐ฎ๐ฑ: This part contains the actual data, such as the user's identity or session information.
๐ฆ๐ถ๐ด๐ป๐ฎ๐๐๐ฟ๐ฒ: This part is used to verify the authenticity of the token.
Here's an example of a JWT:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POkS0Mgmj9g_m8As
The header is encoded as Base64url, the payload is encoded as JSON, and the signature is encoded as Base64url and signed using the secret key.
JWTs are significant in modern APIs because they provide a stateless, scalable, and secure way to authenticate and authorize users.
They enable servers to offload session management tasks and reduce the overhead associated with traditional session-based authentication methods.
Additional thoughts on JWTs:
๐ถ JWTs are typically used in conjunction with HTTP requests.
๐ถ JWTs can be used to represent a variety of information, including user identity, session information, and access tokens.
๐ถ JWTs are typically signed using a secret key, which ensures that the contents of the token cannot be tampered with.
๐ถ JWTs are a popular choice for authentication and authorization in modern APIs because they are lightweight, easy to use, and secure.
OAuth has gone through several versions since its inception, with each version introducing improvements, security enhancements, and additional features. As of my knowledge cutoff in September 2021, the main versions of OAuth are:
OAuth 1.0: The original version of OAuth, published in December 2007. OAuth 1.0 relied on the use of cryptographic signatures to secure requests and was widely adopted. However, it had some complexities and security issues, which led to the development of OAuth 2.0.
OAuth 2.0: OAuth 2.0 is a significant redesign and improvement over OAuth 1.0. It was published in October 2012 and introduced a more straightforward and flexible approach to authorization. OAuth 2.0 does not rely on cryptographic signatures like its predecessor. Instead, it uses bearer tokens (access tokens) for authorization and introduces different grant types, each suited for specific scenarios. OAuth 2.0 has become the de facto standard for authorization in the industry.
Comments
Post a Comment