Dylan  Iqbal

Dylan Iqbal

1630034872

The Differences Between Git-based and API-driven in Headless CMS

In this post we’ll compare both types of headless CMS platforms, focusing on the differences between them, the pros and cons, and the use cases, to help you make the right decision.

Content management system (CMS) platforms have been at the forefront of content creation for nearly two decades. However, a lot has changed since the release of WordPress in 2004. New technologies have been introduced and CMSs have evolved, decoupling where the content is managed from where it’s displayed.

Even though WordPress is still in high use, it has a lot of drawbacks. To achieve better performance, higher reliability, greater security, and the freedom of displaying your content wherever and however you want, you may need to move to a headless CMS.

To do that, you’ll need first to decide which type of headless CMS you want to use—Git-based or API-driven?

In this post I’ll compare both types of headless CMS platforms, focusing on the differences between them, the pros and cons, and the use cases, to help you make your decision.

How Do Headless CMSs Work?

To better understand different types of CMSs, you first have to know the technologies that power them.

Git-Based

Git-based CMSs are built upon the Git version control system (VCS).

Git stores your files and their history of changes in a repository. It allows you to branch out, merge, clone, react to changes, and in general easily manage your content—especially the text element.

Git-based CMS architecture

In a Git-based CMS, you manage your content through mentioned Git functionalities or the Git-powered editor right in your CMS. Then, on selected changes, the CMS processes the new or updated content and automatically builds and updates your frontend (website or app, for instance). That’s usually done through integration with large Git providers like GitHub or GitLab.

API-First

API-first CMSs work as unified pieces of software, serving content through an Application Programming Interface (API).

API-first CMS architecture

Developers can use the API (usually REST or GraphQL) to build the required frontend or other types of integrations. Reactions to specific updates and other outputs from the CMS also need to be directly handled.

The content storage, editor, and general management are all handled by the CMS.

If You Use a Git-Based CMS

Each type of headless CMS offers benefits and drawbacks. Here are the pros and cons of a Git-based CMS. As you’ll see, its biggest strengths and weaknesses come from the Git VCS powering it.

Pros

  • The baked-in features of Git: Full version control, auto backup, clean control structure.
  • Integrated development: As Git is already the go-to VCS for software development, it’s easy to keep your frontend code right beside your content, keeping everything centralized.
  • No lock-in: Git is an open-source tool and industry standard allowing you to switch between Git cloud providers and Git-based CMSs relatively easily.
  • Easy setup: Especially if you’re already used to working with Git, setting up Git-based CMS is relatively simple.

Cons

  • A limited number of front-ends: Due to its implementation as Git integration, a Git-based CMS doesn’t scale well for multiple, especially diverse, frontends.
  • Hard to use with complex or frequently updated content: Git is also not a place for frequent live content and heavy static assets due to its update model and the Git architecture, respectively.
  • Limited querying options: It depends on the CMS, but Git-based platforms usually have limited data querying options, limiting the front-end customization potential.

If You Use an API-First CMS

The advantages and disadvantages of API-first CMSs vary greatly from the Git-based CMSs. Not only are they based on a different foundation, but as unified pieces of software, they can be different even from each other.

Because of this, some API-first CMS platforms might have pros and cons that others might not have. Still, some general points apply to most of them.

Pros

  • Well-suited for multiple frontends: Single, headless CMSs can easily serve different frontends with the help of API.
  • Great customizability and choice: As API-first CMSs are usually built from the ground up, there are many solutions available to choose from. You can even build custom CMSs on top of more advanced APIs.
  • Easily handles large data: This might vary depending on the CMS, but API-first platforms can usually handle larger data sets than Git-based platforms.
  • Can handle frequently updated content: Without Git in the way, updates can be delivered quickly and even more specifically designed.

Cons

  • No Git features guaranteed: Since Git isn’t part of the CMS architecture, you have to think twice about things like versioning or backup.
  • Storage and usage limits: As API-first CMSs are more integrated, you can expect them to come with costly limits on storage and usage.
  • Fewer formatting options: As with all locked-in CMSs, you’ll be limited only to the formatting options you’re given.
  • More dependent on developers: Even though API is great for custom frontends, it requires more custom handling and developer involvement.

Opportunities and Challenges

Each type of headless CMS presents opportunities and challenges to the developer. How can you make the most out of either a Git-based or API-first CMS, and what bottlenecks can you expect as you go?

The Power of Git-Based CMSs

The benefits of powering a CMS through Git cannot be understated.

From the start, you’ll be working with a system you’re probably very familiar with. From version control to its open-source nature and multiple integrations to content formatting flexibility, you’ve got everything you need to set up all kinds of great websites quickly.

SEO and Scalability

However, with content format flexibility also comes more responsibilities, like handling SEO optimizations yourself. That’s something API-first CMSs will often do automatically.

As for scalability, when going with a Git-based CMS, consider the future of your product. Plan the correct content format ahead of time. Know what frontends you’ll need to handle, how large your data set will get, and whether you’ll host frequently updated content, among other issues. A Git-based CMS doesn’t scale well for certain medium and larger or multiple frontends, so keep this in mind.

The Flexibility of API-First CMSs

Using an API-first CMS allows access to opportunities that aren’t possible with Git. It’s much more scalable, can drive multiple diverse frontends, and can even integrate with unique consumer devices like smart speakers. With API, you can do pretty much anything given enough time and the right tools.

Additionally, API-first CMSs are better suited for handling heavy static assets and frequent content updates. Even if that’s not something you need currently, it’s important to consider as your content grows.

Developer-Heavy and Higher Costs

A drawback to all those API benefits is the fact that it drives higher reliance on developers. Whether that’s a deal breaker or not depends on your situation and use case.

API-first CMSs offer a more closed, proprietary model than Git, and along with that come higher costs. However, the amount and quality of provided services might be worth it for your use case.

Use Cases

Speaking of use cases, what exact products and services can you develop with either headless CMS?

Static Websites

Static websites are among the most popular sites for coupling with headless CMSs. For all the blogs, landing pages, newsletter pages, documentation, and other elements, both Git-based and API-first CMSs will work well—particularly the Git-based ones, given their simplicity and fast setup.

E-Commerce

The type of CMS recommended for e-commerce sites will vary depending on how often you need to update your content. For simple, infrequently updated, small- to medium-sized stores, a Git-based CMS will do just fine. If you’re looking at scalability and planning for future growth, though, you should consider investing in an API-first CMS.

Multi-Platform

For multi-platform products with multiple frontends, API-first CMS is definitely the way to go. It will require more developer involvement, but with good API, you’ll get access to a huge variety of platforms.

However, depending on the type of multi-platform support you’re after, Git-based CMS could still be an option. Custom Git integration can work if you want your content to be available not only on your website but also through RSS, in PDF formats, or cross-posted to other websites.

Multi-Source

If in addition to targeting multiple platforms, you also have multiple content sources, API-first CMSs offer one more feature worth considering—content federation.

With the right API (usually offered in GraphQL), you can utilize content federation to pull your content for multiple sources and access it all through a unified API-first CMS. That’s a huge advantage for large publications and a huge relief for content management.

Conclusion

Depending on your needs, there’s a use for both Git-based and API-first CMSs. While Git is great for rapid setup, guaranteed versioning, and simplicity of use, API-first CMSs provide more features, are more scalable, and offer more flexibility for future planning.

Whichever you choose, headless CMSs can make a huge difference in content creation and management for your site. Consider your technical and business needs so you can choose the CMS with the features you most require.

The Original Article can be found on https://strapi.io

#git #api #developer 

What is GEEK

Buddha Community

The Differences Between Git-based and API-driven in Headless CMS

Top 10 API Security Threats Every API Team Should Know

As more and more data is exposed via APIs either as API-first companies or for the explosion of single page apps/JAMStack, API security can no longer be an afterthought. The hard part about APIs is that it provides direct access to large amounts of data while bypassing browser precautions. Instead of worrying about SQL injection and XSS issues, you should be concerned about the bad actor who was able to paginate through all your customer records and their data.

Typical prevention mechanisms like Captchas and browser fingerprinting won’t work since APIs by design need to handle a very large number of API accesses even by a single customer. So where do you start? The first thing is to put yourself in the shoes of a hacker and then instrument your APIs to detect and block common attacks along with unknown unknowns for zero-day exploits. Some of these are on the OWASP Security API list, but not all.

Insecure pagination and resource limits

Most APIs provide access to resources that are lists of entities such as /users or /widgets. A client such as a browser would typically filter and paginate through this list to limit the number items returned to a client like so:

