SHA256
forked from course-team/tjhlp-gitea
1) 出站代理 —— 这次实际踩到的故障:
docker compose 会把「运行 compose 的那个 shell」里的 http_proxy/https_proxy
自动注入容器。登录 shell 里是 127.0.0.1:7890, 而 127.0.0.1 在容器里指向容器自己,
于是 Gitea 启动时 OIDC discovery 失败:
initOAuth2Sources() [E] Unable to register source: 高程统一身份认证 due to
proxyconnect tcp: dial tcp 127.0.0.1:7890: connect: connection refused
认证源注册不上 -> 登录页按钮照旧显示(数据来自数据库), 但点下去
/QA/user/oauth2/... 返回 404, 统一身份认证完全无法登录。
现在两处 compose 都显式给出这四个变量(默认 = 改造前宿主机上的代理设置,
NO_PROXY 含 10.80.42.185 让 OIDC 直连), 显式赋值可挡住自动注入;
.env.example 说明如何覆盖/置空, README 记为新陷阱 6(含一行验证命令)。
2) 通行密钥: [service] ENABLE_PASSKEY_AUTHENTICATION=false(两处 compose)。
登录页此前那个"空方框"就是它: 上游该区块只有 tw-hidden 元素, 浏览器不支持
条件中介时 CSS 隐藏一切, 只剩一个带边框的 segment。关掉后连区块都不再输出。
实测: 生产 up -d 后 OIDC 入口 307 -> https://cpp.tongji.sh/oidc/auth?client_id=tjhlp-gitea...
(修复前是 404), 登录页 200 且两张卡片正常, healthz 200。
93 lines
4.0 KiB
Cheetah
93 lines
4.0 KiB
Cheetah
{{/*
|
|
登录页, 整文件覆盖 Gitea 内置 templates/user/auth/signin.tmpl。
|
|
|
|
维护约定:
|
|
* 上游基线: customization/upstream/<版本>/templates/user/auth/signin.tmpl
|
|
升级 Gitea 时先 diff 基线, 把上游的结构性改动(新增表单字段/新认证方式)合并回来。
|
|
* 相对上游的改动只有布局, 逻辑尽量原样搬过来:
|
|
1) 课程同学走的是「高程统一身份认证」(OIDC), 所以把它放进第一张卡片、配说明文字;
|
|
卡片正文复用上游的 {{template "user/auth/external_auth_methods" .}},
|
|
将来新增/更换认证源不用改这个模板。
|
|
2) 用户名/密码降级为第二张「管理员登录」卡片, 并在正文里写明只有管理员/助教用。
|
|
3) 不再渲染通行密钥(passkey)区块 —— 上游那块只有 tw-hidden 的元素, 浏览器不支持
|
|
条件中介时会留下一个空的方框; 服务端已用
|
|
[service] ENABLE_PASSKEY_AUTHENTICATION = false 关掉该功能。
|
|
* 只用 Gitea 已编译进 CSS 的 class: Tailwind 工具类是按上游模板裁剪过的,
|
|
新增 tw-* 前先 grep assets/css/index.css 确认存在(否则不会生效)。
|
|
* 文案直接写中文(平台只面向中文用户), 表单标签仍走 ctx.Locale.Tr 以便跟随语言设置。
|
|
*/}}
|
|
{{template "base/head" .}}
|
|
<div role="main" aria-label="{{.Title}}" class="page-content user signin">
|
|
<div class="ui middle very relaxed page grid">
|
|
{{/* 这些样式与内置模板保持一致, 同时作用于登录/注册/绑定账号页 */}}
|
|
<div class="column tw-flex tw-flex-col tw-gap-4 tw-max-w-2xl tw-m-auto">
|
|
<div class="ui container fluid">
|
|
{{template "base/alert" .}}
|
|
</div>
|
|
|
|
{{$hasExternalAuth := or .OAuth2Providers .EnableOpenIDSignIn .EnableSSPI}}
|
|
{{if $hasExternalAuth}}
|
|
<div class="ui container fluid">
|
|
<h4 class="ui top attached header center">登录 {{AppName}}</h4>
|
|
<div class="ui attached segment">
|
|
<p class="tw-text-center tw-m-0">
|
|
请使用<strong>高程统一身份认证</strong>登录, 账号密码与文档作业网站相同
|
|
</p>
|
|
{{template "user/auth/external_auth_methods" .}}
|
|
</div>
|
|
</div>
|
|
{{end}}
|
|
|
|
{{if .EnablePasswordSignInForm}}
|
|
<div class="ui container fluid">
|
|
<h4 class="ui top attached header center">管理员登录</h4>
|
|
<div class="ui attached segment">
|
|
<p class="tw-text-center tw-m-0 tw-text-sm">
|
|
此入口仅供管理员使用
|
|
</p>
|
|
<form class="ui form" action="{{.SignInLink}}" method="post">
|
|
<div class="required field {{if .Err_UserName}}error{{end}}">
|
|
<label for="user_name">{{ctx.Locale.Tr "home.uname_holder"}}</label>
|
|
<input id="user_name" type="text" name="user_name" value="{{.user_name}}" required tabindex="1">
|
|
</div>
|
|
{{if not .DisablePassword}}
|
|
<div class="required field {{if .Err_Password}}error{{end}}">
|
|
<div class="tw-flex tw-mb-1">
|
|
<label for="password" class="tw-flex-1">{{ctx.Locale.Tr "password"}}</label>
|
|
<a href="{{AppSubUrl}}/user/forgot_password" tabindex="4">{{ctx.Locale.Tr "auth.forgot_password"}}</a>
|
|
</div>
|
|
<input id="password" name="password" type="password" value="{{.password}}" autocomplete="current-password" required tabindex="2">
|
|
</div>
|
|
{{end}}
|
|
<div class="inline field">
|
|
<div class="ui checkbox">
|
|
<label>{{ctx.Locale.Tr "auth.remember_me"}}</label>
|
|
<input name="remember" type="checkbox" tabindex="5">
|
|
</div>
|
|
</div>
|
|
|
|
{{template "user/auth/captcha" .}}
|
|
|
|
<div class="field">
|
|
<button class="ui primary button tw-w-full" tabindex="3">
|
|
{{ctx.Locale.Tr "sign_in"}}
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
{{end}}
|
|
|
|
{{if .ShowRegistrationButton}}
|
|
<div class="ui container fluid">
|
|
<div class="ui attached segment tw-text-center">
|
|
<span>{{ctx.Locale.Tr "auth.need_account"}}</span>
|
|
<a href="{{AppSubUrl}}/user/sign_up">{{ctx.Locale.Tr "auth.sign_up_now"}}</a>
|
|
</div>
|
|
</div>
|
|
{{end}}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{{template "base/footer" .}}
|