# 2 KongConsumer for apikey authentication for 1 service with different path

**URL:** <https://discuss.konghq.com/t/2-kongconsumer-for-apikey-authentication-for-1-service-with-different-path/9013>\
**Category:** General\
**Tags:** kubernetes\
**Created:** [September 8, 2021, 12:26am UTC](https://discuss.konghq.com/t/2-kongconsumer-for-apikey-authentication-for-1-service-with-different-path/9013 "2021-09-08T00:26:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![zhengliu](https://avatars.discourse-cdn.com/v4/letter/z/bc8723/32.png) [@zhengliu](https://discuss.konghq.com/u/zhengliu)\
**Post date:** [September 8, 2021, 12:26am UTC](https://discuss.konghq.com/t/2-kongconsumer-for-apikey-authentication-for-1-service-with-different-path/9013/1 "2021-09-08T00:26:59Z")

</div>

Hi,  
I am a new beginner of kong for kubernetes and for my case that i need to create 2 consumers and use these 2 consumers with 1 service but with different kong url, like one with /a and one with /b. so how can i use these 2 Kongconsumer for the apikey authentication?

For example, i deploy a simple service echo. And then create an ingress  
apiVersion: extensions/v1beta1  
kind: Ingress  
metadata:  
name: demo  
annotations:  
[kubernetes.io/ingress.class:](http://kubernetes.io/ingress.class:) kong  
spec:  
rules:

- http:  
paths:
  - path: /foo  
backend:  
serviceName: echo  
servicePort: 80
  - path: /hoo  
backend:  
serviceName: echo  
servicePort: 80

## for example the key and consumer setup. apiVersion: v1 kind: Secret metadata: name: ’ my-secret’ stringData: kongCredType: ‘key-auth’ key: mytestkey

## apiVersion: [configuration.konghq.com/v1](http://configuration.konghq.com/v1) kind: KongPlugin metadata: name: echo-auth plugin: key-auth

apiVersion: [configuration.konghq.com/v1](http://configuration.konghq.com/v1)  
kind: KongConsumer  
metadata:  
name: ‘my-consumer’  
annotations:  
[kubernetes.io/ingress.class:](http://kubernetes.io/ingress.class:) kong  
username: ‘my-user’  
credentials:

- my-secret

* * *

## apiVersion: v1 kind: Secret metadata: name: ’ my-secret1’ stringData: kongCredType: ‘key-auth’ key: mytestkey1

apiVersion: [configuration.konghq.com/v1](http://configuration.konghq.com/v1)  
kind: KongConsumer  
metadata:  
name: ‘my-consumer1’  
annotations:  
[kubernetes.io/ingress.class:](http://kubernetes.io/ingress.class:) kong  
username: ‘my-user1’  
credentials:

- my-secret1

So i can access it by both /foo and /hoo, then i want to use the KongConsumer to do the auth apikey check for /foo and use kongconsumer1 to do the auth apikey check for /hoo, then what should I do?  
Thanks.

---

<div class="post-metadata">

**Author:** ![fomm](https://avatars.discourse-cdn.com/v4/letter/f/ea666f/32.png) [@fomm](https://discuss.konghq.com/u/fomm)\
**Post date:** [September 8, 2021, 1:50am UTC](https://discuss.konghq.com/t/2-kongconsumer-for-apikey-authentication-for-1-service-with-different-path/9013/2 "2021-09-08T01:50:00Z")

</div>

From what you described so far, it seems you want to allow consumer1 to access `/foo` and consumer2 to access `/hoo` only, is that right?

If that’s true, you need to add ACL plugin.

---

<div class="post-metadata">

**Author:** ![zhengliu](https://avatars.discourse-cdn.com/v4/letter/z/bc8723/32.png) [@zhengliu](https://discuss.konghq.com/u/zhengliu)\
**Post date:** [September 8, 2021, 2:35am UTC](https://discuss.konghq.com/t/2-kongconsumer-for-apikey-authentication-for-1-service-with-different-path/9013/3 "2021-09-08T02:35:45Z")

</div>

Thank you for the info. If possible can you guide me how to set it with acl? Can you please create an example for it? Thanks.

---

<div class="post-metadata">

**Author:** ![fomm](https://avatars.discourse-cdn.com/v4/letter/f/ea666f/32.png) [@fomm](https://discuss.konghq.com/u/fomm)\
**Post date:** [September 8, 2021, 2:10pm UTC](https://discuss.konghq.com/t/2-kongconsumer-for-apikey-authentication-for-1-service-with-different-path/9013/4 "2021-09-08T14:10:34Z")

</div>

I believe the best learning method is by exploring docs and do the tests yourself.

Please have a look at the [official doc](https://docs.konghq.com/hub/kong-inc/acl/) first. If you can’t get it to work, please share what you’ve tried and people can help you.

---

<div class="post-metadata">

**Author:** ![zhengliu](https://avatars.discourse-cdn.com/v4/letter/z/bc8723/32.png) [@zhengliu](https://discuss.konghq.com/u/zhengliu)\
**Post date:** [September 10, 2021, 11:19am UTC](https://discuss.konghq.com/t/2-kongconsumer-for-apikey-authentication-for-1-service-with-different-path/9013/5 "2021-09-10T11:19:12Z")

</div>

Thank you. It works now. 🙂
