# Restrict Auth0 Lock to a Database Connection

**URL:** <https://community.auth0.com/t/restrict-auth0-lock-to-a-database-connection/7844>\
**Category:** Get Help\
**Tags:** auth0-lock, database, connection\
**Created:** [August 15, 2017, 2:07am UTC](https://community.auth0.com/t/restrict-auth0-lock-to-a-database-connection/7844 "2017-08-15T02:07:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![chris\_patten](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@chris\_patten](https://community.auth0.com/u/chris_patten)\
**Post date:** [August 15, 2017, 2:07am UTC](https://community.auth0.com/t/restrict-auth0-lock-to-a-database-connection/7844/1 "2017-08-15T02:07:48Z")

</div>

I am trying to use Auth0 Lock model and configure it to hit a certain database connection. I am doing the simple example but I don’t see any way to get that modal to create / authenticate users to specific Auth0 Database Connection. I have tried passing it in the allow connections setting but when passing the name in that setting they are not getting created in the DB provided by auth0. Any thoughts?

var lock = new Auth0Lock(‘myclientId’, ‘[mydomain.auth0.com](http://mydomain.auth0.com)’, {  
auth: {  
redirectUrl: ‘[https://mydomain.zendesk.com/access/saml](https://mydomain.zendesk.com/access/saml)’,  
responseType: ‘code’,  
params: {  
scope: ‘openid email’ // Learn about scopes: [Scopes - Auth0 Docs](https://auth0.com/docs/scopes)  
}  
},  
allowedConnections: ‘Username-Password-Authentication’],  
// Did not work…  
defaultDatabaseConnection: ‘mydatabaseName’  
});

---

<div class="post-metadata">

**Author:** ![ashish](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ashish/32/7056_2.png) [@ashish](https://community.auth0.com/u/ashish)\
**Post date:** [August 15, 2017, 10:08am UTC](https://community.auth0.com/t/restrict-auth0-lock-to-a-database-connection/7844/2 "2017-08-15T10:08:01Z")

</div>

To restrict Lock to use only one database connection you should only enable that particular database connection for the client.

`allowedConnections` only determines which connections to display in Lock. If you specify one or more database connections there it will determine whether or not to show the email/username and password fields.

`defaultDatabaseConnection` determines which connection to use by default if the client has enabled multiple database connections.

---

<div class="post-metadata">

**Author:** ![chris\_patten](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@chris\_patten](https://community.auth0.com/u/chris_patten)\
**Post date:** [August 15, 2017, 10:32pm UTC](https://community.auth0.com/t/restrict-auth0-lock-to-a-database-connection/7844/3 "2017-08-15T22:32:22Z")

</div>

Thank you, I got it working, way simpler than I was trying to make it. On a side note, does Auth0 limit on the number of Clients or Connections?

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [March 2, 2018, 5:55am UTC](https://community.auth0.com/t/restrict-auth0-lock-to-a-database-connection/7844/4 "2018-03-02T05:55:55Z")

</div>


