diff options
-rw-r--r-- | conf/locale/locale_en-US.ini | 5 | ||||
-rwxr-xr-x | conf/locale/locale_es-ES.ini | 250 | ||||
-rwxr-xr-x | conf/locale/locale_ru-RU.ini | 46 | ||||
-rw-r--r-- | models/action.go | 22 | ||||
-rw-r--r-- | models/login.go | 3 | ||||
-rw-r--r-- | modules/auth/auth.go | 9 | ||||
-rw-r--r-- | modules/auth/auth_form.go | 5 | ||||
-rw-r--r-- | modules/auth/ldap/ldap.go | 48 | ||||
-rw-r--r-- | routers/admin/auths.go | 42 | ||||
-rw-r--r-- | routers/repo/http.go | 10 | ||||
-rw-r--r-- | routers/repo/issue.go | 19 | ||||
-rw-r--r-- | templates/admin/auth/edit.tmpl | 16 |
12 files changed, 270 insertions, 205 deletions
diff --git a/conf/locale/locale_en-US.ini b/conf/locale/locale_en-US.ini index ca076b8b..f05287f5 100644 --- a/conf/locale/locale_en-US.ini +++ b/conf/locale/locale_en-US.ini @@ -595,7 +595,10 @@ auths.domain = Domain auths.host = Host auths.port = Port auths.base_dn = Base DN -auths.attributes = Search Attributes +auths.attribute_username = Username attribute +auths.attribute_name = First name attribute +auths.attribute_surname = Surname attribute +auths.attribute_mail = E-mail attribute auths.filter = Search Filter auths.ms_ad_sa = Ms Ad SA auths.smtp_auth = SMTP Authorization Type diff --git a/conf/locale/locale_es-ES.ini b/conf/locale/locale_es-ES.ini index 046bab89..fc235f15 100755 --- a/conf/locale/locale_es-ES.ini +++ b/conf/locale/locale_es-ES.ini @@ -516,8 +516,8 @@ dashboard.git_gc_repos=Ejecutar la recolección de basura en los repositorios dashboard.git_gc_repos_success=Todos los repositorios han ejecutado correctamente el recolector de basuras.
dashboard.resync_all_sshkeys=Reescribir el fichero '.ssh/authorized_key'(atención: se perderán las claves que no pertenezcan a Gogs)
dashboard.resync_all_sshkeys_success=Todas las claves públicas se han reescrito correctamente.
-dashboard.resync_all_update_hooks=Rewrite all update hook of repositories (needed when custom config path is changed)
-dashboard.resync_all_update_hooks_success=All repositories' update hook have been rewritten successfully.
+dashboard.resync_all_update_hooks=Reescribir todos los hooks de actualización de los repositorios (necesario cuando se modifica la ruta de configuración personalizada)
+dashboard.resync_all_update_hooks_success=Todos los hooks de actualización de los repositorios se han reescrito correctamente.
dashboard.server_uptime=Uptime del Servidor
dashboard.current_goroutine=Gorutinas Actuales
@@ -547,62 +547,62 @@ dashboard.last_gc_time=Tiempo desde el Último GC dashboard.total_gc_time=Pausa Total por GC
dashboard.total_gc_pause=Pausa Total por GC
dashboard.last_gc_pause=Última Pausa por GC
-dashboard.gc_times=GC Times
-
-users.user_manage_panel=User Manage Panel
-users.new_account=Create New Account
-users.name=Name
-users.activated=Activated
-users.admin=Admin
-users.repos=Repos
-users.created=Created
-users.edit=Edit
-users.auth_source=Authorization Source
+dashboard.gc_times=Ejecuciones GC
+
+users.user_manage_panel=Panel de Gestión de Usuarios
+users.new_account=Crear Nueva Cuenta
+users.name=Nombre
+users.activated=Activado
+users.admin=Administrador
+users.repos=Repositorios
+users.created=Creado
+users.edit=Editar
+users.auth_source=Origen de Autorización
users.local=Local
-users.auth_login_name=Authorization Login Name
-users.update_profile_success=Account profile has been updated successfully.
+users.auth_login_name=Nombre de Usuario de Autorización
+users.update_profile_success=El perfil de la cuenta se ha actualizado correctamente.
users.edit_account=Editar Cuenta
users.is_activated=Esta cuenta está activada
-users.is_admin=This account has administrator permissions
-users.allow_git_hook=This account has permissions to create Git hooks
-users.update_profile=Update Account Profile
-users.delete_account=Delete This Account
-users.still_own_repo=This account still have ownership of repository, you have to delete or transfer them first.
-users.still_has_org=This account still have membership of organization, you have to left or delete them first.
-
-orgs.org_manage_panel=Organization Manage Panel
-orgs.name=Name
-orgs.teams=Teams
-orgs.members=Members
-
-repos.repo_manage_panel=Repository Manage Panel
-repos.owner=Owner
-repos.name=Name
-repos.private=Private
-repos.watches=Watches
-repos.stars=Stars
-repos.issues=Issues
-
-auths.auth_manage_panel=Authorization Manage Panel
-auths.new=Add New Authorization Source
-auths.name=Name
-auths.type=Type
-auths.enabled=Enabled
-auths.updated=Updated
-auths.auth_type=Authorization Type
-auths.auth_name=Authorization Name
-auths.domain=Domain
+users.is_admin=Esta cuenta tiene permisos de administrador
+users.allow_git_hook=Esta cuenta tiene permisos para crear hooks de Git
+users.update_profile=Actualizar Perfil de la Cuenta
+users.delete_account=Eliminar esta Cuenta
+users.still_own_repo=Esta cuenta es propietaria de uno o más repositorios, tienes que borrarlos o transferirlos primero.
+users.still_has_org=Esta cuenta es miembro de una o más organizaciones, tienes que abandonarlas o eliminarlas primero.
+
+orgs.org_manage_panel=Panel de Gestión de Organización
+orgs.name=Nombre
+orgs.teams=Equipos
+orgs.members=Miembros
+
+repos.repo_manage_panel=Panel de Gestión de Repositorios
+repos.owner=Propietario
+repos.name=Nombre
+repos.private=Privado
+repos.watches=Vigilantes
+repos.stars=Estrellas
+repos.issues=Incidencias
+
+auths.auth_manage_panel=Panel de Gestión de Autorizaciones
+auths.new=Añadir nuevo origen de autorización
+auths.name=Nombre
+auths.type=Tipo
+auths.enabled=Activo
+auths.updated=Actualizado
+auths.auth_type=Tipo de Autorización
+auths.auth_name=Nombre de Autorización
+auths.domain=Dominio
auths.host=Host
-auths.port=Port
+auths.port=Puerto
auths.base_dn=Base DN
-auths.attributes=Search Attributes
-auths.filter=Search Filter
+auths.attributes=Atributos de búsqueda
+auths.filter=Filtro de Búsqueda
auths.ms_ad_sa=Ms Ad SA
-auths.smtp_auth=SMTP Authorization Type
+auths.smtp_auth=Tipo de Autorización SMTP
auths.smtphost=SMTP Host
-auths.smtpport=SMTP Port
-auths.enable_tls=Enable TLS Encryption
-auths.enable_auto_register=Enable Auto Registration
+auths.smtpport=Puerto SMTP
+auths.enable_tls=Habilitar Cifrado TLS
+auths.enable_auto_register=Hablilitar Auto-Registro
auths.tips=Consejos
auths.edit=Editar la Configuración de Autorización
auths.activated=Esta autenticación ha sido activada
@@ -625,7 +625,7 @@ config.repo_root_path=Ruta del Repositorio config.static_file_root_path=Ruta de los Ficheros Estáticos
config.log_file_root_path=Ruta de los Ficheros de Log
config.script_type=Tipo de Script
-config.reverse_auth_user=Reverse Authentication User
+config.reverse_auth_user=Autenticación Inversa de Usuario
config.db_config=Configuración de la Base de Datos
config.db_type=Tipo
config.db_host=Host
@@ -642,83 +642,83 @@ config.show_registration_button=Mostrar Botón de Registro config.require_sign_in_view=Solicitar la Vista de Inicio de Sesión
config.mail_notify=Notificación por Correo Electrónico
config.enable_cache_avatar=Activar la Caché de Avatar
-config.active_code_lives=Active Code Lives
-config.reset_password_code_lives=Reset Password Code Lives
-config.webhook_config=Webhook Configuration
-config.task_interval=Task Interval
-config.deliver_timeout=Deliver Timeout
-config.skip_tls_verify=Skip TLS Verify
-config.mailer_config=Mailer Configuration
-config.mailer_enabled=Enabled
-config.mailer_name=Name
+config.active_code_lives=Habilitar Vida del Código
+config.reset_password_code_lives=Restablecer Contraseña de Vida del Código
+config.webhook_config=Configuración de Webhooks
+config.task_interval=Intervalo de Tareas
+config.deliver_timeout=Timeout de Entrega
+config.skip_tls_verify=Omitir la Verificación TLS
+config.mailer_config=Configuración del Mailer
+config.mailer_enabled=Activado
+config.mailer_name=Nombre
config.mailer_host=Host
-config.mailer_user=User
-config.oauth_config=OAuth Configuration
-config.oauth_enabled=Enabled
-config.cache_config=Cache Configuration
-config.cache_adapter=Cache Adapter
-config.cache_interval=Cache Interval
-config.cache_conn=Cache Connection
-config.session_config=Session Configuration
-config.session_provider=Session Provider
-config.provider_config=Provider Config
-config.cookie_name=Cookie Name
-config.enable_set_cookie=Enable Set Cookie
-config.gc_interval_time=GC Interval Time
-config.session_life_time=Session Life Time
-config.https_only=HTTPS Only
-config.cookie_life_time=Cookie Life Time
-config.picture_config=Picture Configuration
-config.picture_service=Picture Service
-config.disable_gravatar=Disable Gravatar
-config.log_config=Log Configuration
-config.log_mode=Log Mode
-
-monitor.cron=Cron Tasks
-monitor.name=Name
-monitor.schedule=Schedule
-monitor.next=Next Time
-monitor.previous=Previous Time
-monitor.execute_times=Execute Times
-monitor.process=Running Processes
-monitor.desc=Description
-monitor.start=Start Time
-monitor.execute_time=Execution Time
-
-notices.system_notice_list=System Notices
-notices.type=Type
-notices.type_1=Repository
-notices.desc=Description
+config.mailer_user=Usuario
+config.oauth_config=Configuración OAuth
+config.oauth_enabled=Activado
+config.cache_config=Configuración de la Caché
+config.cache_adapter=Adaptador de la Caché
+config.cache_interval=Intervalo de la Caché
+config.cache_conn=Conexión de la Caché
+config.session_config=Configuración de la Sesión
+config.session_provider=Proveedor de la Sesión
+config.provider_config=Configuración del Proveedor
+config.cookie_name=Nombre de la Cookie
+config.enable_set_cookie=Activar Establecimiento de Cookie
+config.gc_interval_time=Intervalo de tiempo del GC
+config.session_life_time=Tiempo de Vida de la Sesión
+config.https_only=Sólo HTTPS
+config.cookie_life_time=Tiempo de Vida de la Cookie
+config.picture_config=Configuración de Imagen
+config.picture_service=Servicio de Imágen
+config.disable_gravatar=Desactivar Gravatar
+config.log_config=Configuración del Log
+config.log_mode=Modo del Log
+
+monitor.cron=Tareas de Cron
+monitor.name=Nombre
+monitor.schedule=Agenda
+monitor.next=Próxima Vez
+monitor.previous=Vez Anterior
+monitor.execute_times=Ejecuciones
+monitor.process=Procesos en Ejecución
+monitor.desc=Descripción
+monitor.start=Hora de Inicio
+monitor.execute_time=Tiempo de ejecución
+
+notices.system_notice_list=Notificaciones del Sistema
+notices.type=Tipo
+notices.type_1=Repositorio
+notices.desc=Descripción
notices.op=Op.
-notices.delete_success=System notice has been deleted successfully.
+notices.delete_success=La notificación del sistema se ha eliminado correctamente.
[action]
-create_repo=created repository <a href="%s/%s">%s</a>
-commit_repo=pushed to <a href="%s/%s/src/%s">%s</a> at <a href="%s/%s">%s</a>
-create_issue=`opened issue <a href="%s/issues/%s">%[1]s#%[2]s</a>`
-comment_issue=`commented on issue <a href="%s/issues/%s">%[1]s#%[2]s</a>`
-transfer_repo=transfered repository <code>%s</code> to <a href="/%s%s">%s</a>
-push_tag=pushed tag <a href="%s/%s/src/%s">%s</a> to <a href="%s/%s">%s</a>
-compare_2_commits=View comparison for these 2 commits
+create_repo=Repositorio creado <a href="%s/%s">%s</a>
+commit_repo=hizo push a <a href="%s/%s/src/%s">%s</a> en <a href="%s/%s">%s</a>
+create_issue=`incidencia abierta <a href="%s/issues/%s">%[1]s#%[2]s</a>`
+comment_issue=`comentó en la incidencia <a href="%s/issues/%s">%[1]s#%[2]s</a>`
+transfer_repo=transfirió el repositorio <code>%s</code> a <a href="/%s%s">%s</a>
+push_tag=hizo push del tag <a href="%s/%s/src/%s">%s</a> a <a href="%s/%s">%s</a>
+compare_2_commits=Ver la comparación de estos 2 commits
[tool]
-ago=ago
-from_now=from now
-now=now
-1s=1 second %s
-1m=1 minute %s
-1h=1 hour %s
-1d=1 day %s
-1w=1 week %s
-1mon=1 month %s
-1y=1 year %s
-seconds=%d seconds %s
-minutes=%d minutes %s
-hours=%d hours %s
-days=%d days %s
-weeks=%d weeks %s
-months=%d months %s
-years=%d years %s
-raw_seconds=seconds
-raw_minutes=minutes
+ago=hace
+from_now=desde ahora
+now=ahora
+1s=1 segundo %s
+1m=1 minuto %s
+1h=1 hora %s
+1d=1 día %s
+1w=1 semana %s
+1mon=1 mes %s
+1y=1 año %s
+seconds=%d segundos %s
+minutes=%d minutos %s
+hours=%d horas %s
+days=%d días %s
+weeks=%d semanas %s
+months=%d meses %s
+years=%d años %s
+raw_seconds=segundos
+raw_minutes=minutos
diff --git a/conf/locale/locale_ru-RU.ini b/conf/locale/locale_ru-RU.ini index e21dca14..731ba469 100755 --- a/conf/locale/locale_ru-RU.ini +++ b/conf/locale/locale_ru-RU.ini @@ -313,9 +313,9 @@ tags=Метки issues=Обсуждения
commits=Коммиты
releases=Релизы
-file_raw=Raw
+file_raw=Исходник
file_history=История
-file_view_raw=View Raw
+file_view_raw=Посмотреть исходник
commits.commits=Коммиты
commits.search=Поиск коммитов
@@ -339,7 +339,7 @@ settings.update_settings=Обновить настройки settings.change_reponame=Имя репозитория изменено
settings.change_reponame_desc=Имя хранилища изменено, вы хотите продолжить? Это действие повлияет на все ссылки, относящиеся к этому репозиторию.
settings.transfer=Передать права собственности
-settings.transfer_desc=Transfer this repo to another user or to an organization where you have admin rights.
+settings.transfer_desc=Передать репозиторий другому пользователю или организации где у вас есть права администратора.
settings.new_owner_has_same_repo=У нового владельца уже есть хранилище с таким названием.
settings.delete=Удалить этот репозиторий
settings.delete_desc=Как только вы удалите репозиторий — пути назад не будет. Удостоверьтесь, что вам это точно нужно.
@@ -352,7 +352,7 @@ settings.confirm_delete=Подтвердить удаление settings.add_collaborator=Добавить нового соавтора
settings.add_collaborator_success=Был добавлен новый соавтор.
settings.remove_collaborator_success=Соавтор был удален.
-settings.user_is_org_member=User is organization member who cannot be added as a collaborator.
+settings.user_is_org_member=Пользователь является членом организации, члены которой не могут быть добавлены в качестве соавтора.
settings.add_webhook=Добавить Webhook
settings.hooks_desc=Webhooks allow external services to be notified when certain events happen on Gogs. When the specified events happen, we'll send a POST request to each of the URLs you provide. Learn more in our <a target="_blank" href="%s">Webhooks Guide</a>.
settings.githooks_desc=Git Hooks are powered by Git itself, you can edit files of supported hooks in the list below to apply custom operations.
@@ -399,12 +399,12 @@ release.ahead=<strong>%d</strong> commits to %s since this release release.source_code=Исходный код
release.tag_name=Имя тега
release.target=Цель
-release.tag_helper=Choose an existing tag, or create a new tag on publish.
+release.tag_helper=Выберите существующий тег, или создайте новый.
release.release_title=Название релиза
release.content_with_md=Содержимое с <a href="%s">Markdown</a>
release.write=Запись
release.preview=Предварительный просмотр
-release.content_placeholder=Write some content
+release.content_placeholder=Напишите что-нибудь
release.loading=Загрузка...
release.prerelease_desc=Это предварительный релиз
release.prerelease_helper=We’ll point out that this release is identified as non-production ready.
@@ -443,10 +443,10 @@ settings.change_orgname_desc=Organization name has been changed, do you want to settings.update_setting_success=Organization setting has been updated successfully.
settings.delete=Удалить Организацию
settings.delete_account=Удалить Эту Организацию
-settings.delete_prompt=The operation will delete this organization permanently, and <strong>CANNOT</strong> be undone!
+settings.delete_prompt=Это действие безвозвратно удалит эту организацию навсегда.
settings.confirm_delete_account=Подтвердить удаление
settings.delete_org_title=Удаление Организации
-settings.delete_org_desc=This organization is going to be deleted permanently, do you want to continue?
+settings.delete_org_desc=Эта организация будет удалена навсегда. Хотите всё-равно продолжить?
settings.hooks_desc=Добавьте автоматическое обновление, который будет вызываться для <strong>всех репозиций</strong> под этой Группой.
members.public=Публичный
@@ -455,7 +455,7 @@ members.private=Приватный members.private_helper=Сделать Публичным
members.owner=Владелец
members.member=Участник
-members.conceal=Conceal
+members.conceal=Скрыть
members.remove=Удалить
members.leave=Покинуть
members.invite_desc=Начните вводить имя пользователя чтобы пригласить нового члена %s:
@@ -494,7 +494,7 @@ organizations=Организации repositories=Репозитории
authentication=Авторизация
config=Настройки
-notices=System Notices
+notices=Системные уведомления
monitor=Мониторинг
prev=Предыдущий.
next=Следующий
@@ -506,15 +506,15 @@ dashboard.statistic_info=В базе данных Gogs записано <b>%d</b dashboard.operation_name=Operation Name
dashboard.operation_switch=Переключить
dashboard.operation_run=Запуск
-dashboard.clean_unbind_oauth=Clean unbound OAuthes
-dashboard.clean_unbind_oauth_success=All unbind OAuthes have been deleted successfully.
+dashboard.clean_unbind_oauth=Удалить не привязанные OAUth
+dashboard.clean_unbind_oauth_success=Не привязанные OAuth аккаунты успешно удалены.
dashboard.delete_inactivate_accounts=Удалить все неактивированные учетные записи
dashboard.delete_inactivate_accounts_success=Все неактивированные учетные записи удалены успешно.
dashboard.delete_repo_archives=Удаление всех архивов репозиториев
dashboard.delete_repo_archives_success=Все архивы репозиториев были успешно удалены.
dashboard.git_gc_repos=Выполнить сборку мусора на репозиториях
dashboard.git_gc_repos_success=Сборка мусора на всех репозиториях успешно выполнена.
-dashboard.resync_all_sshkeys=Rewrite '.ssh/autorized_key' file (caution: non-Gogs keys will be lost)
+dashboard.resync_all_sshkeys=Переписать файл «.ssh/autorized_key» (осторожно: не Gogs ключи будут утеряны)
dashboard.resync_all_sshkeys_success=All public keys have been rewritten successfully.
dashboard.resync_all_update_hooks=Rewrite all update hook of repositories (needed when custom config path is changed)
dashboard.resync_all_update_hooks_success=All repositories' update hook have been rewritten successfully.
@@ -690,7 +690,7 @@ notices.type=Тип notices.type_1=Репозиторий
notices.desc=Описание
notices.op=Op.
-notices.delete_success=System notice has been deleted successfully.
+notices.delete_success=Системное уведомление успешно удалено.
[action]
create_repo=создан репозиторий <a href="%s/%s"> %s</a>
@@ -699,26 +699,26 @@ create_issue=`opened issue <a href="%s/issues/%s">%[1]s#%[2]s</a>` comment_issue=`commented on issue <a href="%s/issues/%s">%[1]s#%[2]s</a>`
transfer_repo=transfered repository <code>%s</code> to <a href="/%s%s">%s</a>
push_tag=pushed tag <a href="%s/%s/src/%s">%s</a> to <a href="%s/%s">%s</a>
-compare_2_commits=View comparison for these 2 commits
+compare_2_commits=Просмотреть сравнение двух коммитов
[tool]
ago=ago
from_now=from now
now=сейчас
1s=1 second %s
-1m=1 minute %s
-1h=1 hour %s
-1d=1 day %s
-1w=1 week %s
+1m=1 минута %s
+1h=1 час %s
+1d=1 день %s
+1w=1 неделя %s
1mon=1 month %s
-1y=1 year %s
+1y=1 год %s
seconds=%d секунд %s
minutes=%d минут %s
hours=%d часов %s
-days=%d days %s
+days=%d дней %s
weeks=%d weeks %s
months=%d months %s
years=%d years %s
-raw_seconds=seconds
-raw_minutes=minutes
+raw_seconds=секунд
+raw_minutes=минут
diff --git a/models/action.go b/models/action.go index fee5e5e6..f872104e 100644 --- a/models/action.go +++ b/models/action.go @@ -182,6 +182,17 @@ func updateIssuesCommit(userId, repoId int64, repoUserName, repoName string, com } issue.IsClosed = true + if err = issue.GetLabels(); err != nil { + return err + } + for _, label := range issue.Labels { + label.NumClosedIssues++ + + if err = UpdateLabel(label); err != nil { + return err + } + } + if err = UpdateIssue(issue); err != nil { return err } else if err = UpdateIssueUserPairsByStatus(issue.Id, issue.IsClosed); err != nil { @@ -230,6 +241,17 @@ func updateIssuesCommit(userId, repoId int64, repoUserName, repoName string, com } issue.IsClosed = false + if err = issue.GetLabels(); err != nil { + return err + } + for _, label := range issue.Labels { + label.NumClosedIssues-- + + if err = UpdateLabel(label); err != nil { + return err + } + } + if err = UpdateIssue(issue); err != nil { return err } else if err = UpdateIssueUserPairsByStatus(issue.Id, issue.IsClosed); err != nil { diff --git a/models/login.go b/models/login.go index 125e110a..1dc1b6ca 100644 --- a/models/login.go +++ b/models/login.go @@ -231,7 +231,7 @@ func UserSignIn(uname, passwd string) (*User, error) { // Return the same LoginUserPlain semantic // FIXME: https://github.com/gogits/gogs/issues/672 func LoginUserLdapSource(u *User, name, passwd string, sourceId int64, cfg *LDAPConfig, autoRegister bool) (*User, error) { - mail, logged := cfg.Ldapsource.SearchEntry(name, passwd) + name, fn, sn, mail, logged := cfg.Ldapsource.SearchEntry(name, passwd) if !logged { // User not in LDAP, do nothing return nil, ErrUserNotExist @@ -247,6 +247,7 @@ func LoginUserLdapSource(u *User, name, passwd string, sourceId int64, cfg *LDAP u = &User{ Name: name, + FullName: fn + " " + sn, LoginType: LDAP, LoginSource: sourceId, LoginName: name, diff --git a/modules/auth/auth.go b/modules/auth/auth.go index ad7ce5b9..5b24591a 100644 --- a/modules/auth/auth.go +++ b/modules/auth/auth.go @@ -108,17 +108,16 @@ func SignedInUser(req *http.Request, sess session.Store) (*models.User, bool) { auths := strings.Fields(baHead) if len(auths) == 2 && auths[0] == "Basic" { uname, passwd, _ := base.BasicAuthDecode(auths[1]) - u, err := models.GetUserByName(uname) + + u, err := models.UserSignIn(uname, passwd) if err != nil { if err != models.ErrUserNotExist { - log.Error(4, "GetUserByName: %v", err) + log.Error(4, "UserSignIn: %v", err) } return nil, false } - if u.ValidtePassword(passwd) { - return u, true - } + return u, true } } return nil, false diff --git a/modules/auth/auth_form.go b/modules/auth/auth_form.go index e9789634..c7b93896 100644 --- a/modules/auth/auth_form.go +++ b/modules/auth/auth_form.go @@ -18,7 +18,10 @@ type AuthenticationForm struct { Port int `form:"port"` UseSSL bool `form:"usessl"` BaseDN string `form:"base_dn"` - Attributes string `form:"attributes"` + AttributeUsername string `form:"attribute_username"` + AttributeName string `form:"attribute_name"` + AttributeSurname string `form:"attribute_surname"` + AttributeMail string `form:"attribute_mail"` Filter string `form:"filter"` MsAdSA string `form:"ms_ad_sa"` IsActived bool `form:"is_actived"` diff --git a/modules/auth/ldap/ldap.go b/modules/auth/ldap/ldap.go index 44c130a1..c78e241d 100644 --- a/modules/auth/ldap/ldap.go +++ b/modules/auth/ldap/ldap.go @@ -15,15 +15,18 @@ import ( // Basic LDAP authentication service type Ldapsource struct { - Name string // canonical name (ie. corporate.ad) - Host string // LDAP host - Port int // port number - UseSSL bool // Use SSL - BaseDN string // Base DN - Attributes string // Attribute to search - Filter string // Query filter to validate entry - MsAdSAFormat string // in the case of MS AD Simple Authen, the format to use (see: http://msdn.microsoft.com/en-us/library/cc223499.aspx) - Enabled bool // if this source is disabled + Name string // canonical name (ie. corporate.ad) + Host string // LDAP host + Port int // port number + UseSSL bool // Use SSL + BaseDN string // Base DN + AttributeUsername string // Username attribute + AttributeName string // First name attribute + AttributeSurname string // Surname attribute + AttributeMail string // E-mail attribute + Filter string // Query filter to validate entry + MsAdSAFormat string // in the case of MS AD Simple Authen, the format to use (see: http://msdn.microsoft.com/en-us/library/cc223499.aspx) + Enabled bool // if this source is disabled } //Global LDAP directory pool @@ -32,18 +35,18 @@ var ( ) // Add a new source (LDAP directory) to the global pool -func AddSource(name string, host string, port int, usessl bool, basedn string, attributes string, filter string, msadsaformat string) { - ldaphost := Ldapsource{name, host, port, usessl, basedn, attributes, filter, msadsaformat, true} +func AddSource(name string, host string, port int, usessl bool, basedn string, attribcn string, attribname string, attribsn string, attribmail string, filter string, msadsaformat string) { + ldaphost := Ldapsource{name, host, port, usessl, basedn, attribcn, attribname, attribsn, attribmail, filter, msadsaformat, true} Authensource = append(Authensource, ldaphost) } //LoginUser : try to login an user to LDAP sources, return requested (attribute,true) if ok, ("",false) other wise //First match wins //Returns first attribute if exists -func LoginUser(name, passwd string) (a string, r bool) { +func LoginUser(name, passwd string) (cn, fn, sn, mail string, r bool) { r = false for _, ls := range Authensource { - a, r = ls.SearchEntry(name, passwd) + cn, fn, sn, mail, r = ls.SearchEntry(name, passwd) if r { return } @@ -52,12 +55,12 @@ func LoginUser(name, passwd string) (a string, r bool) { } // searchEntry : search an LDAP source if an entry (name, passwd) is valide and in the specific filter -func (ls Ldapsource) SearchEntry(name, passwd string) (string, bool) { +func (ls Ldapsource) SearchEntry(name, passwd string) (string, string, string, string, bool) { l, err := ldapDial(ls) if err != nil { log.Error(4, "LDAP Connect error, %s:%v", ls.Host, err) ls.Enabled = false - return "", false + return "", "", "", "", false } defer l.Close() @@ -65,26 +68,29 @@ func (ls Ldapsource) SearchEntry(name, passwd string) (string, bool) { err = l.Bind(nx, passwd) if err != nil { log.Debug("LDAP Authan failed for %s, reason: %s", nx, err.Error()) - return "", false + return "", "", "", "", false } search := ldap.NewSearchRequest( ls.BaseDN, ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false, fmt.Sprintf(ls.Filter, name), - []string{ls.Attributes}, + []string{ls.AttributeUsername, ls.AttributeName, ls.AttributeSurname, ls.AttributeMail}, nil) sr, err := l.Search(search) if err != nil { log.Debug("LDAP Authen OK but not in filter %s", name) - return "", false + return "", "", "", "", false } log.Debug("LDAP Authen OK: %s", name) if len(sr.Entries) > 0 { - r := sr.Entries[0].GetAttributeValue(ls.Attributes) - return r, true + cn := sr.Entries[0].GetAttributeValue(ls.AttributeUsername) + name := sr.Entries[0].GetAttributeValue(ls.AttributeName) + sn := sr.Entries[0].GetAttributeValue(ls.AttributeSurname) + mail := sr.Entries[0].GetAttributeValue(ls.AttributeMail) + return cn, name, sn, mail, true } - return "", true + return "", "", "", "", true } func ldapDial(ls Ldapsource) (*ldap.Conn, error) { diff --git a/routers/admin/auths.go b/routers/admin/auths.go index e537572b..dcb98d33 100644 --- a/routers/admin/auths.go +++ b/routers/admin/auths.go @@ -63,15 +63,18 @@ func NewAuthSourcePost(ctx *middleware.Context, form auth.AuthenticationForm) { case models.LDAP: u = &models.LDAPConfig{ Ldapsource: ldap.Ldapsource{ - Host: form.Host, - Port: form.Port, - UseSSL: form.UseSSL, - BaseDN: form.BaseDN, - Attributes: form.Attributes, - Filter: form.Filter, - MsAdSAFormat: form.MsAdSA, - Enabled: true, - Name: form.AuthName, + Host: form.Host, + Port: form.Port, + UseSSL: form.UseSSL, + BaseDN: form.BaseDN, + AttributeUsername: form.AttributeUsername, + AttributeName: form.AttributeName, + AttributeSurname: form.AttributeSurname, + AttributeMail: form.AttributeMail, + Filter: form.Filter, + MsAdSAFormat: form.MsAdSA, + Enabled: true, + Name: form.AuthName, }, } case models.SMTP: @@ -142,15 +145,18 @@ func EditAuthSourcePost(ctx *middleware.Context, form auth.AuthenticationForm) { case models.LDAP: config = &models.LDAPConfig{ Ldapsource: ldap.Ldapsource{ - Host: form.Host, - Port: form.Port, - UseSSL: form.UseSSL, - BaseDN: form.BaseDN, - Attributes: form.Attributes, - Filter: form.Filter, - MsAdSAFormat: form.MsAdSA, - Enabled: true, - Name: form.AuthName, + Host: form.Host, + Port: form.Port, + UseSSL: form.UseSSL, + BaseDN: form.BaseDN, + AttributeUsername: form.AttributeUsername, + AttributeName: form.AttributeName, + AttributeSurname: form.AttributeSurname, + AttributeMail: form.AttributeMail, + Filter: form.Filter, + MsAdSAFormat: form.MsAdSA, + Enabled: true, + Name: form.AuthName, }, } case models.SMTP: diff --git a/routers/repo/http.go b/routers/repo/http.go index d47d73ef..3cfc0659 100644 --- a/routers/repo/http.go +++ b/routers/repo/http.go @@ -105,10 +105,10 @@ func Http(ctx *middleware.Context) { return } - authUser, err = models.GetUserByName(authUsername) + authUser, err := models.UserSignIn(authUsername, authPasswd) if err != nil { if err != models.ErrUserNotExist { - ctx.Handle(500, "GetUserByName", err) + ctx.Handle(500, "UserSignIn error: %v", err) return } @@ -128,12 +128,6 @@ func Http(ctx *middleware.Context) { return } authUsername = authUser.Name - } else { - // Check user's password when username is correctly presented. - if !authUser.ValidtePassword(authPasswd) { - ctx.Handle(401, "invalid password", nil) - return - } } if !isPublicPull { diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 40e93389..abe33beb 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -549,6 +549,7 @@ func UpdateIssueLabel(ctx *middleware.Context) { label.NumClosedIssues-- } } + if err = models.UpdateLabel(label); err != nil { ctx.Handle(500, "issue.UpdateIssueLabel(UpdateLabel)", err) return @@ -767,6 +768,24 @@ func Comment(ctx *middleware.Context) { return } + if err = issue.GetLabels(); err != nil { + send(500, nil, err) + return + } + + for _, label := range issue.Labels { + if issue.IsClosed { + label.NumClosedIssues++ + } else { + label.NumClosedIssues-- + } + + if err = models.UpdateLabel(label); err != nil { + send(500, nil, err) + return + } + } + // Change open/closed issue counter for the associated milestone if issue.MilestoneId > 0 { if err = models.ChangeMilestoneIssueStats(issue); err != nil { diff --git a/templates/admin/auth/edit.tmpl b/templates/admin/auth/edit.tmpl index 77d28f62..e1bbd23d 100644 --- a/templates/admin/auth/edit.tmpl +++ b/templates/admin/auth/edit.tmpl @@ -48,8 +48,20 @@ <input class="ipt ipt-large ipt-radius {{if .Err_BaseDN}}ipt-error{{end}}" id="base_dn" name="base_dn" value="{{.Source.LDAP.BaseDN}}" /> </div> <div class="field"> - <label class="req" for="attributes">{{.i18n.Tr "admin.auths.attributes"}}</label> - <input class="ipt ipt-large ipt-radius {{if .Err_Attributes}}ipt-error{{end}}" id="attributes" name="attributes" value="{{.Source.LDAP.Attributes}}" /> + <label class="req" for="attribute_username">{{.i18n.Tr "admin.auths.attribute_username"}}</label> + <input class="ipt ipt-large ipt-radius {{if .Err_Attributes}}ipt-error{{end}}" id="attribute_username" name="attribute_username" value="{{.Source.LDAP.AttributeUsername}}" /> + </div> + <div class="field"> + <label class="req" for="attribute_name">{{.i18n.Tr "admin.auths.attribute_name"}}</label> + <input class="ipt ipt-large ipt-radius {{if .Err_Attributes}}ipt-error{{end}}" id="attribute_name" name="attribute_name" value="{{.Source.LDAP.AttributeName}}" /> + </div> + <div class="field"> + <label class="req" for="attribute_surname">{{.i18n.Tr "admin.auths.attribute_surname"}}</label> + <input class="ipt ipt-large ipt-radius {{if .Err_Attributes}}ipt-error{{end}}" id="attribute_surname" name="attribute_surname" value="{{.Source.LDAP.AttributeSurname}}" /> + </div> + <div class="field"> + <label class="req" for="attribute_mail">{{.i18n.Tr "admin.auths.attribute_mail"}}</label> + <input class="ipt ipt-large ipt-radius {{if .Err_Attributes}}ipt-error{{end}}" id="attribute_mail" name="attribute_mail" value="{{.Source.LDAP.AttributeMail}}" /> </div> <div class="field"> <label class="req" for="filter">{{.i18n.Tr "admin.auths.filter"}}</label> |