Skip to content

feat(admin): show and filter users by authentication source - #38900

Draft
Zettat123 wants to merge 4 commits into
go-gitea:mainfrom
Zettat123:feat/show-user-auth-source
Draft

feat(admin): show and filter users by authentication source#38900
Zettat123 wants to merge 4 commits into
go-gitea:mainfrom
Zettat123:feat/show-user-auth-source

Conversation

@Zettat123

Copy link
Copy Markdown
Contributor

Admins running external authentication (LDAP, OAuth2, ...) currently cannot tell from the user list which accounts belong to which source, and cannot narrow the list down to one source.

This adds an "Authentication Source" filter and a matching column to the admin user list. Local is a selectable value, so accounts not tied to any source can be listed too. Both the filter and the column are hidden on instances with no authentication source configured. Deactivated sources are included, since users stay attached to a source after it is disabled.

Screenshots:

image image

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Aug 12, 2026
@github-actions github-actions Bot added the type/feature Completely new functionality. Can only be merged if feature freeze is not active. label Aug 12, 2026
ctx.Data["Sources"] = sources
ctx.Data["SourceNames"] = sourceNames

sourceIDFilter := optional.ParseInt64(ctx.FormString("source_id"))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use FormInt64 like other places.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FormInt64 returns 0 for a missing, empty or invalid value, so it can't distinguish "no filter" from "filter for local users"(0 is a real value here since user.login_source is 0 for local accounts).


However, this is definitely a point of divergence: in API, source_id = 0 means not filtering users by authentication source (because API doesn't support filtering users by local auth source)

@Zettat123
Zettat123 marked this pull request as draft August 13, 2026 04:23
Comment on lines +50 to +52
{{range .Sources}}
<label class="item"><input type="radio" name="source_id" value="{{.ID}}" {{if eq $selectedSourceID .ID}}checked{{end}}> {{.Name}}</label>
{{end}}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ctx.Data["Sources"] = sources
ctx.Data["SourceNames"] = sourceNames

sourceIDFilter := optional.ParseInt64(ctx.FormString("source_id"))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be ctx.FormOptionalInt64

Types: []user_model.UserType{user_model.UserTypeIndividual},
LoginName: ctx.FormTrim("login_name"),
SourceID: ctx.FormInt64("source_id"),
SourceID: optional.FromNonDefault(ctx.FormInt64("source_id")),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be ctx.FormOptionalInt64

</tr>
{{else}}
<tr class="no-results-row"><td class="tw-text-center" colspan="9">{{ctx.Locale.Tr "no_results_found"}}</td></tr>
<tr class="no-results-row"><td class="tw-text-center" colspan="{{Iif $.Sources 10 9}}">{{ctx.Locale.Tr "no_results_found"}}</td></tr>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

auth source column can always be there, no need to use such fragile {Iif $.Sources 10 9}} trick

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. type/feature Completely new functionality. Can only be merged if feature freeze is not active.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants