ArticleslgStudy

science

Web API security

Web API security is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Web API security rather than just read about it. In short: Web API security entails authenticating programs or users who are invoking a web API. Along with the ease of API integrations come the difficulties of ensuring proper authentication (AuthN) and authorization (AuthZ).

Web API security — main illustration
Web API security — illustration

Key takeaways

  • Web API security belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Web API security to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Web API security from memory before moving on to harder problems.

Reference excerpt

Web API security entails authenticating programs or users who are invoking a web API. Along with the ease of API integrations come the difficulties of ensuring proper authentication (AuthN) and authorization (AuthZ). In a multitenant environment, security controls based on proper AuthN and AuthZ can help ensure that API access is limited to those who need (and are entitled to) it. Appropriate AuthN schemes enable producers (APIs or services) to properly identify consumers (clients or calling programs), and to evaluate their access level (AuthZ). In other words, may a consumer invoke a particular method (business logic) based on the credentials presented? "Interface design flaws are widespread, from the world of crypto processors through sundry embedded systems right through to antivirus software and the operating system itself."

Method of authentication and authorization The most common methods for authentication and authorization include:

Static strings: These are like passwords that are provided by API's to consumers. Dynamic tokens: These are time based tokens obtained by caller from an authentication service. User-delegated tokens: These are tokens such as OAuth which are granted based on user authentication. Policy & attribute-based access control: policies use attributes to define how APIs can be invoked using standards such as ALFA or XACML. The above methods provide different level of security and ease of integration. Oftentimes, the easiest method of integration also offers weakest security model.

Static strings In static strings method, the API caller or client embeds a string as a token in the request. This method is often referred as basic authentication. "From a security point of view, basic authentication is not very satisfactory. It means sending the user's password over the network in clear text for every single page accessed (unless a secure lower-level protocol, like SSL, is used to encrypt all transactions). Thus the user is very vulnerable to any packet sniffers on the net."

Dynamic tokens When an API is protected by a dynamic token, there is a time-based nonce inserted into the token. The token has a time to live (TTL) after which the client must acquire a new token. The API method has a time check algorithm, and if the token is expired, the request is forbidden. "An example of such token is JSON Web Token. The "exp" (expiration time) claim identifies the expiration time on or after which the JWT MUST NOT be accepted for processing."

User-delegated token This type of token is used in three-legged systems where an application needs to access an API on behalf of a user. Instead of revealing user id and password to the application, a user grants a token which encapsulates users permission for the application to invoke the API. The OAuth 2.0 authorization framework enables a third-party application to obtain limited access to an HTTP service, either on behalf of a resource owner by orchestrating an approval interaction between the resource owner and the HTTP service, or by allowing the third-party application to obtain access on its own behalf.

Fine-Grained Authorization for APIs

Attribute-Based Access Control In this approach, there is a Policy Enforcement Point either within the API itself, in the API framework (as an interceptor or message handler), or as an API gateway (e.g. WSO2, Kong, Tyk, or similar) that intercepts the call to the API and / or the response back from the API. It converts it into an authorization request (typically in XACML) which it sends to a Policy Decision Point (PDP). The Policy Decision Point is configured with policies that implement dynamic access control that can use any number of user, resource, action, and context attributes to define which access is allowed or denied. Policies can be about:

the resource (e.g. a bank account) the user (e.g. a customer) the context (e.g. time of day) a relationship (e.g. the customer to whom the account belongs). Policies are expressed in ALFA or XACML.

References

External links OWASP API Security Project

Worked examples

Example 1 — a first encounter with Web API security

Start with the simplest possible case. Write down what Web API security claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Web API security before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Web API security ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Web API security

In research
Web API security appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Web API security in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Web API security is common in secondary-school and first-year university syllabi. It links to neighbouring topics Transport Layer Security, so understanding it makes those chapters shorter.
In everyday life
Look for Web API security outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Web API security” →

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Web API security in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Web API security means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Web API security out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Web API security in simple terms?

Web API security entails authenticating programs or users who are invoking a web API. Along with the ease of API integrations come the difficulties of ensuring proper authentication (AuthN) and authorization (AuthZ).

Why does Web API security matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Web API security?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Web API security.

Tags

  • Transport Layer Security

Keep exploring