Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Add a check for duplicate IdP ids (#9184)
Browse files Browse the repository at this point in the history
  • Loading branch information
richvdh authored Jan 21, 2021
1 parent b5120f0 commit 42a8e81
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.d/9184.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Emit an error at startup if different Identity Providers are configured with the same `idp_id`.
11 changes: 11 additions & 0 deletions synapse/config/oidc_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# limitations under the License.

import string
from collections import Counter
from typing import Iterable, Optional, Tuple, Type

import attr
Expand Down Expand Up @@ -43,6 +44,16 @@ def read_config(self, config, **kwargs):
except DependencyException as e:
raise ConfigError(e.message) from e

# check we don't have any duplicate idp_ids now. (The SSO handler will also
# check for duplicates when the REST listeners get registered, but that happens
# after synapse has forked so doesn't give nice errors.)
c = Counter([i.idp_id for i in self.oidc_providers])
for idp_id, count in c.items():
if count > 1:
raise ConfigError(
"Multiple OIDC providers have the idp_id %r." % idp_id
)

public_baseurl = self.public_baseurl
self.oidc_callback_url = public_baseurl + "_synapse/oidc/callback"

Expand Down

0 comments on commit 42a8e81

Please sign in to comment.