First Call: GET /items?skip=0&take=10 
Second Call: GET /items?skip=10&take=10

However, if that entity has any PII or other information, then a hacker could scrape that endpoint to get a dump of all entities in your database. This could be most dangerous if those entities accidently exposed PII or other sensitive information, but could also be dangerous in providing competitors or others with adoption and usage stats for your business or provide scammers with a way to get large email lists. See how Venmo data was scraped

A naive protection mechanism would be to check the take count and throw an error if greater than 100 or 1000. The problem with this is two-fold:

  1. For data APIs, legitimate customers may need to fetch and sync a large number of records such as via cron jobs. Artificially small pagination limits can force your API to be very chatty decreasing overall throughput. Max limits are to ensure memory and scalability requirements are met (and prevent certain DDoS attacks), not to guarantee security.
  2. This offers zero protection to a hacker that writes a simple script that sleeps a random delay between repeated accesses.
skip = 0
while True:    response = requests.post('https://api.acmeinc.com/widgets?take=10&skip=' + skip),                      headers={'Authorization': 'Bearer' + ' ' + sys.argv[1]})    print("Fetched 10 items")    sleep(randint(100,1000))    skip += 10

How to secure against pagination attacks

To secure against pagination attacks, you should track how many items of a single resource are accessed within a certain time period for each user or API key rather than just at the request level. By tracking API resource access at the user level, you can block a user or API key once they hit a threshold such as “touched 1,000,000 items in a one hour period”. This is dependent on your API use case and can even be dependent on their subscription with you. Like a Captcha, this can slow down the speed that a hacker can exploit your API, like a Captcha if they have to create a new user account manually to create a new API key.

Insecure API key generation

Most APIs are protected by some sort of API key or JWT (JSON Web Token). This provides a natural way to track and protect your API as API security tools can detect abnormal API behavior and block access to an API key automatically. However, hackers will want to outsmart these mechanisms by generating and using a large pool of API keys from a large number of users just like a web hacker would use a large pool of IP addresses to circumvent DDoS protection.

How to secure against API key pools

The easiest way to secure against these types of attacks is by requiring a human to sign up for your service and generate API keys. Bot traffic can be prevented with things like Captcha and 2-Factor Authentication. Unless there is a legitimate business case, new users who sign up for your service should not have the ability to generate API keys programmatically. Instead, only trusted customers should have the ability to generate API keys programmatically. Go one step further and ensure any anomaly detection for abnormal behavior is done at the user and account level, not just for each API key.

Accidental key exposure

APIs are used in a way that increases the probability credentials are leaked:

  1. APIs are expected to be accessed over indefinite time periods, which increases the probability that a hacker obtains a valid API key that’s not expired. You save that API key in a server environment variable and forget about it. This is a drastic contrast to a user logging into an interactive website where the session expires after a short duration.
  2. The consumer of an API has direct access to the credentials such as when debugging via Postman or CURL. It only takes a single developer to accidently copy/pastes the CURL command containing the API key into a public forum like in GitHub Issues or Stack Overflow.
  3. API keys are usually bearer tokens without requiring any other identifying information. APIs cannot leverage things like one-time use tokens or 2-factor authentication.

If a key is exposed due to user error, one may think you as the API provider has any blame. However, security is all about reducing surface area and risk. Treat your customer data as if it’s your own and help them by adding guards that prevent accidental key exposure.

How to prevent accidental key exposure

The easiest way to prevent key exposure is by leveraging two tokens rather than one. A refresh token is stored as an environment variable and can only be used to generate short lived access tokens. Unlike the refresh token, these short lived tokens can access the resources, but are time limited such as in hours or days.

The customer will store the refresh token with other API keys. Then your SDK will generate access tokens on SDK init or when the last access token expires. If a CURL command gets pasted into a GitHub issue, then a hacker would need to use it within hours reducing the attack vector (unless it was the actual refresh token which is low probability)

Exposure to DDoS attacks

APIs open up entirely new business models where customers can access your API platform programmatically. However, this can make DDoS protection tricky. Most DDoS protection is designed to absorb and reject a large number of requests from bad actors during DDoS attacks but still need to let the good ones through. This requires fingerprinting the HTTP requests to check against what looks like bot traffic. This is much harder for API products as all traffic looks like bot traffic and is not coming from a browser where things like cookies are present.

