• 0

Securing an Azure Function App with OAUTH


Question

Hi, I'm looking at building an API in Azure - and that's an immovable, I am bound to Azure here for various reasons.

It seems the best way for me to achieve what I need is to use a Function App, so I've done this and created a very simple Hello World api.  Great... it works, pat on the back - I can follow a tutorial.

And to manage this very simple API, I am going to use an API Management Service - it can handle the traffic management and so on.  So yeah, got that set up too.

I'm a bit confused.  While the API Management Service exposes the API through a specific URL that applies all the benefits of the service, the "raw/native" url of the Function App still exists.  This seems a bit like... easily bypassed and any end user could just go to the original Function App url.  Am I missing something?

Anyhow yeah, so I have this all set up, but I want to secure it with OAUTH so that anyone calling this API has to authenticate and so on.  I believed that Azure API Management Service could do this for me, but I seem to be missing something.

Anyone here setup anything similar and able to guide me a little please?

I'm aware that this comes very close to consultation, so if that's the case, please do also feel free to discuss that via PM.

Thanks

4 answers to this question

Recommended Posts

  • 0

You can secure your Functions by using (and rotating) the App and Function Keys (configured through the Azure Portal), and you can also configure the firewall (under Networking) to disallow the general public from accessing it.

If there's a more "official" way to do it, I don't know what it us.

  • 0
On 28/01/2023 at 01:30, virtorio said:

You can secure your Functions by using (and rotating) the App and Function Keys (configured through the Azure Portal), and you can also configure the firewall (under Networking) to disallow the general public from accessing it.

If there's a more "official" way to do it, I don't know what it us.

Thanks.  My query was more about how to implement OAUTH2 against the app?

  • 0

Just done some googling.

Good idea to read up on Azure Active Directory: https://learn.microsoft.com/en-us/azure/active-directory/fundamentals/active-directory-whatis and 

 

Please see these links which relate to the use of OAUTH in AD:

 

https://scomnewbie.github.io/posts/authenticatedazfunc/

 

Hope this helps, and is what you're looking for? 

 

I'm afraid I don't have experience with Azure, however I'm a massive googler in my day-to-day job as a professional software developer! When I struggle to find the information I need via documentation, I've always found it helpful to watch youtube videos!

  • 0

I think you may have a misconception about OAUTH...  OAUTH is an authorization method, not an authentication method.

In  a nutshell, if you have ever visited a site that you want to become a member of, and instead of creating your own userid and password, you click a button that says login with Amazon or Login with Facebook, or Login with Google... and you use a pre-established account from one of those services which has already done the authentication, and now you are only authorizing that account the privilege of now using an additional site/service.

This is exactly what OAUTH is.  This is usually applied to your front end...

 

It sounds to me what you want to do is make your back end api private and only usable with your front end... ("the "raw/native" url of the Function App still exists.  This seems a bit like... easily bypassed and any end user could just go to the original Function App url.  Am I missing something?")

There are usually only 2 ways to do this... you either make it available only on your internal network

OR

you need to require a security token as part of the API request paremeters and reject all calls that do not contain it and reject all calls with a submitted token which is invalid...

How you generate and validate those tokens is up to you... (Cryptography hashes?)

 

Also you need to properly implement CORS policies within your http headers to prevent false/fake front ends from using your API.

