# Restrict registration to specific authentication mechanism

**URL:** <https://discuss.openedx.org/t/restrict-registration-to-specific-authentication-mechanism/742>\
**Category:** Development\
**Created:** [October 22, 2019, 3:27pm UTC](https://discuss.openedx.org/t/restrict-registration-to-specific-authentication-mechanism/742 "2019-10-22T15:27:45Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![blarghmatey](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.openedx.org/blarghmatey/32/1632_2.png) [@blarghmatey](https://discuss.openedx.org/u/blarghmatey)\
**Post date:** [October 22, 2019, 3:27pm UTC](https://discuss.openedx.org/t/restrict-registration-to-specific-authentication-mechanism/742/1 "2019-10-22T15:27:45Z")

</div>

We are trying to set up our installation to rely on the SAML integration via the social-auth pipeline. The login and registration piece is functional, but in order to allow everything to operate it also enables public account creation via the login/registration form. We don’t want the general public to be able to create accounts on our installation, and instead rely on our SAML IDP as the source of truth for who can and cannot be on the platform.

From what I have been able to find, there is not currently any capability to restrict the allowed authentication mechanism for login/registration, meaning that it is not possible for the SAML integration to fully satisfy our needs. Has anyone done any work to lock down the allowed auth backend, and is there any plan to allow for this as a standard feature in the edX platform?

---

<div class="post-metadata">

**Author:** ![pdpinch](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.openedx.org/pdpinch/32/36_2.png) [@pdpinch](https://discuss.openedx.org/u/pdpinch)\
**Post date:** [October 23, 2019, 2:07pm UTC](https://discuss.openedx.org/t/restrict-registration-to-specific-authentication-mechanism/742/2 "2019-10-23T14:07:50Z")

</div>

Has anyone at OpenCraft or Racoon Gang dealt with this, like @jill or @RuslanSkiraRaccoonga ?

---

<div class="post-metadata">

**Author:** ![RuslanSkiraRaccoonga](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.openedx.org/ruslanskiraraccoonga/32/455_2.png) [@RuslanSkiraRaccoonga](https://discuss.openedx.org/u/RuslanSkiraRaccoonga)\
**Post date:** [October 23, 2019, 2:53pm UTC](https://discuss.openedx.org/t/restrict-registration-to-specific-authentication-mechanism/742/3 "2019-10-23T14:53:00Z")

</div>

1. in lms/envs/devstack.py -\> need to add FEATURES[‘ENABLE\_THIRD\_PARTY\_AUTH’] = True
2. [http://localhost:8000/admin/third\_party\_auth/oauth2providerconfig/add/](http://localhost:8000/admin/third_party_auth/oauth2providerconfig/add/)  
2.1 Enable and Visible flags should be active

---

<div class="post-metadata">

**Author:** ![blarghmatey](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.openedx.org/blarghmatey/32/1632_2.png) [@blarghmatey](https://discuss.openedx.org/u/blarghmatey)\
**Post date:** [October 23, 2019, 3:08pm UTC](https://discuss.openedx.org/t/restrict-registration-to-specific-authentication-mechanism/742/4 "2019-10-23T15:08:16Z")

</div>

Thank you for following up, but the problem isn’t currently with getting the SAML login working, the problem is that in order to get it functional it also opens up public account creation for anyone who uses the registration form or the API. We want to set things up so that SAML is the _only_ way to log in or create an account.

---

<div class="post-metadata">

**Author:** ![RuslanSkiraRaccoonga](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.openedx.org/ruslanskiraraccoonga/32/455_2.png) [@RuslanSkiraRaccoonga](https://discuss.openedx.org/u/RuslanSkiraRaccoonga)\
**Post date:** [October 23, 2019, 3:16pm UTC](https://discuss.openedx.org/t/restrict-registration-to-specific-authentication-mechanism/742/5 "2019-10-23T15:16:35Z")

</div>

Unfortunately only hide the registration form and leave your loginbutton.  
I didn’t find other opportunities or build in functionality.

---

<div class="post-metadata">

**Author:** ![blarghmatey](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.openedx.org/blarghmatey/32/1632_2.png) [@blarghmatey](https://discuss.openedx.org/u/blarghmatey)\
**Post date:** [October 23, 2019, 3:58pm UTC](https://discuss.openedx.org/t/restrict-registration-to-specific-authentication-mechanism/742/6 "2019-10-23T15:58:37Z")

</div>

Thank you for that feedback, I just wanted to make sure there wasn’t something that I had missed.

---

<div class="post-metadata">

**Author:** ![viadanna](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.openedx.org/viadanna/32/276_2.png) [@viadanna](https://discuss.openedx.org/u/viadanna)\
**Post date:** [October 25, 2019, 10:23pm UTC](https://discuss.openedx.org/t/restrict-registration-to-specific-authentication-mechanism/742/7 "2019-10-25T22:23:31Z")

</div>

> [@blarghmatey](#):
>
> We don’t want the general public to be able to create accounts on our installation, and instead rely on our SAML IDP as the source of truth for who can and cannot be on the platform.

You’ll have to modify `/edx/etc/lms.yml` with:

```auto
"FEATURES": {
...
  "ALLOW_PUBLIC_ACCOUNT_CREATION" : false
}

```

This will remove the REGISTER button from the [templates](https://github.com/edx/edx-platform/blob/2fc27a9caa4ddc803906b306beac971da48dd2fa/lms/templates/header/navbar-not-authenticated.html#L19) and make sure the [user api doesn’t not accept](https://github.com/edx/edx-platform/blob/b92c30de10efa55dac84ad1cc8a1ed8f021cc2cc/openedx/core/djangoapps/user_api/accounts/api.py#L378-L382) an user create request.

---

<div class="post-metadata">

**Author:** ![blarghmatey](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.openedx.org/blarghmatey/32/1632_2.png) [@blarghmatey](https://discuss.openedx.org/u/blarghmatey)\
**Post date:** [October 26, 2019, 4:11pm UTC](https://discuss.openedx.org/t/restrict-registration-to-specific-authentication-mechanism/742/8 "2019-10-26T16:11:42Z")

</div>

Unfortunately it’s not so simple as that. In order for the SAML integration to be able to create new users that flag needs to be set to True, which is what then puts us in the situation of needing to restrict which authentication methods are allowed to create the accounts. Thank you for the input though!

---

<div class="post-metadata">

**Author:** ![jill](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.openedx.org/jill/32/3188_2.png) [@jill](https://discuss.openedx.org/u/jill)\
**Post date:** [October 27, 2019, 1:05am UTC](https://discuss.openedx.org/t/restrict-registration-to-specific-authentication-mechanism/742/9 "2019-10-27T01:05:40Z")

</div>

@blarghmatey There’s a feature called [Hinted Sign In](https://github.com/edx/edx-documentation/blob/master/en_us/install_operations/source/configuration/tpa/tpa_advanced_features.rst#hinted-sign-in) which should help you here. When Hinted Sign In is enabled, the login/registration pages to automatically redirect to the indicated authentication provider, so nobody gets to see those pages without going through your provider first.

Originally, this “hint” had to be made by adding an extra parameter to the `/login` or `/register` page links (see [docs](https://github.com/edx/edx-documentation/blob/master/en_us/install_operations/source/configuration/tpa/tpa_advanced_features.rst#hinted-sign-in)). You can test this by adding `?tpa_hint=saml-providerslug` to the end of your LMS `/login` or `/registration` URL, where `providerslug` is the “Slug” value you assigned your Provider Configuration (SAML IdP).

We contributed a feature with Ginkgo which makes it possible to enforce this “hinting” for every hit to your login/registration pages without having to change the links (cf [edx-platform#15587](https://github.com/edx/edx-platform/pull/15587)).

Steps:

1. Login to your LMS Django Admin as a superuser.
2. Locate the Site Configuration, and add or update the entry for your LMS site.
3. Set `THIRD_PARTY_AUTH_HINT`, e.g.

```auto
{
   "THIRD_PARTY_AUTH_HINT": "saml-providerslug"
}

```

The Site Configuration value describes a JSON Object, so it’s fussy about the format. See [JSON structures :: Object](https://www.w3resource.com/JSON/structures.php) if you have trouble getting your changes to save.
4. Wait 3 minutes for the site configuration cache to clear.
5. Logout, and visit your LMS’s normal `/login` or `/register` page, and watch it redirect to your SAML provider.

Alternatively, you can use `settings.FEATURES.THIRD_PARTY_AUTH_HINT`, but it’s nice to be able to do this with Site Configuration, so you don’t have to restart (or redeply) your whole LMS to make the change.

---

<div class="post-metadata">

**Author:** ![slunav](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.openedx.org/slunav/32/2667_2.png) [@slunav](https://discuss.openedx.org/u/slunav)\
**Post date:** [July 13, 2021, 1:18pm UTC](https://discuss.openedx.org/t/restrict-registration-to-specific-authentication-mechanism/742/10 "2021-07-13T13:18:45Z")

</div>

Hi,

I just deployed koa with tutor and bumped into the same issue and reported my findings in:

> [@API to link Open edX account with the account on third party authentication providers](https://discuss.openedx.org/t/api-to-link-open-edx-account-with-the-account-on-third-party-authentication-providers/566/6):
>
> Hi, I just deployed koa with tutor and bumped into the same issue. It turns out that local accounts are required: [https://edx.readthedocs.io/projects/edx-installing-configuring-and-running/en/open-release-koa.master/configuration/tpa/tpa\_behavior.html](https://edx.readthedocs.io/projects/edx-installing-configuring-and-running/en/open-release-koa.master/configuration/tpa/tpa_behavior.html) I hope it helps. Best regards, Sebastian

Best regards,  
Sebastian