Stopping DDoS attacks

The magical part about APIs is almost every access requires an API Key. If a request doesn’t have an API key, you can automatically reject it which is lightweight on your servers (Ensure authentication is short circuited very early before later middleware like request JSON parsing). So then how do you handle authenticated requests? The easiest is to leverage rate limit counters for each API key such as to handle X requests per minute and reject those above the threshold with a 429 HTTP response. There are a variety of algorithms to do this such as leaky bucket and fixed window counters.

Incorrect server security

APIs are no different than web servers when it comes to good server hygiene. Data can be leaked due to misconfigured SSL certificate or allowing non-HTTPS traffic. For modern applications, there is very little reason to accept non-HTTPS requests, but a customer could mistakenly issue a non HTTP request from their application or CURL exposing the API key. APIs do not have the protection of a browser so things like HSTS or redirect to HTTPS offer no protection.

How to ensure proper SSL

Test your SSL implementation over at Qualys SSL Test or similar tool. You should also block all non-HTTP requests which can be done within your load balancer. You should also remove any HTTP headers scrub any error messages that leak implementation details. If your API is used only by your own apps or can only be accessed server-side, then review Authoritative guide to Cross-Origin Resource Sharing for REST APIs

Incorrect caching headers

APIs provide access to dynamic data that’s scoped to each API key. Any caching implementation should have the ability to scope to an API key to prevent cross-pollution. Even if you don’t cache anything in your infrastructure, you could expose your customers to security holes. If a customer with a proxy server was using multiple API keys such as one for development and one for production, then they could see cross-pollinated data.

#api management #api security #api best practices #api providers #security analytics #api management policies #api access tokens #api access #api security risks #api access keys

Autumn  Blick

Autumn Blick

1601381326

Public ASX100 APIs: The Essential List

We’ve conducted some initial research into the public APIs of the ASX100 because we regularly have conversations about what others are doing with their APIs and what best practices look like. Being able to point to good local examples and explain what is happening in Australia is a key part of this conversation.

Method

The method used for this initial research was to obtain a list of the ASX100 (as of 18 September 2020). Then work through each company looking at the following:

  1. Whether the company had a public API: this was found by googling “[company name] API” and “[company name] API developer” and “[company name] developer portal”. Sometimes the company’s website was navigated or searched.
  2. Some data points about the API were noted, such as the URL of the portal/documentation and the method they used to publish the API (portal, documentation, web page).
  3. Observations were recorded that piqued the interest of the researchers (you will find these below).
  4. Other notes were made to support future research.
  5. You will find a summary of the data in the infographic below.

Data

With regards to how the APIs are shared:

#api #api-development #api-analytics #apis #api-integration #api-testing #api-security #api-gateway

An API-First Approach For Designing Restful APIs | Hacker Noon

I’ve been working with Restful APIs for some time now and one thing that I love to do is to talk about APIs.

So, today I will show you how to build an API using the API-First approach and Design First with OpenAPI Specification.

First thing first, if you don’t know what’s an API-First approach means, it would be nice you stop reading this and check the blog post that I wrote to the Farfetchs blog where I explain everything that you need to know to start an API using API-First.

Preparing the ground

Before you get your hands dirty, let’s prepare the ground and understand the use case that will be developed.

Tools

If you desire to reproduce the examples that will be shown here, you will need some of those items below.

  • NodeJS
  • OpenAPI Specification
  • Text Editor (I’ll use VSCode)
  • Command Line

Use Case

To keep easy to understand, let’s use the Todo List App, it is a very common concept beyond the software development community.

#api #rest-api #openai #api-first-development #api-design #apis #restful-apis #restful-api

Chaz  Homenick

Chaz Homenick

1602682740

A Simple Guide to Planning API Roadmaps

APIs - the current “big thing” - offer the opportunity for modern organizations to unlock new and lucrative business models. The article below covers some tips on how to spin the API flywheel and leverage its possibilities.

In the API economy, a successful service can gain popularity and be utilized in ways unpredicted and often inconceivable by its original owners. The very flexible nature of the technology opens many doors, including business collaborations, reuse in third-party products or even conquering hardware barriers by reaching a spectrum of devices.

What to consider

Taking the builder’s perspective

