Skip to content

Commit 7939bcc

Browse files
authored
feat: show custom trusted publishers for org (#18914)
* feat: show custom trusted publishers for org Display only, non-interactive. Refs: #18842 * feat: custom trusted publishers events in history * feat: redact admin IP for events * chore: stop rendering commented code The code is waiting on whether user-facing org rename feature will be active. Until such time, no need to render and emit the contents of the commented code, so use a jinja comment instead. --------- Signed-off-by: Mike Fiedler <miketheman@gmail.com>
1 parent 36a5819 commit 7939bcc

File tree

5 files changed

+122
-54
lines changed

5 files changed

+122
-54
lines changed

tests/unit/admin/views/test_organizations.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1794,6 +1794,7 @@ def test_add_oidc_issuer_success(self, db_request, monkeypatch):
17941794
"issuer_type": "gitlab",
17951795
"issuer_url": "https://gitlab.company.com",
17961796
"submitted_by_user_id": str(admin_user.id),
1797+
"redact_ip": True,
17971798
},
17981799
)
17991800
]
@@ -1956,6 +1957,7 @@ def test_delete_oidc_issuer_success(self, db_request, monkeypatch):
19561957
"issuer_type": "gitlab",
19571958
"issuer_url": "https://gitlab.company.com",
19581959
"deleted_by_user_id": str(admin_user.id),
1960+
"redact_ip": True,
19591961
},
19601962
)
19611963
]

warehouse/admin/views/organizations.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,6 +1346,7 @@ def add_oidc_issuer(request):
13461346
"issuer_type": form.issuer_type.data.value,
13471347
"issuer_url": form.issuer_url.data,
13481348
"submitted_by_user_id": str(user_service.get_admin_user().id),
1349+
"redact_ip": True,
13491350
},
13501351
)
13511352

@@ -1404,6 +1405,7 @@ def delete_oidc_issuer(request):
14041405
"issuer_type": issuer.issuer_type.value,
14051406
"issuer_url": issuer.issuer_url,
14061407
"deleted_by_user_id": str(user_service.get_admin_user().id),
1408+
"redact_ip": True,
14071409
},
14081410
)
14091411

warehouse/locale/messages.pot

Lines changed: 73 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,9 +1225,8 @@ msgstr ""
12251225
#: warehouse/templates/manage/account.html:845
12261226
#: warehouse/templates/manage/manage_base.html:364
12271227
#: warehouse/templates/manage/manage_base.html:442
1228-
#: warehouse/templates/manage/organization/settings.html:205
1229-
#: warehouse/templates/manage/organization/settings.html:266
1230-
#: warehouse/templates/manage/organization/settings.html:272
1228+
#: warehouse/templates/manage/organization/settings.html:291
1229+
#: warehouse/templates/manage/organization/settings.html:297
12311230
#: warehouse/templates/manage/project/documentation.html:13
12321231
#: warehouse/templates/manage/project/release.html:209
12331232
#: warehouse/templates/manage/project/settings.html:78
@@ -3953,16 +3952,16 @@ msgid "Recent account activity"
39533952
msgstr ""
39543953

39553954
#: warehouse/templates/manage/account.html:784
3956-
#: warehouse/templates/manage/organization/history.html:175
3955+
#: warehouse/templates/manage/organization/history.html:193
39573956
#: warehouse/templates/manage/project/history.html:333
39583957
#: warehouse/templates/manage/team/history.html:87
39593958
#: warehouse/templates/manage/unverified-account.html:459
39603959
msgid "Event"
39613960
msgstr ""
39623961

39633962
#: warehouse/templates/manage/account.html:785
3964-
#: warehouse/templates/manage/organization/history.html:176
3965-
#: warehouse/templates/manage/organization/history.html:185
3963+
#: warehouse/templates/manage/organization/history.html:194
3964+
#: warehouse/templates/manage/organization/history.html:203
39663965
#: warehouse/templates/manage/project/history.html:334
39673966
#: warehouse/templates/manage/project/history.html:343
39683967
#: warehouse/templates/manage/team/history.html:88
@@ -3972,7 +3971,7 @@ msgid "Time"
39723971
msgstr ""
39733972

39743973
#: warehouse/templates/manage/account.html:786
3975-
#: warehouse/templates/manage/organization/history.html:177
3974+
#: warehouse/templates/manage/organization/history.html:195
39763975
#: warehouse/templates/manage/team/history.html:89
39773976
#: warehouse/templates/manage/unverified-account.html:461
39783977
msgid "Additional Info"
@@ -3984,13 +3983,13 @@ msgid "Date / time"
39843983
msgstr ""
39853984

39863985
#: warehouse/templates/manage/account.html:798
3987-
#: warehouse/templates/manage/organization/history.html:189
3986+
#: warehouse/templates/manage/organization/history.html:207
39883987
#: warehouse/templates/manage/unverified-account.html:472
39893988
msgid "Location Info"
39903989
msgstr ""
39913990

39923991
#: warehouse/templates/manage/account.html:801
3993-
#: warehouse/templates/manage/organization/history.html:192
3992+
#: warehouse/templates/manage/organization/history.html:210
39943993
#: warehouse/templates/manage/project/history.html:350
39953994
#: warehouse/templates/manage/team/history.html:104
39963995
#: warehouse/templates/manage/unverified-account.html:475
@@ -4040,8 +4039,7 @@ msgstr ""
40404039

40414040
#: warehouse/templates/manage/account.html:843
40424041
#: warehouse/templates/manage/account/token.html:177
4043-
#: warehouse/templates/manage/organization/settings.html:203
4044-
#: warehouse/templates/manage/organization/settings.html:264
4042+
#: warehouse/templates/manage/organization/settings.html:289
40454043
#: warehouse/templates/manage/project/publishing.html:19
40464044
#: warehouse/templates/manage/team/settings.html:60
40474045
msgid "Proceed with caution!"
@@ -4313,7 +4311,8 @@ msgid "Any"
43134311
msgstr ""
43144312

43154313
#: warehouse/templates/manage/manage_base.html:633
4316-
#: warehouse/templates/manage/organization/history.html:141
4314+
#: warehouse/templates/manage/organization/history.html:109
4315+
#: warehouse/templates/manage/organization/history.html:159
43174316
#: warehouse/templates/manage/project/history.html:27
43184317
#: warehouse/templates/manage/project/history.html:80
43194318
#: warehouse/templates/manage/project/history.html:119
@@ -4326,7 +4325,8 @@ msgid "Added by:"
43264325
msgstr ""
43274326

43284327
#: warehouse/templates/manage/manage_base.html:635
4329-
#: warehouse/templates/manage/organization/history.html:146
4328+
#: warehouse/templates/manage/organization/history.html:117
4329+
#: warehouse/templates/manage/organization/history.html:164
43304330
#: warehouse/templates/manage/project/history.html:46
43314331
#: warehouse/templates/manage/project/history.html:111
43324332
#: warehouse/templates/manage/project/history.html:126
@@ -4383,7 +4383,7 @@ msgstr ""
43834383
msgid "Decline invitation"
43844384
msgstr ""
43854385

4386-
#: warehouse/templates/manage/organization/settings.html:284
4386+
#: warehouse/templates/manage/organization/settings.html:309
43874387
#: warehouse/templates/manage/organizations.html:51
43884388
msgid "Organization Name"
43894389
msgstr ""
@@ -5620,56 +5620,70 @@ msgstr ""
56205620
msgid "<a href=\"%(href)s\">%(username)s</a> removed from %(team_name)s team"
56215621
msgstr ""
56225622

5623-
#: warehouse/templates/manage/organization/history.html:109
5623+
#: warehouse/templates/manage/organization/history.html:106
5624+
#, python-format
5625+
msgid ""
5626+
"Custom Trusted Publisher '%(issuer_type)s' for "
5627+
"<code>%(issuer_url)s</code> added to organization"
5628+
msgstr ""
5629+
5630+
#: warehouse/templates/manage/organization/history.html:114
5631+
#, python-format
5632+
msgid ""
5633+
"Custom Trusted Publisher '%(issuer_type)s' for "
5634+
"<code>%(issuer_url)s</code> removed from organization"
5635+
msgstr ""
5636+
5637+
#: warehouse/templates/manage/organization/history.html:127
56245638
msgid "Registered by:"
56255639
msgstr ""
56265640

5627-
#: warehouse/templates/manage/organization/history.html:115
5641+
#: warehouse/templates/manage/organization/history.html:133
56285642
#: warehouse/templates/manage/project/history.html:19
56295643
#: warehouse/templates/manage/team/history.html:52
56305644
msgid "Created by:"
56315645
msgstr ""
56325646

5633-
#: warehouse/templates/manage/organization/history.html:120
5647+
#: warehouse/templates/manage/organization/history.html:138
56345648
#: warehouse/templates/manage/project/history.html:293
56355649
#: warehouse/templates/manage/project/history.html:315
56365650
#: warehouse/templates/manage/team/history.html:57
56375651
msgid "Deleted by:"
56385652
msgstr ""
56395653

5640-
#: warehouse/templates/manage/organization/history.html:125
5654+
#: warehouse/templates/manage/organization/history.html:143
56415655
#: warehouse/templates/manage/team/history.html:62
56425656
msgid "Renamed by:"
56435657
msgstr ""
56445658

