Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to specify custom names in the OAuth login buttons #214

Merged
merged 5 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/configuration/cheat-sheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@
| gitlab.client-key | OG_GITLAB_CLIENT_KEY | none | The client key for the GitLab OAuth application. |
| gitlab.secret | OG_GITLAB_SECRET | none | The secret for the GitLab OAuth application. |
| gitlab.url | OG_GITLAB_URL | `https://gitlab.com/` | The URL of the GitLab instance. |
| gitlab.name | OG_GITLAB_NAME | `GitLab` | The name of the GitLab instance. It is displayed in the OAuth login button. |
| gitea.client-key | OG_GITEA_CLIENT_KEY | none | The client key for the Gitea OAuth application. |
| gitea.secret | OG_GITEA_SECRET | none | The secret for the Gitea OAuth application. |
| gitea.url | OG_GITEA_URL | `https://gitea.com/` | The URL of the Gitea instance. |
| gitea.name | OG_GITEA_ | `Gitea` | The name of the Gitea instance. It is displayed in the OAuth login button. |
crapStone marked this conversation as resolved.
Show resolved Hide resolved
| oidc.client-key | OG_OIDC_CLIENT_KEY | none | The client key for the OpenID application. |
| oidc.secret | OG_OIDC_SECRET | none | The secret for the OpenID application. |
| oidc.discovery-url | OG_OIDC_DISCOVERY_URL | none | Discovery endpoint of the OpenID provider. |
5 changes: 5 additions & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,12 @@ type config struct {
GitlabClientKey string `yaml:"gitlab.client-key" env:"OG_GITLAB_CLIENT_KEY"`
GitlabSecret string `yaml:"gitlab.secret" env:"OG_GITLAB_SECRET"`
GitlabUrl string `yaml:"gitlab.url" env:"OG_GITLAB_URL"`
GitlabName string `yaml:"gitlab.name" env:"OG_GITLAB_NAME"`

GiteaClientKey string `yaml:"gitea.client-key" env:"OG_GITEA_CLIENT_KEY"`
GiteaSecret string `yaml:"gitea.secret" env:"OG_GITEA_SECRET"`
GiteaUrl string `yaml:"gitea.url" env:"OG_GITEA_URL"`
GiteaName string `yaml:"gitea.name" env:"OG_GITEA_NAME"`

OIDCClientKey string `yaml:"oidc.client-key" env:"OG_OIDC_CLIENT_KEY"`
OIDCSecret string `yaml:"oidc.secret" env:"OG_OIDC_SECRET"`
Expand Down Expand Up @@ -83,7 +85,10 @@ func configWithDefaults() (*config, error) {
c.SshPort = "2222"
c.SshKeygen = "ssh-keygen"

c.GitlabName = "GitLab"

c.GiteaUrl = "https://gitea.com"
c.GiteaName = "Gitea"

return c, nil
}
Expand Down
3 changes: 1 addition & 2 deletions internal/i18n/locales/cs-CZ.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,7 @@ auth.username: Uživatelské jméno
auth.password: Heslo
auth.register-instead: Raději se zaregistrovat
auth.login-instead: Raději se přihlásit
auth.github-oauth: Pokračovat s účtem na GitHubu
auth.gitea-oauth: Pokračovat s účtem na Gitea
auth.oauth: Pokračovat s účtem na %s

error: Chyba

Expand Down
4 changes: 1 addition & 3 deletions internal/i18n/locales/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,7 @@ auth.username: Username
auth.password: Password
auth.register-instead: Register instead
auth.login-instead: Login instead
auth.github-oauth: Continue with GitHub account
auth.gitlab-oauth: Continue with GitLab account
auth.gitea-oauth: Continue with Gitea account
auth.oauth: Continue with %s account

error: Error

Expand Down
3 changes: 1 addition & 2 deletions internal/i18n/locales/es-ES.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ auth.username: Nombre de usuario
auth.password: Contraseña
auth.register-instead: Registrarse en su lugar
auth.login-instead: Iniciar sesión en su lugar
auth.github-oauth: Continuar con cuenta de GitHub
auth.gitea-oauth: Continuar con cuenta de Gitea
auth.oauth: Continuar con cuenta de %s

error: Error

Expand Down
3 changes: 1 addition & 2 deletions internal/i18n/locales/fr-FR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ auth.username: Nom d'utilisateur
auth.password: Mot de passe
auth.register-instead: Je préfère m'inscrire
auth.login-instead: Je préfère me connecter
auth.github-oauth: Continuer avec un compte GitHub
auth.gitea-oauth: Continuer avec un compte Gitea
auth.oauth: Continuer avec un compte %s

error: Erreur

Expand Down
3 changes: 1 addition & 2 deletions internal/i18n/locales/hu-HU.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ auth.username: Felhasználónév
auth.password: Jelszó
auth.register-instead: Vagy regisztrálj
auth.login-instead: Vagy jelentkezz be
auth.github-oauth: Folytatás GitHub fiókkal
auth.gitea-oauth: Folytatás Gitea fiókkal
auth.oauth: Folytatás %s fiókkal

error: Hiba

Expand Down
3 changes: 1 addition & 2 deletions internal/i18n/locales/pt-BR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ auth.username: Nome de usuário
auth.password: Senha
auth.register-instead: Registrar-se no lugar
auth.login-instead: Entrar no lugar
auth.github-oauth: Continuar com conta do GitHub
auth.gitea-oauth: Continuar com conta do Gitea
auth.oauth: Continuar com conta do %s

error: Erro

Expand Down
3 changes: 1 addition & 2 deletions internal/i18n/locales/ru-RU.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ auth.username: Имя пользователя
auth.password: Пароль
auth.register-instead: Зарегистрироваться
auth.login-instead: Войти
auth.github-oauth: Войти с помощью доступа GitHub
auth.gitea-oauth: Войти с помощью доступа Gitea
auth.oauth: Войти с помощью доступа %s

error: Ошибка

Expand Down
3 changes: 1 addition & 2 deletions internal/i18n/locales/zh-CN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ auth.username: 用户名
auth.password: 密码
auth.register-instead: 转到注册
auth.login-instead: 转到登录
auth.github-oauth: 使用 GitHub 账号继续
auth.gitea-oauth: 使用 Gitea 账号继续
auth.oauth: 使用 %s 账号继续

error: 错误

Expand Down
4 changes: 1 addition & 3 deletions internal/i18n/locales/zh-TW.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,7 @@ auth.username: 使用者名稱
auth.password: 密碼
auth.register-instead: 註冊
auth.login-instead: 登錄
auth.github-oauth: 用 GitHub 帳號繼續
auth.gitlab-oauth: 用 GitLab 帳號繼續
auth.gitea-oauth: 用 Gitea 帳號繼續
auth.oauth: 用 %s 帳號繼續

error: 錯誤

Expand Down
2 changes: 2 additions & 0 deletions templates/pages/admin_config.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,11 @@
<dt>GitLab client Key</dt><dd>{{ .c.GitlabClientKey }}</dd>
<dt>GitLab Secret</dt><dd>{{ .c.GitlabSecret }}</dd>
<dt>GitLab URL</dt><dd>{{ .c.GitlabUrl }}</dd>
<dt>GitLab Name</dt><dd>{{ .c.GitlabName }}</dd>
<dt>Gitea client Key</dt><dd>{{ .c.GiteaClientKey }}</dd>
<dt>Gitea Secret</dt><dd>{{ .c.GiteaSecret }}</dd>
<dt>Gitea URL</dt><dd>{{ .c.GiteaUrl }}</dd>
<dt>Gitea Name</dt><dd>{{ .c.GiteaName }}</dd>
<dt>OIDC client Key</dt><dd>{{ .c.OIDCClientKey }}</dd>
<dt>OIDC Secret</dt><dd>{{ .c.OIDCSecret }}</dd>
<dt>OIDC Discovery URL</dt><dd>{{ .c.OIDCDiscoveryUrl }}</dd>
Expand Down
6 changes: 3 additions & 3 deletions templates/pages/auth_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,17 @@ <h1 class="text-2xl font-bold leading-tight text-slate-700 dark:text-slate-300">
<div>
{{ if .githubOauth }}
<a href="{{ $.c.ExternalUrl }}/oauth/github" class="block w-full mb-2 text-center whitespace-nowrap text-slate-700 dark:text-slate-300{{ if .syncReposFromFS }} text-slate-500 cursor-not-allowed {{ end }}rounded border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 px-2.5 py-2 text-xs font-medium text-gray-700 dark:text-white shadow-sm hover:bg-gray-100 dark:hover:bg-gray-700 hover:border-gray-500 hover:text-slate-700 dark:hover:text-slate-300 focus:outline-none focus:ring-1 focus:border-primary-500 focus:ring-primary-500 leading-3">
{{ .locale.Tr "auth.github-oauth" }}
{{ .locale.Tr "auth.oauth" "GitHub"}}
</a>
{{ end }}
{{ if .gitlabOauth }}
<a href="{{ $.c.ExternalUrl }}/oauth/gitlab" class="block w-full mb-2 text-center whitespace-nowrap text-slate-700 dark:text-slate-300{{ if .syncReposFromFS }} text-slate-500 cursor-not-allowed {{ end }}rounded border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 px-2.5 py-2 text-xs font-medium text-gray-700 dark:text-white shadow-sm hover:bg-gray-100 dark:hover:bg-gray-700 hover:border-gray-500 hover:text-slate-700 dark:hover:text-slate-300 focus:outline-none focus:ring-1 focus:border-primary-500 focus:ring-primary-500 leading-3">
{{ .locale.Tr "auth.gitlab-oauth" }}
{{ .locale.Tr "auth.oauth" .c.GitLabName}}
</a>
{{ end }}
{{ if .giteaOauth }}
<a href="{{ $.c.ExternalUrl }}/oauth/gitea" class="block w-full mb-2 text-center whitespace-nowrap text-slate-700 dark:text-slate-300{{ if .syncReposFromFS }} text-slate-500 cursor-not-allowed {{ end }}rounded border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 px-2.5 py-2 text-xs font-medium text-gray-700 dark:text-white shadow-sm hover:bg-gray-100 dark:hover:bg-gray-700 hover:border-gray-500 hover:text-slate-700 dark:hover:text-slate-300 focus:outline-none focus:ring-1 focus:border-primary-500 focus:ring-primary-500 leading-3">
{{ .locale.Tr "auth.gitea-oauth" }}
{{ .locale.Tr "auth.oauth" .c.GiteaName }}
</a>
{{ end }}
{{ if .oidcOauth }}
Expand Down
Loading