Skip to content

Commit 462367a

Browse files
authored
Merge pull request #155 from maykinmedia/feature/154-add-options-example-to-setup-config-documentation
📝 [#154] add options example to setup config documentation
2 parents 6966805 + 285687f commit 462367a

File tree

2 files changed

+40
-16
lines changed

2 files changed

+40
-16
lines changed

mozilla_django_oidc_db/setup_configuration/models.py

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class OIDCConfigProviderModel(ConfigurationModel):
7070
OIDCProvider,
7171
"identifier",
7272
description="a unique identifier for this OIDC provider.",
73-
examples=["admin-oidc-provider"],
73+
examples=["test-oidc-provider"],
7474
)
7575
endpoint_config: OIDCProviderConfigUnion
7676

@@ -95,12 +95,36 @@ class AdminOIDCConfigurationModelItem(ConfigurationModel):
9595

9696
enabled: bool = DjangoModelRef(OIDCClient, "enabled", default=True)
9797
oidc_rp_scopes_list: list[str] = DjangoModelRef(OIDCClient, "oidc_rp_scopes_list")
98-
options: dict = DjangoModelRef(OIDCClient, "options", default_factory=dict)
98+
options: dict = DjangoModelRef(
99+
OIDCClient,
100+
"options",
101+
default_factory=dict,
102+
examples=[
103+
{
104+
"user_settings": {
105+
"claim_mappings": {
106+
"username": ["sub"],
107+
"email": ["email"],
108+
"first_name": ["given_name"],
109+
"last_name": ["family_name"],
110+
},
111+
"username_case_sensitive": False,
112+
},
113+
"groups_settings": {
114+
"make_users_staff": True,
115+
"superuser_group_names": ["superuser"],
116+
"sync": True,
117+
"sync_pattern": "*",
118+
"claim_mapping": ["roles"],
119+
},
120+
}
121+
],
122+
)
99123

100124
endpoint_config: OIDCProviderConfigUnion | None = Field(
101125
description=_("Configuration for the OIDC Provider endpoints."),
102126
default=None,
103-
deprecated=True,
127+
deprecated="Moved to `providers.endpoint_config`",
104128
)
105129
oidc_provider_identifier: str = DjangoModelRef(
106130
OIDCProvider, "identifier", examples=["test-oidc-provider"], default=""
@@ -114,7 +138,7 @@ class AdminOIDCConfigurationModelItem(ConfigurationModel):
114138
"last_name": ["family_name"],
115139
},
116140
description=_("Mapping from User model field names to a path in the claim."),
117-
deprecated=True,
141+
deprecated="Moved to `items.options.user_settings.claim_mappings`",
118142
)
119143
oidc_token_use_basic_auth: bool = Field(
120144
default=False,
@@ -123,67 +147,67 @@ class AdminOIDCConfigurationModelItem(ConfigurationModel):
123147
"header when obtaining the access token. Otherwise, they are sent in the "
124148
"request body."
125149
),
126-
deprecated=True,
150+
deprecated="Moved to `providers.oidc_token_use_basic_auth`",
127151
)
128152
oidc_use_nonce: bool = Field(
129153
default=True,
130154
description=_("Controls whether the client uses nonce verification"),
131-
deprecated=True,
155+
deprecated="Moved to providers.oidc_use_nonce",
132156
)
133157
oidc_nonce_size: int = Field(
134158
default=32,
135159
description=_(
136160
"Sets the length of the random string used for nonce verification"
137161
),
138-
deprecated=True,
162+
deprecated="Moved to `providers.oidc_nonce_size`",
139163
)
140164
oidc_state_size: int = Field(
141165
default=32,
142166
description=_(
143167
"Sets the length of the random string used for state verification"
144168
),
145-
deprecated=True,
169+
deprecated="Moved to `providers.oidc_state_size`",
146170
)
147171
# Arrays are overridden to make the typing simpler (the underlying Django field is an ArrayField, which is non-standard)
148172
username_claim: list[str] = Field(
149173
default_factory=lambda: ["sub"],
150174
description=_("Path in the claims to the value to use as username."),
151-
deprecated=True,
175+
deprecated="Moved to `items.options.user_settings.claim_mappings.username`",
152176
examples=[["nested", "username", "claim"]],
153177
)
154178
groups_claim: list[str] = Field(
155179
default_factory=lambda: ["roles"],
156180
description=_("Path in the claims to the value with group names."),
157-
deprecated=True,
181+
deprecated="Moved to `items.options.group_settings.claim_mapping`",
158182
examples=[["nested", "group", "claim"]],
159183
)
160184
superuser_group_names: list[str] = Field(
161185
default_factory=list,
162186
description=_("Superuser group names"),
163-
deprecated=True,
187+
deprecated="Moved to `items.options.group_settings.superuser_group_names`",
164188
examples=[["superusers"]],
165189
)
166190
default_groups: list[str] = Field(
167191
default_factory=list,
168192
description=_("Default group names"),
169-
deprecated=True,
193+
deprecated="Moved `items.options.group_settings.default_groups`",
170194
examples=[["read-only-users"]],
171195
)
172196
sync_groups: bool = Field(
173197
description=_("Whether to sync local groups"),
174-
deprecated=True,
198+
deprecated="Moved to `items.options.group_settings.sync`",
175199
examples=[True],
176200
default=True,
177201
)
178202
sync_groups_glob_pattern: str = Field(
179203
description=_("Pattern that the group names to sync should follow."),
180-
deprecated=True,
204+
deprecated="Moved to `items.options.group_settings.sync_pattern`",
181205
examples=["*"],
182206
default="*",
183207
)
184208
make_users_staff: bool = Field(
185209
description=_("Whether to make the users staff."),
186-
deprecated=True,
210+
deprecated="Moved to `items.options.groups_settings.make_users_staff`",
187211
examples=[False],
188212
default=False,
189213
)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Changelog = "https://github.com/maykinmedia/mozilla-django-oidc-db/blob/master/C
4646

4747
[project.optional-dependencies]
4848
setup-configuration = [
49-
"django-setup-configuration>=0.8.2",
49+
"django-setup-configuration>=0.11.0",
5050
]
5151
tests = [
5252
"psycopg",

0 commit comments

Comments
 (0)