https://stackoverflow.com/questions/54369416/how-to-secure-own-backend-api-which-serves-only-my-frontend

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Posts

    • Samsung Galaxy Z Fold 8, Flip 8, Z Fold Wide: Everything you need to know The ONLY thing I need to know is the price, which I know will be way higher than I (and most people) are willing to pay for a phone... so basically nothing here I need to know. PS: Nice job getting that Apple reference to a non-existent and unrevealed product as "competition" in there. Cheque is in the mail.
    • Well I really think the repasting helped if your higher clocks have returned, maybe the next thing to look at is if there is a problem with your case airflow? I guess this because your 3080 has returned to optimal state, but is still staying too warm, which might suggest it was thermal throttling before you repasted, of which the only logical conclusion could be outside factors.
    • Samsung Galaxy Z Fold 8, Flip 8, Z Fold Wide: Everything you need to know by Hamid Ganji Galaxy Z Fold 7 - Image via Samsung The next generation of Samsung foldables is set to be unveiled next month at the second Unpacked event of the year. Samsung’s 2026 foldables are not expected to offer significant upgrades over their predecessors, with the Korean firm instead focusing on design refinements and conventional upgrades such as faster processors and better cameras. However, Samsung is reportedly planning to unveil an all-new passport-style foldable this year to rival Apple’s first foldable iPhone, which is expected to debut this September. Here’s a roundup of everything we know about Samsung’s upcoming foldable devices ahead of their official debut. When can we expect Samsung’s new foldables? The Galaxy Z Fold 7 and Z Flip 7 series were unveiled in July, and Samsung is expected to maintain this timeframe in 2026. Based on previous reports from Korean sources, Samsung will hold its Unpacked event on July 22 in London, UK, to pull back the curtain on the Galaxy Z Fold 8 series. The devices are also expected to hit the shelves a few weeks after launch. However, Samsung has yet to announce an official date. A new naming scheme? One of the most interesting changes we might see this year is a new naming scheme for Samsung’s latest foldables. SamMobile reported that since Samsung is expected to unveil three foldables this year, it has adopted a new naming strategy to simplify product identification for customers. Accordingly, the standard Galaxy Z Fold 8 will reportedly be called the Galaxy Z Fold 8 Ultra and will serve as the direct successor to last year’s Galaxy Z Fold 7. The “Ultra” suffix suggests the phone could feature higher-end specifications, such as additional rear camera modules. Samsung’s new passport-style foldable is expected to carry the Galaxy Z Fold 8 name without any suffix. This model is reportedly equipped with two rear cameras. No major changes are expected for the Flip model. Galaxy Z Fold 8 Ultra and Z Flip 8 anticipated specs Rumors over the past few months suggest Samsung is preparing several upgrades for its upcoming foldables, although the devices may continue to rely on larger batteries and faster charging speeds rather than dramatic design changes. The primary focus this year is expected to be the Galaxy Z Fold 8 and its wide-screen design. Galaxy Z Fold 8 Ultra official CAD renders - Image via AndroidHeadlines Here are the anticipated specifications for the Galaxy Z Fold 8 Ultra based on previous leaks: 6.5-inch outer display and 8-inch inner display, 120Hz refresh rate, and 2,600 nits peak brightness Snapdragon 8 Elite Gen 5 processor, paired with 12GB or 16GB of RAM and 256GB, 512GB, or 1TB of storage 4.1mm thickness when unfolded and a weight of 210g 200MP main camera, 50MP ultrawide camera, 10MP or 12MP telephoto camera, 10MP cover camera, and 10MP selfie camera 5,000mAh battery with 45W wired charging Android 17 and One UI 9 As for the Galaxy Z Flip 8, the device is not expected to be a major departure from its predecessor, although it could become slightly slimmer. Expected specifications include: Snapdragon 8 Elite Gen 5 or Exynos 2600 processor 12GB of RAM with 256GB and 512GB storage options 6.9-inch Dynamic AMOLED 2X inner dispaly and 4.1-inch Super AMOLED outer dispaly 50MP main camera, 12MP ultrawide camera, and 10MP selfie camera 4,300mAh battery with 25W wired charging Android 17 and One UI 9 Samsung’s foldables are also expected to launch with Gemini Intelligence, Google’s AI suite for automating tasks in Android ecosystem. Moreover, given current memory and component costs, some Galaxy Z Fold 8 Ultra and Z Flip 8 variants could see a price hike. Galaxy Z Fold 8 adopts a wide-screen design The centerpiece of the upcoming Unpacked event could be the Galaxy Z Fold 8, previously rumored as the Galaxy Z Fold Wide. This model adopts a passport-style form factor and is expected to compete directly with Apple’s iPhone Fold. Galaxy Z Fold 8 official CAD renders - Image via AndroidHeadlines Here’s what to expect: 7.6-inch primary OLED display and 5.4-inch cover display, 120Hz refresh rate, 2,600 nits peak brightness, and 4:3 aspect ratio Snapdragon 8 Elite Gen 5 processor, 12GB or 16GB of RAM, and 256GB, 512GB, or 1TB storage options 4,800mAh battery with 45W wired charging 50MP main camera, 50MP ultrawide camera, and 10MP selfie camera Android 17 and One UI 9 The three new foldable phones are unlikely to be the only devices unveiled at Samsung’s Unpacked event. The company is also expected to introduce the Galaxy Watch Ultra 2 and the Galaxy Watch 9 series.
    • Thanks
  • Recent Achievements

    • Week One Done
      rolfus earned a badge
      Week One Done
    • One Month Later
      Leroy Jethro Gibbs earned a badge
      One Month Later
    • Conversation Starter
      flexorcist earned a badge
      Conversation Starter
    • One Month Later
      AndreaB earned a badge
      One Month Later
    • One Month Later
      agatameier earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      504
    2. 2
      +Edouard
      196
    3. 3
      PsYcHoKiLLa
      140
    4. 4
      ATLien_0
      88
    5. 5
      Steven P.
      81
  • Tell a friend

    Love Neowin? Tell a friend!