# Protecting URIs with OAuth2

**URL:** <https://www.ruby-forum.com/t/protecting-uris-with-oauth2/239080>\
**Category:** NGINX\
**Created:** [February 11, 2014, 6:33am UTC](https://www.ruby-forum.com/t/protecting-uris-with-oauth2/239080 "2014-02-11T06:33:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Detlef\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/58f4c7/32.png) [@Detlef\_R](https://www.ruby-forum.com/u/Detlef_R)\
**Post date:** [February 11, 2014, 6:33am UTC](https://www.ruby-forum.com/t/protecting-uris-with-oauth2/239080/1 "2014-02-11T06:33:04Z")

</div>

Hi

Does anyone know how to protect an URI with OAuth authentication? the  
upstream sever is already capable of issuing new tokens, but I’m hoping  
that  
nginx can check the access token for certain URIs.

Thanks!

Posted at Nginx Forum:

> **[Protecting URIs with OAuth2](https://forum.nginx.org/read.php?2,247374,247374#msg-247374)**
>
> Hi Does anyone know how to protect an URI with OAuth authentication? the upstream sever is already capable of issuing new tokens, but I'm hoping that nginx can check the access token for certain URIs. Thanks!

---

<div class="post-metadata">

**Author:** ![kate\_r](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/c57346/32.png) [@kate\_r](https://www.ruby-forum.com/u/kate_r)\
**Post date:** [February 11, 2014, 1:33pm UTC](https://www.ruby-forum.com/t/protecting-uris-with-oauth2/239080/2 "2014-02-11T13:33:18Z")

</div>

On 11 Feb 2014 06:33, “kate\_r” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi
> 
> Does anyone know how to protect an URI with OAuth authentication? the  
> upstream sever is already capable of issuing new tokens, but I’m hoping  
> that  
> nginx can check the access token for certain URIs.

In my experience, you can easily use nginx to pass the request to an  
auth-only app which then tells nginx from where to serve the  
success/failure response. I haven’t seen a uncomplicated way of getting  
nginx itself to do the auth entirely.

I suppose you could write an oauth implementation in lua/perl/etc and  
embed  
it in nginx, but I’d personally argue that would be a mistake in most  
architectures.

J
