Skip to content

Commit e89e0c5

Browse files
committed
iam: opt-in anonymous self-registration
The anonymous token carries no permissions by design (gcl_iam AnonDriver), so public sign-up via the console register page is impossible through permission bindings. Gate it on an explicit [iam] allow_self_registration option (default false): when set, an anon token may create IAM users.
1 parent 4340ca7 commit e89e0c5

2 files changed

Lines changed: 23 additions & 4 deletions

File tree

exordos_core/cmd/user_api.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,14 @@
6363
default=c.DEFAULT_HS256_JWKS_ENCRYPTION_KEY,
6464
help="Encryption key for HS256 JWKS secret (A256GCM, 32 bytes)",
6565
),
66+
cfg.BoolOpt(
67+
"allow_self_registration",
68+
default=False,
69+
help="Allow anonymous requests to create IAM users (public "
70+
"sign-up, e.g. the ecosystem console register page). The "
71+
"anonymous token carries no permissions by design, so "
72+
"without this option registration is admin-only.",
73+
),
6674
]
6775

6876

exordos_core/user_api/iam/api/controllers.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
from gcl_iam.api import controllers as iam_controllers
2929
from gcl_iam.api import field_perms as iam_fp
3030
import jinja2
31+
from oslo_config import cfg
3132
import pyotp
3233
from restalchemy.api import actions
3334
from restalchemy.api import constants as ra_c
@@ -183,11 +184,21 @@ def get(self, uuid, **kwargs):
183184
return super().get(uuid, **kwargs)
184185

185186
def create(self, **kwargs):
186-
self.enforce(
187-
c.PERMISSION_USER_CREATE,
188-
do_raise=True,
189-
exc=iam_e.CanNotCreateUser,
187+
# The anonymous token carries no permissions by design (see
188+
# gcl_iam AnonDriver), so public sign-up is impossible via
189+
# permission bindings alone; it is an explicit installation
190+
# choice instead ([iam] allow_self_registration).
191+
ctx = contexts.get_context()
192+
is_anon_signup = (
193+
ctx.iam_context.token_info.token_type == "anon"
194+
and cfg.CONF["iam"].allow_self_registration
190195
)
196+
if not is_anon_signup:
197+
self.enforce(
198+
c.PERMISSION_USER_CREATE,
199+
do_raise=True,
200+
exc=iam_e.CanNotCreateUser,
201+
)
191202
self.validate_secret(kwargs)
192203
kwargs.pop("email_verified", None)
193204
user = super().create(**kwargs)

0 commit comments

Comments
 (0)