Latest / CyberCode Academy / Course 37 - Building Web Apps with Ruby On Rails | Episode 14: From Basic HTTP to JWT Authentication
Transcript
- 0:00Speaker 1: Right now, your phone is likely holding dozens of silent
- 0:04Speaker 1: conversations with servers across the world.
- 0:07Speaker 2: Yeah, it's constantly chatting away in the background, right Like.
- 0:09Speaker 1: You open an app, you're a fresh of feed, maybe
- 0:11Speaker 1: you check a bank balance, And for every single one
- 0:14Speaker 1: of those actions, your device has to cryptographically prove you
- 0:18Speaker 1: are who you say you are, and has to do
- 0:20Speaker 1: in milliseconds too, exactly in milliseconds, and without ever actually
- 0:24Speaker 1: sending your pass where it happens so seamlessly.
- 0:26Speaker 3: We you know, we just never think about it.
- 0:28Speaker 2: No we don't. But the engineering required to make that
- 0:31Speaker 2: secure and scalable is immense.
- 0:35Speaker 3: It really is.
- 0:36Speaker 1: So today we are taking you on a deep dive
- 0:38Speaker 1: into the evolution of API security. We're going to trace
- 0:41Speaker 1: the exact steps of how systems verify identity.
- 0:44Speaker 2: Right moving from the earliest kind of clunkiest methods to
- 0:48Speaker 2: the modern stateless architecture that basically runs the web today.
- 0:52Speaker 1: Yeah, it's a critical journey to understand because as applications
- 0:55Speaker 1: scale from one hundred users to like one hundred million,
- 0:59Speaker 1: the bottleneck is almost always how efficiently we handle trust.
- 1:02Speaker 2: Absolutely, So we're going to look under the hood at
- 1:05Speaker 2: the actual mechanics of these protocols, not just you know
- 1:09Speaker 2: what code to write, but the underlying architectural decisions right,
- 1:12Speaker 2: the why behind it all Exactly, we need to understand
- 1:16Speaker 2: the trade offs engineers make when they decide how a
- 1:19Speaker 2: server should remember you.
- 1:21Speaker 1: So let's start at the very beginning with the most
- 1:22Speaker 1: foundational protocol, which is basic EAHTTP authentication.
- 1:27Speaker 2: Right.
- 1:27Speaker 1: The classic if we're visualizing this, it's the bouncer at
- 1:30Speaker 1: the door model. Imagine you are at a crowded venue.
- 1:35Speaker 1: Every single time you want to order a drink, or
- 1:37Speaker 1: walk into a different room, or I don't know, even
- 1:39Speaker 1: just look at a menu.
- 1:40Speaker 2: A bouncer steps right in front of you, Yes.
- 1:43Speaker 1: Stops everything and demands to see your physical idea.
- 1:46Speaker 2: That captures the friction perfectly. Yeah, I mean in a
- 1:49Speaker 2: technical sense. Let's look at how this plays out between
- 1:51Speaker 2: a client like a web browser and a server. Okay,
- 1:54Speaker 2: when the client makes an API request to a protected endpoint,
- 1:57Speaker 2: the server immediately halts the request. It responds with an
- 2:01Speaker 2: HTTP four oh one unauthorized status.
- 2:03Speaker 3: Code, basically saying stop right there, right.
- 2:06Speaker 2: And it includes a header that challenges the client for credentials.
- 2:10Speaker 2: So then the client has to prompt the user for
- 2:13Speaker 2: their username and password.
- 2:14Speaker 1: Yeah, and it takes those credentials and bundles them into
- 2:17Speaker 1: the AHGTP authorization header.
- 2:19Speaker 3: The format is incredibly straightforward.
- 2:23Speaker 2: It's very simple.
- 2:24Speaker 1: Yeah. It literally starts with the word basic followed by
- 2:27Speaker 1: a space, and then the username and password joined by
- 2:29Speaker 1: a coal in, right, and then it encodes that combined
- 2:32Speaker 1: string into base.
- 2:32Speaker 2: Sixty four precisely. So the server sees that header, extracts
- 2:36Speaker 2: the base sixty four string, decodes it, and then checks
- 2:39Speaker 2: the database and if there's a match, then it returns
- 2:41Speaker 2: an HTTP two hundred OK code and serves the requested data.
- 2:45Speaker 1: Okay, let's unpack this for a second, because we need
- 2:47Speaker 1: to be very clear about what is actually happening here.
- 2:49Speaker 1: Encoding the header in base sixty four isn't securing anything, right,
- 2:53Speaker 1: not at all. I mean, anyone intercepting the traffic can
- 2:56Speaker 1: decode a Base sixty four string in half a second.
- 2:59Speaker 1: It's just it's pure early an encoding scheme designed to
- 3:01Speaker 1: ensure the text travels over HGTP without breaking due to
- 3:06Speaker 1: special character conflict.
- 3:07Speaker 2: Exactly. That's not encryption, right.
- 3:08Speaker 1: So if there is no encryption happening here, how is
- 3:12Speaker 1: this any better than just sending plaintext. Aren't we essentially
- 3:15Speaker 1: just constantly shouting our sensitive password across the network with
- 3:19Speaker 1: every single click?
- 3:20Speaker 2: We absolutely are, And that is the fatal flaw of
- 3:23Speaker 2: basic HTTP authentication.
- 3:26Speaker 3: It's wild to think about.
- 3:27Speaker 2: It is because to avoid prompting the user to manually
- 3:30Speaker 2: type their password every time they navigate to a new page,
- 3:33Speaker 2: the client application has to cash those credentials locally.
- 3:36Speaker 3: Oh wow, so it's just sitting there.
- 3:38Speaker 2: Yes, it has to keep the plaintext password stored in
- 3:41Speaker 2: memory so it can continuously generate that basicsty four header
- 3:46Speaker 2: for every single subsequent.
- 3:47Speaker 1: Request, which is a massive security vulnerability. You are leaving
- 3:51Speaker 1: the most sensitive piece of user data just sitting exposed
- 3:55Speaker 1: on the client.
- 3:55Speaker 3: Device, right.
- 3:56Speaker 2: It is entirely unacceptable for a production application handling really
- 3:59Speaker 2: US user data today. I can imagine now in the
- 4:02Speaker 2: early days of the web, when systems were simpler and
- 4:05Speaker 2: SSLTLS encryption was less ubiquitous. This is just a quick
- 4:09Speaker 2: way to put up a.
- 4:09Speaker 3: Barrier, sort of a quick and dirty solution exactly.
- 4:12Speaker 2: And even today, if you're just throwing up a temporary
- 4:15Speaker 2: staging environment for internal developers, it works fine, sure, but
- 4:18Speaker 2: as soon as you're building for scale, forcing the client
- 4:21Speaker 2: to store plaintext passwords and forcing the server to do
- 4:25Speaker 2: a heavy database lookup for the password on every single request.
- 4:29Speaker 3: All system just grinds to a halt.
- 4:31Speaker 2: Exactly.
- 4:31Speaker 3: We had to find a better way, which brings us
- 4:34Speaker 3: to the paradigm shift.
- 4:36Speaker 1: If basic off is the bouncer checking your ID at
- 4:39Speaker 1: every single door, the modern standard is the VIP wristband.
- 4:43Speaker 2: VIP wristband.
- 4:43Speaker 1: Yeah, we're talking about JWT. Jason web Tookens. The workflow
- 4:48Speaker 1: change is completely here. You show your username and password
- 4:52Speaker 1: to the bouncer exactly once at.
- 4:53Speaker 3: The front door, right.
- 4:54Speaker 1: The server verifies it and then hands you a secure,
- 4:57Speaker 1: mathematically verifiable wristband.
- 4:59Speaker 3: Forever. Reaction you take after that, you just flash the wristband.
- 5:02Speaker 2: It fundamentally changes application architecture. But to understand why this
- 5:06Speaker 2: VIP wristband can be trusted by the server without doing
- 5:09Speaker 2: a database lookup, we kind of have to dissect its anatomy.
- 5:13Speaker 3: Yeah, let's do that.
- 5:14Speaker 1: Because a JWT just looks like gibberish. It's this long
- 5:16Speaker 1: string of characters.
- 5:17Speaker 2: It does look like gibberish, but it's actually three distinct
- 5:21Speaker 2: Base sixty four encoded segments separated by periods.
- 5:24Speaker 1: Okay, let's break those three parts down, starting with the header.
- 5:27Speaker 2: So the header is the metadata. It tells the server
- 5:30Speaker 2: two pieces of information, First the type of token, which
- 5:34Speaker 2: is JWT, and second the cryptographic hashing algorithm used to secure.
- 5:38Speaker 3: It, like what's the common one.
- 5:41Speaker 2: Usually this is an algorithm like HMAC saha two five six.
- 5:45Speaker 1: Okay, So the header is basically the instruction manual. Then
- 5:48Speaker 1: we have the second part, which is the payload. Right
- 5:51Speaker 1: with the payload, this is the actual cargo. It's a
- 5:53Speaker 1: Jason object containing the claims about the user. Usually it's
- 5:57Speaker 1: just a user ID, maybe an expiration timestamp, and perhaps
- 6:00Speaker 1: a user roll like admin or standard correct.
- 6:03Speaker 2: But if we stop there, we have a massive problem because,
- 6:06Speaker 2: as we established earlier, Base sixty four is just encoding.
- 6:09Speaker 3: Right.
- 6:10Speaker 1: Here's where it gets really interesting, because if the payload
- 6:12Speaker 1: is just Base sixty four, anyone can decode it. So
- 6:16Speaker 1: what is stopping a malicious user from decoding the payload,
- 6:20Speaker 1: changing their user ID from an ordinary user say ID five,
- 6:24Speaker 1: to the admin account ID one, re encoding it and
- 6:27Speaker 1: firing it.
- 6:28Speaker 3: Back to the server.
- 6:29Speaker 2: Nothing if that's all there was, right.
- 6:31Speaker 3: So where is the actual security.
- 6:33Speaker 2: This is where the third segment comes in, which is
- 6:35Speaker 2: the signature. The signature is what makes it JWT functional.
- 6:38Speaker 3: Okay, how does it work?
- 6:39Speaker 2: When the server originally issues the token, It takes the
- 6:43Speaker 2: encoded header, the encoded payload, and a secret key that
- 6:47Speaker 2: is securely stored on the server.
- 6:48Speaker 3: Oh okay.
- 6:49Speaker 2: It runs all three of those through that SAHA two
- 6:51Speaker 2: fifty six algorithm to generate a unique mathematical hash. That
- 6:56Speaker 2: hash becomes the signature.
- 6:58Speaker 1: I want to visualize that secret kese for a second.
- 7:00Speaker 1: It's not a password the user knows. It's more like
- 7:03Speaker 1: a cryptographic water mark, or like a tamper evidence seal
- 7:07Speaker 1: on a pool bottle.
- 7:08Speaker 2: That is an excellent way to think about it. It
- 7:10Speaker 2: is a tamper evident seal. When the client sends the
- 7:13Speaker 2: JWT back to the server to request data, the server
- 7:15Speaker 2: strips off the signature attached to the token. It takes
- 7:18Speaker 2: the header and payload provided by the client, grabs its
- 7:21Speaker 2: own secret key, and basically runs the math again.
- 7:24Speaker 1: So if our malicious user tried to change their user
- 7:28Speaker 1: ID from five to one in the payload, the data
- 7:32Speaker 1: is fundamentally different. Now exactly when the server runs the
- 7:35Speaker 1: hashing algorithm on that altered payload. The resulting hash will
- 7:39Speaker 1: look completely different from the original signature exactly.
- 7:41Speaker 2: The hashes won't match the tamper evidence seal is broken,
- 7:45Speaker 2: and the server immediately rejects the request.
- 7:47Speaker 3: That's brilliant.
- 7:48Speaker 2: What's fascinating here is that the server doesn't need to
- 7:51Speaker 2: query the database to ask is this user really an admin?
- 7:55Speaker 2: It just does the.
- 7:56Speaker 3: Math, right, it trusts the math.
- 7:58Speaker 2: Yes. If the math checks out out, the token is
- 8:01Speaker 2: mathematically proven to be authentic and unaltered.
- 8:04Speaker 1: This totally changes the game for scalability. The core concept
- 8:08Speaker 1: here is statelessness because in older models like traditional session cookies,
- 8:13Speaker 1: the server had to maintain this massive ledger in its
- 8:16Speaker 1: memory of every single active user session.
- 8:18Speaker 2: Which is incredibly memory intensive. I mean, if you have
- 8:21Speaker 2: millions of concurrent users, your database is taking an absolute
- 8:24Speaker 2: beating just verifying who everyone is before it even processes
- 8:29Speaker 2: the actual data request, oh for sure. But with the
- 8:31Speaker 2: stateless JWT, the token is entirely self contained. The server
- 8:36Speaker 2: just does a quick CPU calculation to verify the signature.
- 8:39Speaker 1: But let's push the boundaries of this a bit, because
- 8:41Speaker 1: we're talking about a single server verifying its own token, right,
- 8:45Speaker 1: But modern apps aren't built on single servers anymore. They're
- 8:48Speaker 1: sprawling micro services. You have an authentication service, a billing service,
- 8:54Speaker 1: a video streaming service.
- 8:56Speaker 2: Yeah, dozens of them.
- 8:57Speaker 1: So how does the billing service verify a tamper evidence
- 9:00Speaker 1: if the authentication service is the one holding the secret key.
- 9:04Speaker 1: You wouldn't want to just like copy and paste that
- 9:06Speaker 1: ultimate secret key across fifty different code bases.
- 9:08Speaker 2: Absolutely wouldn't. That would be a complete security nightmare. In
- 9:11Speaker 2: a microservice architecture, we evolve the hashing algorithm. Instead of
- 9:15Speaker 2: a single symmetric secret key, we use asymmetric cryptography.
- 9:19Speaker 3: Meaning a private key and a public key pair exactly.
- 9:22Speaker 2: The central authentication service holds the private key. It is
- 9:26Speaker 2: the only service in the entire infrastructure capable of generating
- 9:30Speaker 2: and signing a new JWT.
- 9:31Speaker 3: Okay, got it.
- 9:33Speaker 2: But it shares the public key with all the other microservices.
- 9:37Speaker 2: So when a user sends a request to the billing service,
- 9:40Speaker 2: the billing service uses the public key to do the
- 9:43Speaker 2: math and verify the signature.
- 9:45Speaker 1: Oh wow, So it can't create tokens, but it can
- 9:48Speaker 1: mathematically prove they were created by the off service.
- 9:51Speaker 2: Excisily, it allows you to scale out your microservices infinitely
- 9:54Speaker 2: without ever creating a bottleneck at the database.
- 9:56Speaker 3: That is just brilliant.
- 9:58Speaker 1: It distributes the trust without out compromising the secret exactly now.
- 10:02Speaker 1: People often claim that another huge benefit of JWT's, especially
- 10:06Speaker 1: compared to old school session cookies, is that they are
- 10:09Speaker 1: a silver bullet for cross site request forgery or CSRF attacks.
- 10:14Speaker 1: Like but let's clarify that because it's a bit of
- 10:16Speaker 1: a dangerous oversimplification, isn't it. Jawts are only immune to
- 10:20Speaker 1: CSRF depending on exactly where you store them on the
- 10:22Speaker 1: client right.
- 10:23Speaker 2: That is a critical nuance, yes, and a place where
- 10:27Speaker 2: a lot of development teams actually introduce fatal flaws. Let's
- 10:30Speaker 2: talk about that. Let's look at the storage trade offs.
- 10:32Speaker 2: If you store the JWT in the browser's local storage
- 10:36Speaker 2: or session storage, the browser won't automatically append it to
- 10:39Speaker 2: cross origin requests. So yes, in that case you are
- 10:42Speaker 2: immune to CSRF.
- 10:44Speaker 1: But the trade off is massive there. Anything in local
- 10:46Speaker 1: storage can be read by JavaScript, right, which immediately opens
- 10:50Speaker 1: you up to cross site scripting or XSS attacks. If
- 10:54Speaker 1: an attacker manages to inject a malicious script into your app,
- 10:57Speaker 1: say through a vulnerable comment, that script can just read
- 11:01Speaker 1: the local storage.
- 11:02Speaker 2: Yep, it grabs the users JWT and sends it to
- 11:05Speaker 2: the attacker server.
- 11:05Speaker 1: And the attacker now has the VIP risk band and
- 11:08Speaker 1: can fully take over the account.
- 11:10Speaker 2: We have seen massive real world breaches happen exactly this way.
- 11:13Speaker 2: A seemingly harmless third party analytics script gets compromised. It
- 11:17Speaker 2: scrapes the local storage of every visitor, and suddenly thousands
- 11:21Speaker 2: of JWTs are stolen.
- 11:22Speaker 3: That's terrifying, So how do we fix it?
- 11:24Speaker 2: To protect against that XSS threat, developers often choose to
- 11:28Speaker 2: store the JWT inside an HTT only cookie because.
- 11:31Speaker 1: An httpay only cookie cannot be read by JavaScript, neutralizing
- 11:35Speaker 1: the EXSS threat entirely right.
- 11:37Speaker 2: But by putting it in a cookie, the browser goes
- 11:40Speaker 2: back to automatically attaching it to requests, which means you
- 11:44Speaker 2: are right back to being vulnerable to CSRF, where an
- 11:47Speaker 2: attacker tricks a user into clicking a link that executes
- 11:50Speaker 2: a state changing request on the app they are logged into.
- 11:52Speaker 3: So JWT is really not a magic seal, No, it's not.
- 11:56Speaker 2: You still have to implement strict core S policies, same
- 11:59Speaker 2: site cookie attribute and potentially anti CSRF tokens depending on
- 12:03Speaker 2: your storage strategy.
- 12:04Speaker 1: Okay, so we have the theory of the Tampa evidence seal,
- 12:07Speaker 1: the asymmetric keys for scaling, and the very real pitfalls
- 12:11Speaker 1: of client side storage. Let's pivot to the back end. Okay,
- 12:15Speaker 1: how do we actually architect this defense in a real
- 12:18Speaker 1: world system? If I'm building an API using a framework
- 12:20Speaker 1: like rubyond Rails or no JS or Django, how do
- 12:23Speaker 1: I organize my code?
- 12:25Speaker 2: The guiding principle here is separation of concerns. We want
- 12:28Speaker 2: to ruthlessly decouple the process of generating the token from
- 12:31Speaker 2: the process of validating the token.
- 12:32Speaker 3: Makes sense.
- 12:33Speaker 2: If you mix those two things into a monolithic jumble
- 12:36Speaker 2: of code, your application becomes just impossible to maintain. We
- 12:41Speaker 2: build two distinct entities, an authentication service and an authorization service.
- 12:45Speaker 1: Okay, let's trace a user's request through this architecture. The
- 12:49Speaker 1: authentication service is the front door. A user submits an
- 12:53Speaker 1: htt post request to assign endpoint containing their email and password.
- 12:59Speaker 2: Right this service intercepts the request, checks the email against
- 13:03Speaker 2: the database, and performs the heavy lifting of hashing the provided.
- 13:07Speaker 1: Password, usually with an algorithm like b crypt.
- 13:09Speaker 2: Trying exactly bcrypt, and it compares it to the stored
- 13:12Speaker 2: hash if they match, The authentication service calls a library
- 13:16Speaker 2: like the JWTGM and Ruby to construct the header, package
- 13:19Speaker 2: the payload, and sign it with private key.
- 13:21Speaker 1: And then it hands the token back to the client
- 13:23Speaker 1: and its job is entirely finished exactly, And it's crucial
- 13:26Speaker 1: to note why we separate this. Hashing passwords with bcrypt
- 13:29Speaker 1: is intentionally slow and CPU intensive to thwart brute force attacks,
- 13:33Speaker 1: you want that heavy workload isolated. So once the client
- 13:36Speaker 1: has the token, they want to actually use the app,
- 13:39Speaker 1: they send a get request to fetch, say, a list
- 13:42Speaker 1: of private projects. This is where the authorization service takes over.
- 13:46Speaker 1: It's the interior security guard.
- 13:48Speaker 2: Yes. When that geet request hits the application, the authorization
- 13:52Speaker 2: service intercepts the HTTP authorization header. It strips away the
- 13:56Speaker 2: word bearer, grabs the token, and runs the signature verification
- 14:00Speaker 2: math we discussed earlier.
- 14:02Speaker 1: And what if things go wrong? Because building mobus software
- 14:05Speaker 1: means anticipating failure. The token might be expired, the payload
- 14:10Speaker 1: might have been tampered with, or the client might have
- 14:12Speaker 1: completely forgotten to send the header at all.
- 14:14Speaker 2: A well architected system fails gracefully and informatively, the authorization
- 14:18Speaker 2: service shouldn't.
- 14:19Speaker 3: Just crash the server great, that would be bad.
- 14:21Speaker 2: It should raise specific custom exceptions in rails. For example,
- 14:25Speaker 2: if the library encounters a bad signature, it might raise
- 14:27Speaker 2: a jawttcode air Okay, if the timestamp is passed due,
- 14:30Speaker 2: it raises a JWT expired signature. The authorization service catches
- 14:35Speaker 2: these exceptions and translates them into a clean HTTP FORO
- 14:38Speaker 2: to one unauthorized.
- 14:39Speaker 1: Response, sending a clear Jason error message back to the
- 14:43Speaker 1: client explaining exactly why they were rejected exactly. So we
- 14:47Speaker 1: have these two highly specialized services. But as an engineering
- 14:51Speaker 1: team grows, how do you prevent human error? You don't
- 14:55Speaker 1: want a junior developer building a brand new, highly sensitive
- 14:59Speaker 1: APIs endpoint and just you know, forgetting to tell the
- 15:02Speaker 1: authorization service to check the door.
- 15:04Speaker 2: No, you definitely don't. You solve that through application level
- 15:07Speaker 2: integration using global enforcers. In most modern web frameworks, you
- 15:12Speaker 2: have a base controller, like an application controller that all
- 15:16Speaker 2: other controllers inherit from. You implement a before reaction filter
- 15:19Speaker 2: at the very top of this base controller.
- 15:22Speaker 3: So it's basically a non negotiable checkpoint exactly.
- 15:24Speaker 2: This global filter dictates that every single incoming API request
- 15:28Speaker 2: must pass through the authorization service before a single line
- 15:32Speaker 2: of feature code is executed. Wow, It extracts the token,
- 15:35Speaker 2: does the math, and fetches the user. If the token
- 15:38Speaker 2: is missing or invalid, the request is halted.
- 15:40Speaker 3: Instantly and if it succeeds.
- 15:42Speaker 2: If it succeeds, it attaches the validated user object to
- 15:46Speaker 2: the request context, so this specific feature controller knows exactly
- 15:51Speaker 2: who is making the request. Security isn't an afterthought, It
- 15:54Speaker 2: is structurally baked right into the foundation.
- 15:57Speaker 3: There are no forgotten end points.
- 15:58Speaker 2: It is incredibly it really is.
- 16:01Speaker 1: We have covered immense technical ground today. Let's do a
- 16:04Speaker 1: quick recap to solidify the architecture we just built. We
- 16:07Speaker 1: started by discarding basic HTTP authentication because forcing the client
- 16:12Speaker 1: to cache plain text passwords and forcing the server to
- 16:16Speaker 1: do constant betabase lookups is just a scaling and security disaster.
- 16:20Speaker 2: A total disaster. Yeah.
- 16:22Speaker 1: We move to the stateless mathematical elegance of JSON web tokens.
- 16:26Speaker 1: We explored the anatomy of the token, how the header
- 16:28Speaker 1: and payload are secured by a server generated signature acting
- 16:31Speaker 1: as that tamper evidence seal. We discussed the realities of
- 16:35Speaker 1: micro services using asymmetric keys, the serious trade offs between
- 16:38Speaker 1: EXSS and CSRF when storing those tokens, And finally, how
- 16:42Speaker 1: to implement a global authorization service to protect every single
- 16:45Speaker 1: end point by default.
- 16:46Speaker 2: That's a solid summary.
- 16:47Speaker 1: To really reinforce what we've covered, I want to pose
- 16:50Speaker 1: a quick review exercise for you.
- 16:51Speaker 3: To think about.
- 16:52Speaker 1: Imagine you are whiteboarding the architecture for a new mobile
- 16:56Speaker 1: application right now. The app needs to support millions of
- 17:00Speaker 1: concurrent users.
- 17:02Speaker 3: First, why would.
- 17:03Speaker 1: You choose a stateless jata WT architecture over a traditional
- 17:07Speaker 1: server side session cookie? And second, if a malicious user
- 17:11Speaker 1: captures their own token and attempts to elevate their privileges
- 17:14Speaker 1: by changing their role from user to admin in the
- 17:17Speaker 1: base sixty four payload, exactly what mathematical process causes the
- 17:21Speaker 1: server to reject the modified token.
- 17:24Speaker 2: Those are great questions.
- 17:25Speaker 1: Take a brief moment to map that out in your head. First,
- 17:28Speaker 1: if you identified that jata BUTT is drastically reduced database
- 17:31Speaker 1: load by putting the verification data inside the token itself,
- 17:35Speaker 1: and that the server's private secret key ensures any altered
- 17:38Speaker 1: payload will result in a mismatched cryptographic.
- 17:40Speaker 2: Hash, then you have a very solid grasp on modern
- 17:43Speaker 2: API security absolutely if we connect this to the bigger picture,
- 17:46Speaker 2: though it is vital to recognize that scalability is a
- 17:49Speaker 2: moving target. We've spent this entire discussion focusing on the
- 17:52Speaker 2: gateway how to efficiently and securely let users in, Right,
- 17:56Speaker 2: But once you solve the authentication bottleneck, you inevitably run
- 17:59Speaker 2: into the data fetching bottleneck.
- 18:01Speaker 1: Oh, you mean the structural limitations of rest APIs themselves.
- 18:05Speaker 2: Exactly As your client applications become more complex, traditional rest
- 18:09Speaker 2: architecture often leads to overfetching.
- 18:11Speaker 3: Right, pulling down too much stuff.
- 18:12Speaker 2: Yeah, If your mobile app only needs a user's name
- 18:15Speaker 2: and profile picture to render a header, but the rest
- 18:18Speaker 2: endpoint returns the entire user object, including their bio, their settings,
- 18:23Speaker 2: and an array of their last fifty posts, you're forcing
- 18:26Speaker 2: the device to download data it doesn't even need.
- 18:29Speaker 1: Which drains battery life, consumes bandwidth, and just slows down
- 18:33Speaker 1: the experience.
- 18:34Speaker 3: It does, which is why the evolution never stops.
- 18:36Speaker 2: Precisely, once your JWT authorization is locked down. The next
- 18:41Speaker 2: logical step in optimizing your architecture is exploring alternative data
- 18:45Speaker 2: paradigms technologies like GRAPHQL or graffiti fundamentally change the client
- 18:50Speaker 2: server relationship.
- 18:51Speaker 1: Well.
- 18:51Speaker 2: Instead of hitting a fixed endpoint that returns a fixed structure,
- 18:54Speaker 2: the client sends a query asking for exactly the fields
- 18:57Speaker 2: it needs, and the server responds with nothing more. It
- 19:01Speaker 2: solves the efficiency problem that rest creates entirely.
- 19:04Speaker 1: It is a continuous loop, isn't it. Finding the bottleneck,
- 19:07Speaker 1: engineering a solution, and moving to the next challenge.
- 19:10Speaker 2: That's the job.
- 19:11Speaker 1: Thank you for joining us on this deep dive into
- 19:13Speaker 1: the mechanics of trust. Whether you are studying for a
- 19:16Speaker 1: system's architecture exam, preparing for a senior engineering interview, or
- 19:20Speaker 1: actively building the back end of your next project, we
- 19:23Speaker 1: hope this gave you a clear mental model of what
- 19:25Speaker 1: is actually happening under the hood. Keep experimenting, keep optimizing,
- 19:29Speaker 1: and never take the security of your front door for granted.
- 19:32Speaker 1: Catch you next time.