Protecting API Access with BIG-IP using OAuth

Protecting API Access with BIG-IP using OAuth

As more organizations use APIs in their systems, they've become targets for the not-so-good-doers so API Security is something you need to take seriously. Most APIs today use the HTTP protocol so organizations should protect them as they would ordinary web properties.

Starting in v13, BIG-IP APM is able to act as an OAuth Client, OAuth Resource Server and OAuth Authorization Server. In this example, we will show how to use BIG-IP APM to act as an OAuth Resource Server protecting the API.

In our environment, we’ve published an API (api.f5se.com) and we’re trying to get a list of departments in the HR database. The API is not natively protected and we want APM to enable OAuth protection to this API.

First, let’s try an unauthenticated request.

You can see we get the 401 Unauthorized response which is coming from the BIG-IP. In this instance we’re only sending 3 headers, Connection (close), Content Length (0) and WWW Authenticate (Bearer), indicating to the client that it wants Bearer Token authentication.

So we’ll get that authorization and a new access token.

Here the Getpostman.com (Postman toolchain for API developers) is preconfigured to get a new access token from the OAuth authorization server, which is a BIG-IP. 

We will request the OAuth token and will need to authenticate to the BIG-IP.

After that, we get an authorization request. In this case, BIG-IP is acting as an Authorization server and is indicating to the resource owner (us) that there is a HR API application that wants to use certain information (about us) that the authorization server is going to provide. 

In this case, it is telling us that the resource server wants to get scope api-email.

We’ll click Authorize and now we have our auth token and is saved in the Postman client.

Within the token properties we see that it expires in 300 seconds, it is a Bearer token and the scope is api-email and we get a refresh token as well.

Now we can add this token to the header and try to make a request again. And this time, we get a much better response.

We get a 200 OK, along with the headers of the application server. We’ll click on the Body tab within Postman, we’ll see the XML that the API has returned in response to the query for the list of departments that are available. There were no cookies being returned by the server if you were wondering about that tab. In the Headers tab we see the Authorization header that was being sent and the content of the Bearer token.

A simple way to easily protect your APIs leveraging OAuth 2.0 Resource Server capabilities in BIG-IP.

Special thanks to Michael Koyfman for the basis of the content and check out his full demo here.

ps

Related:


To view or add a comment, sign in

More articles by Peter Silva

  • Grateful for 15 with F5

    Today marks 15 years with F5. That’s 28.

    16 Comments
  • Me:Recently

    (Or, How I Mandela’d Myself Back into a Job) Almost every week for over a decade, I’d tap some words out on a keyboard…

    38 Comments
  • DevCentral Showcase on LinkedIn

    We are excited to share our New LinkedIn Home! We're thrilled to be Showcased under F5's LinkedIn Company Page and look…

  • The DevCentral Chronicles July Edition 1(7)

    July is my favorite month due to it being both the middle of summer and I was born in July. This month I’ll drip of…

  • Calling All Conversations!

    Is what I wrote almost 10 years ago when F5 was rolling out some of our early social media channels as the medium…

  • DevCentral's Featured Member for July - Rhazi Youssef

    Our Featured Member series is a way for us to show appreciation and highlight active contributors in our community…

  • The DevCentral Chronicles June Edition 1(6)

    Heading into the summer months is always a nice time of year – school is out, warmer weather, BBQs, beaches, baseball…

  • DevCentral's Featured Member for June - Jie Gao

    Our Featured Member series is a way for us to show appreciation and highlight active contributors in our community…

  • The DevCentral Chronicles Volume 1, Issue 5

    Is it May already? Did you enjoy your ‘May the Fourth’ along with ‘Revenge of the Sixth’? For me, May is filled with a…

  • DevCentral's Featured Member for May - Jai Kumar

    Our Featured Member series is a way for us to show appreciation and highlight active contributors in our community…

    2 Comments

Others also viewed

Explore content categories