# Enable authentication only at specific endpoint

**URL:** <https://discuss.konghq.com/t/enable-authentication-only-at-specific-endpoint/2563>\
**Category:** Questions\
**Created:** [January 4, 2019, 6:47am UTC](https://discuss.konghq.com/t/enable-authentication-only-at-specific-endpoint/2563 "2019-01-04T06:47:19Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Timotius\_Pamungkas](https://avatars.discourse-cdn.com/v4/letter/t/3bc359/32.png) [@Timotius\_Pamungkas](https://discuss.konghq.com/u/Timotius_Pamungkas)\
**Post date:** [January 4, 2019, 6:47am UTC](https://discuss.konghq.com/t/enable-authentication-only-at-specific-endpoint/2563/1 "2019-01-04T06:47:19Z")

</div>

Can you give me example?

I have service `service-alpha` with Kong route : `/alpha`  
Inside of `service-alpha`, there are two endpoints

- `[GET] /api/v1/read` which require no authentication. With Kong, this will be [http://kong/alpha/api/v1/read](http://kong/alpha/api/v1/read)
- `[POST] /api/v1/create` which require no API Key authentication. With Kong, this will be [http://kong/alpha/api/v1/create](http://kong/alpha/api/v1/create)

The alpha services refer to upstream `http://myserver:9001`

I set two routes on service `alpha`:

- `/alpha` with no auth plugin
- `/alpha/api/v1/read` with api key plugin

However, accessing `/alpha/api/v1/read` is equals to accessing `http://myserver:9001`.

How can I set Kong to enable authentication only to `/create` What route configuration that correct?

---

<div class="post-metadata">

**Author:** ![jeremyjpj0916](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/jeremyjpj0916/32/1388_2.png) [@jeremyjpj0916](https://discuss.konghq.com/u/jeremyjpj0916)\
**Post date:** [January 4, 2019, 5:40pm UTC](https://discuss.konghq.com/t/enable-authentication-only-at-specific-endpoint/2563/2 "2019-01-04T17:40:11Z")

</div>

Well you could do

1. service service1 : [http://myserver:9001/api/v1/read](http://myserver:9001/api/v1/read) , route: /alpha/api/v1/read (no plugin)
2. service: service2 : [http://myserver:9001/api/v1/create](http://myserver:9001/api/v1/create) , route /alpha/api/v1/create (plugin)

My minds all over the place, so maybe a more efficient pattern is possible too though.

---

<div class="post-metadata">

**Author:** ![p0pr0ck5](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/p0pr0ck5/32/987_2.png) [@p0pr0ck5](https://discuss.konghq.com/u/p0pr0ck5)\
**Post date:** [January 4, 2019, 5:42pm UTC](https://discuss.konghq.com/t/enable-authentication-only-at-specific-endpoint/2563/3 "2019-01-04T17:42:06Z")

</div>

Since more than one Route can be associated with a Service, it would be simpler to create a single Service with the two Routes/one Plugin noted above.

---

<div class="post-metadata">

**Author:** ![jeremyjpj0916](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/jeremyjpj0916/32/1388_2.png) [@jeremyjpj0916](https://discuss.konghq.com/u/jeremyjpj0916)\
**Post date:** [January 4, 2019, 5:46pm UTC](https://discuss.konghq.com/t/enable-authentication-only-at-specific-endpoint/2563/4 "2019-01-04T17:46:55Z")

</div>

Ah yes, and then just let wild carding do the rest to ensure it goes to the right back-end location. Much better 🙂 .

---

<div class="post-metadata">

**Author:** ![thibaultcha](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/thibaultcha/32/340_2.png) [@thibaultcha](https://discuss.konghq.com/u/thibaultcha)\
**Post date:** [January 5, 2019, 7:38pm UTC](https://discuss.konghq.com/t/enable-authentication-only-at-specific-endpoint/2563/5 "2019-01-05T19:38:51Z")

</div>

It’s almost as if the good old API entity was split into Routes and Services precisely for this use case! 😂

---

<div class="post-metadata">

**Author:** ![Timotius\_Pamungkas](https://avatars.discourse-cdn.com/v4/letter/t/3bc359/32.png) [@Timotius\_Pamungkas](https://discuss.konghq.com/u/Timotius_Pamungkas)\
**Post date:** [January 8, 2019, 5:56am UTC](https://discuss.konghq.com/t/enable-authentication-only-at-specific-endpoint/2563/6 "2019-01-08T05:56:44Z")

</div>

What wildcard?  
In your example above, is that means if I have 10 endpoints, I have to create 10 routes?  
Seems ineffficient

---

<div class="post-metadata">

**Author:** ![jeremyjpj0916](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/jeremyjpj0916/32/1388_2.png) [@jeremyjpj0916](https://discuss.konghq.com/u/jeremyjpj0916)\
**Post date:** [January 8, 2019, 6:04am UTC](https://discuss.konghq.com/t/enable-authentication-only-at-specific-endpoint/2563/7 "2019-01-08T06:04:49Z")

</div>

Kong supports wild carding, meaning you make a Kong route like this:

/api/test

Then someone actually calls the route like this:

/api/test/myservice/1

And you have a Kong service set to [http://company.com](http://company.com),

Then the Backend service url after Kong proxies is: [http://company.com/myservice/1](http://company.com/myservice/1)

---

<div class="post-metadata">

**Author:** ![Timotius\_Pamungkas](https://avatars.discourse-cdn.com/v4/letter/t/3bc359/32.png) [@Timotius\_Pamungkas](https://discuss.konghq.com/u/Timotius_Pamungkas)\
**Post date:** [January 8, 2019, 6:15am UTC](https://discuss.konghq.com/t/enable-authentication-only-at-specific-endpoint/2563/8 "2019-01-08T06:15:54Z")

</div>

OK, got the way

service 1 : alpha, route `/alpha` (no plugin)  
service 2 : alpha-secure, route `/alpha/api/v1/create` (with plugin)

Thanks
