Out of curiosity, is there a way for me to hide my User accounts from public view? Maybe like a config option?
I don’t think that’s possible. But you can make a proposal on the issues: https://github.com/go-gitea/gitea/issues
Will do. I was thinking about it and it might be possible with templates. Going to test it out this week and see.
Hi
I know that the thread is old, but could you please tell how you solved this? I’m also interested.
Best regards
Josef
Nevermind, I figured this out. You need to create the folder: “custom/templates/explore”, then put a file called: “users.tmpl” inside it and now you can customize the user list. Another way would be to customize the “navbar.tmpl” template and remove the Users-Tab. On my case, I’m looking for just hidding the usernames of the admin users; showing the emails is OK.
For customizing other templates not mentioned on the docs, you may have to look for the template here:
https://github.com/go-gitea/gitea/tree/master/templates
then create the folder and its replacement under: “custom/templates”.
Another nice hack if what you want is to hide all gitea pages to the anonymous users is to the the variable: “REQUIRE_SIGNIN_VIEW” to “true” inside the “[service]” section of your gitea’s app.ini file.
I am using custom templates approach described by jmeile (Thanks!). Sharing what I customised here for others to reference.
My requirements:
- Before sign in, cannot explore “Users”. After login, can access.
- Before sign in, can explore “Organizations”. Use case: Public organisation used to publish NPM packages and Docker images so that it can be used without auth.
What makes it work (I’ll not explain the codes as it is quite obvious):
href="{{if .IsSigned}}{{AppSubUrl}}/explore/users{{end}}"
{{if or .IsSigned .PageIsExploreOrganizations}}
- Make sure you are using the templates from correct Gitea version! I am using this: gitea/templates at v1.21.11 · go-gitea/gitea · GitHub. I noticed that main branch is slightly different (and it does not work properly for v1.21.11).
Full templates for users.tmpl
:
{{template "base/head" .}}
<div role="main" aria-label="{{.Title}}" class="page-content explore users">
{{template "explore/navbar" .}}
<div class="ui container">
{{if or .IsSigned .PageIsExploreOrganizations}}
{{template "explore/search" .}}
{{template "explore/user_list" .}}
{{template "base/paginate" .}}
{{else}}
<!--users listing disabled until logged in-->
<div> </div>
{{end}}
</div>
</div>
{{template "base/footer" .}}
Template for navbar.tmpl
:
<div class="ui secondary pointing tabular top attached borderless menu new-menu navbar">
<div class="new-menu-inner">
<a class="{{if .PageIsExploreRepositories}}active {{end}}item" href="{{AppSubUrl}}/explore/repos">
{{svg "octicon-repo"}} {{ctx.Locale.Tr "explore.repos"}}
</a>
{{if not .UsersIsDisabled}}
<a class="{{if .PageIsExploreUsers}}active {{end}}item" href="{{if .IsSigned}}{{AppSubUrl}}/explore/users{{end}}">
{{svg "octicon-person"}} {{ctx.Locale.Tr "explore.users"}}
</a>
{{end}}
<a class="{{if .PageIsExploreOrganizations}}active {{end}}item" href="{{AppSubUrl}}/explore/organizations">
{{svg "octicon-organization"}} {{ctx.Locale.Tr "explore.organizations"}}
</a>
{{if and (not $.UnitTypeCode.UnitGlobalDisabled) .IsRepoIndexerEnabled}}
<a class="{{if .PageIsExploreCode}}active {{end}}item" href="{{AppSubUrl}}/explore/code">
{{svg "octicon-code"}} {{ctx.Locale.Tr "explore.code"}}
</a>
{{end}}
</div>
</div>
Hope this helps someone.
Thank you for all your suggestions. The custom template approach does not seem appealing to me for upgradeability reasons. But I did notice .UsersPageIsDisabled
all over the templates.
According to the source code, the .UsersPageIsDisabled
is controlled in conf/app.ini
by:
[service.explore]
DISABLE_USERS_PAGE = true
This setting completely disables browsing users - for visitors or signed-in users. Which is exactly what we need. LDAP authentication brings all our Active Directory users to Gitea and I don’t feel comfortable to make this list explorable.
Repositories and organizations remain explorable. One can still access individual user page, by browsing commits or mocking the URL by guessing a user name.