5645-
#: warehouse/templates/manage/organization/history.html:130
5659+
#: warehouse/templates/manage/organization/history.html:148
56465660
msgid "Approved by:"
56475661
msgstr ""
56485662

5649-
#: warehouse/templates/manage/organization/history.html:135
5663+
#: warehouse/templates/manage/organization/history.html:153
56505664
msgid "Declined by:"
56515665
msgstr ""
56525666

5653-
#: warehouse/templates/manage/organization/history.html:151
5667+
#: warehouse/templates/manage/organization/history.html:169
56545668
#: warehouse/templates/manage/project/history.html:133
56555669
#: warehouse/templates/manage/project/history.html:179
56565670
#: warehouse/templates/manage/team/history.html:78
56575671
msgid "Changed by:"
56585672
msgstr ""
56595673

5660-
#: warehouse/templates/manage/organization/history.html:156
5661-
#: warehouse/templates/manage/organization/history.html:161
5674+
#: warehouse/templates/manage/organization/history.html:174
5675+
#: warehouse/templates/manage/organization/history.html:179
56625676
#: warehouse/templates/manage/project/history.html:140
56635677
#: warehouse/templates/manage/project/history.html:147
56645678
msgid "Invited by:"
56655679
msgstr ""
56665680

5667-
#: warehouse/templates/manage/organization/history.html:166
5681+
#: warehouse/templates/manage/organization/history.html:184
56685682
#: warehouse/templates/manage/project/history.html:154
56695683
msgid "Revoked by:"
56705684
msgstr ""
56715685

5672-
#: warehouse/templates/manage/organization/history.html:172
5686+
#: warehouse/templates/manage/organization/history.html:190
56735687
#: warehouse/templates/manage/project/history.html:330
56745688
#: warehouse/templates/manage/team/history.html:84
56755689
#, python-format
@@ -6055,90 +6069,97 @@ msgid "Activate billing"
60556069
msgstr ""
60566070

60576071
#: warehouse/templates/manage/organization/settings.html:194
6058-
#: warehouse/templates/manage/organization/settings.html:228
6059-
msgid "Change organization account name"
6072+
msgid "Custom Trusted Publishers"
60606073
msgstr ""
60616074

60626075
#: warehouse/templates/manage/organization/settings.html:196
6063-
msgid "Renaming organizations is not currently supported."
6076+
msgid ""
6077+
"The following custom Trusted Publisher issuers have been configured for "
6078+
"this organization. These issuers can be used to configure Trusted "
6079+
"Publishing for your organization's projects."
60646080
msgstr ""
60656081

6066-
#: warehouse/templates/manage/organization/settings.html:198
6082+
#: warehouse/templates/manage/organization/settings.html:209
6083+
msgid "Modifying custom Trusted Publishers is not currently supported."
6084+
msgstr ""
6085+
6086+
#: warehouse/templates/manage/organization/settings.html:211
60676087
#, python-format
60686088
msgid ""
6069-
"Please contact <a href=%(href)s>PyPI Support</a> if you need to rename "
6070-
"your organization."
6089+
"Please contact <a href=%(href)s>PyPI Support</a> if you need to modify "
6090+
"custom Trusted Publishers."
60716091
msgstr ""
60726092

6073-
#: warehouse/templates/manage/organization/settings.html:206
6074-
msgid ""
6075-
"You will not be able to revert to your current account name after you "
6076-
"rename your organization."
6093+
#: warehouse/templates/manage/organization/settings.html:219
6094+
msgid "Change organization account name"
60776095
msgstr ""
60786096

6079-
#: warehouse/templates/manage/organization/settings.html:228
6080-
msgid "Change organization account name for"
6097+
#: warehouse/templates/manage/organization/settings.html:221
6098+
msgid "Renaming organizations is not currently supported."
60816099
msgstr ""
60826100

6083-
#: warehouse/templates/manage/organization/settings.html:228
6084-
msgid "Current organization account name"
6101+
#: warehouse/templates/manage/organization/settings.html:223
6102+
#, python-format
6103+
msgid ""
6104+
"Please contact <a href=%(href)s>PyPI Support</a> if you need to rename "
6105+
"your organization."
60856106
msgstr ""
60866107

6087-
#: warehouse/templates/manage/organization/settings.html:234
6088-
#: warehouse/templates/manage/organization/settings.html:284
6108+
#: warehouse/templates/manage/organization/settings.html:259
6109+
#: warehouse/templates/manage/organization/settings.html:309
60896110
msgid "Delete organization"
60906111
msgstr ""
60916112

6092-
#: warehouse/templates/manage/organization/settings.html:237
6113+
#: warehouse/templates/manage/organization/settings.html:262
60936114
msgid "Cannot delete organization"
60946115
msgstr ""
60956116

6096-
#: warehouse/templates/manage/organization/settings.html:239
6117+
#: warehouse/templates/manage/organization/settings.html:264
60976118
#, python-format
60986119
msgid "Your organization currently owns %(count)s project."
60996120
msgid_plural "Your organization currently owns %(count)s projects."
61006121
msgstr[0] ""
61016122
msgstr[1] ""
61026123

6103-
#: warehouse/templates/manage/organization/settings.html:244
6124+
#: warehouse/templates/manage/organization/settings.html:269
61046125
msgid "For each project, you must either:"
61056126
msgstr ""
61066127

6107-
#: warehouse/templates/manage/organization/settings.html:246
6128+
#: warehouse/templates/manage/organization/settings.html:271
61086129
msgid "Transfer ownership and remove the project from your organization"
61096130
msgstr ""
61106131

6111-
#: warehouse/templates/manage/organization/settings.html:247
6132+
#: warehouse/templates/manage/organization/settings.html:272
61126133
msgid "Delete the project"
61136134
msgstr ""
61146135

6115-
#: warehouse/templates/manage/organization/settings.html:249
6136+
#: warehouse/templates/manage/organization/settings.html:274
61166137
msgid "Before you can delete your organization."
61176138
msgstr ""
61186139

6119-
#: warehouse/templates/manage/organization/settings.html:255
6140+
#: warehouse/templates/manage/organization/settings.html:280
61206141
#, python-format
61216142
msgid ""
61226143
"<a href=\"%(transfer_href)s\">transfer ownership</a> and <a "
61236144
"href=\"%(remove_delete_href)s\">remove project</a> <b>or</b> <a "
61246145
"href=\"%(remove_delete_href)s\">delete project</a>"
61256146
msgstr ""
61266147

6127-
#: warehouse/templates/manage/organization/settings.html:267
6148+
#: warehouse/templates/manage/organization/settings.html:292
61286149
msgid "You will not be able to recover your organization after you delete it."
61296150
msgstr ""
61306151

6131-
#: warehouse/templates/manage/organization/settings.html:274
6152+
#: warehouse/templates/manage/organization/settings.html:299
61326153
msgid ""
61336154
"Your subscription will be cancelled, and you will lose access to the "
61346155
"billing portal."
61356156
msgstr ""
61366157

6137-
#: warehouse/templates/manage/organization/settings.html:276
6158+
#: warehouse/templates/manage/organization/settings.html:301
61386159
msgid "You will lose access to the billing portal."
61396160
msgstr ""
61406161

6141-
#: warehouse/templates/manage/organization/settings.html:278
6162+
#: warehouse/templates/manage/organization/settings.html:303
61426163
#, python-format
61436164
msgid ""
61446165
"Please ensure you have retrieved all invoices from <a "

warehouse/templates/manage/organization/history.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,24 @@ <h2>{% trans %}Security history{% endtrans %}</h2>
9999
<strong>
100100
{% trans href=request.route_path('accounts.profile', username=target_user), username=target_user, team_name=event.additional.team_name %}<a href="{{ href }}">{{ username }}</a> removed from {{ team_name }} team{% endtrans %}
101101
</strong>
102+
{# Display custom trusted publisher events #}
103+
{% elif event.tag == EventTag.Organization.OIDCPublisherAdded %}
104+
{% set submitted_by = get_user(event.additional.submitted_by_user_id).username %}
105+
<strong>
106+
{% trans issuer_url=event.additional.issuer_url, issuer_type=event.additional.issuer_type %}Custom Trusted Publisher '{{ issuer_type }}' for <code>{{ issuer_url }}</code> added to organization{% endtrans %}
107+
</strong>
108+
<small>
109+
{% trans %}Added by:{% endtrans %} <a href="{{ request.route_path('accounts.profile', username=submitted_by) }}">{{ submitted_by }}</a>
110+
</small>
111+
{% elif event.tag == EventTag.Organization.OIDCPublisherRemoved %}
112+
{% set deleted_by = get_user(event.additional.deleted_by_user_id).username %}
113+
<strong>
114+
{% trans issuer_url=event.additional.issuer_url, issuer_type=event.additional.issuer_type %}Custom Trusted Publisher '{{ issuer_type }}' for <code>{{ issuer_url }}</code> removed from organization{% endtrans %}
115+
</strong>
116+
<small>
117+
{% trans %}Removed by:{% endtrans %} <a href="{{ request.route_path('accounts.profile', username=deleted_by) }}">{{ deleted_by }}</a>
118+
</small>
119+
{# For everything else, display the tag itself #}
102120
{% else %}
103121
<strong>{{ event.tag }}</strong>
104122
{% endif %}

0 commit comments

Comments
 (0)