Important note: Most of the time API consumers are not the end-users but rather the app developers. Any new venture ought to be supported with excellent learning resources and descriptive documentation. These things combined will ensure a top-notch developer experience and encourage adoption of your product, increasing its visibility in the market.

More than the revenue

While in the simplest scenario, the most popular API business model is revenue via service charges, there are several other goals:

  • **Growth **- APIs are finely-grained and, usually, short-term projects that bring lots of value. Decoupling sectors of your business and encapsulating them in the form of concise, dedicated APIs enable teams to work in parallel, encouraging company growth.
  • **Reach **- By building APIs for wide use, the organization can extend its group of recipients and open new opportunities to cooperate with other players in the market and discover new collaborations.
  • **Compliance **- Products and services implemented as an API ecosystem can freely exchange data between one another, whether they are internal or external.
  • **Insight **- The rate of use of APIs will surely give an idea of what consumers value the most. Also, implementing APIs alone helps to clarify what pieces of your business are crucial. This helps to revise implementation details and encourages reflection of your current technological solutions.

#api #api-development #api-integration #restful-api #api-based-business-model #api-first-development #automation #rest-api

Marcelle  Smith

Marcelle Smith

1597061580

Introduction to API-First CMS with Directus' Open Source, Headless CMS

“Off with their heads!”

The frontend developers’ call to arms echoed throughout the realm. All across the Internet lands, monolithic, traditional CMS shivered.

Seriously though, we’re finally going to discuss API-first CMS—aka decoupled/headless CMS—on the blog.

From GitHub forks to email inquiries, we’ve noticed an increasing interest in “going headless” in general, but also for e-commerce purpose. So today, we’re going to:

  1. Discuss the whatwhy and when of API-first CMS.
  2. Show how to code a transactional web app with content managed in Directus, an open source headless CMS.

More specifically, I’ll explain how to build a lookbook using a full JAMstack: Metalsmith, Vue.js, Snipcart, and Directus. I’ll even throw in an open source code repo & live demo. :)

First, let’s try to understand how API-first CMS can add value to your workflow.

“API” still sound like a kind of beer to you? Read this smooth primer first.

What is an API-first, headless CMS? Why use one?

Like traditional content management systems, API-first CMS let users manage content through a web UI. So how do they differ?

API-first CMS allow developers to decouple content management from content rendering. A coupled CMS, like WordPress, takes care of both: content is stored in a backend database AND rendered in frontend templates using HTML/CSS. So the “head” that’s missing from a headless CMS is actually that final “presentation layer”:

Unlike a traditional CMS, an API-first CMS exposes its content data via a consumable API.

Your headless CMS isn’t concerned about how you choose to display content. It pushes raw content (e.g. JSON or XML) for you to fetch and display anywhere: mobile app, static site, web app, desktop app, IoT device… or all of these at once!

api-first-cms-headless-architecture

Headless CMS architecture

So why have they become popular? Why are companies like the NY Times, Lenovo, Spotify, Nike, Apple, Microsoft & New Relic using them?

Because the web has evolved! Frontend tooling & frameworks have exploded. Traditional CMS have become limited in how they display content and are prone to many security exploitsCross-platform content management has become essential to many projects. Static site generators have resurfaced, opening a content management gap API-first CMS could fill, saving non-technical folks from editing Markdown files.

We have many tools and channels to build digital experiences today.

With headless CMS, content can seamlessly follow different forms, not be limited by one.

API-first CMS: Benefits

  • Organizations save time & money: reduction of overhead for cross-platform content management.
  • Developers get more freedom: ditching CMS templates makes for authentic UX. Fewer worries about backend scalability and maintenance.
  • Content is future-proof: reduced impact of migrations & re-designs since content is decoupled from frontend.
  • In some cases, more performance: content is pre-baked and ready to be served.

API-first CMS make for a clear separation of concerns which enhances developer productivity. They foster a technology-agnostic approach to development that resonates with our own product’s values. If you’re interested, we have an in-depth tutorial on decoupling data with Vue.js in the frontend.

Drawbacks

Most potential drawbacks (supporting user permissions, multi-languages, etc.) have already been solved. Still, a few potential issues worth mentioning:

  • Might be overkill for a simple website project.
  • Might not provide responsive UI for on-the-go content management.
  • Might not support website tree architecture for content navigation.
  • Might be expensive for client budget.

#api #cms #api-first #headless cms #open -source