Skip to content

Commit 9cab53d

Browse files
committed
Support setting a custom tenant ID for OAuth2 (fix #1)
1 parent 3438793 commit 9cab53d

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,10 @@ Role Variables
187187
* `use_custom_urls`
188188
Whether to use custom URLs if `provider` is `github`, `gitlab` or `gitea`.
189189
Defaults to `false`.
190+
* `custom_tenant_id`
191+
A custom Tenant ID for OAuth2 endpoint (cf. `use_custom_urls`).
192+
Optional.
193+
Only works on Gitea 1.19.0 an newer.
190194
* `custom_auth_url`
191195
A custom Authorization URL (cf. `use_custom_urls`).
192196
Optional.

library/gitea_auth.py

+9
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@
7878
type: str
7979
required: False
8080
default: /etc/gitea/app.ini
81+
custom_tenant_id:
82+
description:
83+
- Use custom Tenant ID for OAuth endpoints
84+
- Only used if I(type) is C(oauth) and I(state) is C(present).
85+
type: str
86+
required: False
8187
custom_auth_url:
8288
description:
8389
- Use a custom Authorization URL (option for GitLab/GitHub).
@@ -332,6 +338,7 @@ def run_module():
332338
client_id=dict(type='str'),
333339
client_secret=dict(type='str', no_log=True),
334340
config=dict(type='str', default='/etc/gitea/app.ini'),
341+
custom_tenant_id=dict(type='str'),
335342
custom_auth_url=dict(type='str'),
336343
custom_email_url=dict(type='str'),
337344
custom_profile_url=dict(type='str'),
@@ -442,6 +449,8 @@ def run_module():
442449
cmd += ['--auto-discover-url', module.params['auto_discover_url']]
443450
if module.params['use_custom_urls']:
444451
cmd += ['--use-custom-urls', str(module.params['use_custom_urls'])]
452+
if module.params['custom_tenant_id']:
453+
cmd += ['--custom-tenant-id', module.params['custom_tenant_id']]
445454
if module.params['custom_auth_url']:
446455
cmd += ['--custom-auth-url', module.params['custom_auth_url']]
447456
if module.params['custom_token_url']:

tasks/main.yml

+1
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@
232232
client_secret: "{{ provider.client_secret | default(omit) }}"
233233
auto_discover_url: "{{ provider.auto_discover_url | default(omit) }}"
234234
use_custom_urls: "{{ provider.use_custom_urls | default(omit) }}"
235+
custom_tenant_id: "{{ provider.custom_tenant_id | default(omit) }}"
235236
custom_auth_url: "{{ provider.custom_auth_url | default(omit) }}"
236237
custom_email_url: "{{ provider.custom_email_url | default(omit) }}"
237238
custom_profile_url: "{{ provider.custom_profile_url | default(omit) }}"

0 commit comments

Comments
 (0)