Changeset View
Changeset View
Standalone View
Standalone View
src/applications/auth/provider/PhabricatorLDAPAuthProvider.php
| Show All 38 Lines | if (!$this->adapter) { | ||||
| ->setPort( | ->setPort( | ||||
| $conf->getProperty(self::KEY_PORT)) | $conf->getProperty(self::KEY_PORT)) | ||||
| ->setBaseDistinguishedName( | ->setBaseDistinguishedName( | ||||
| $conf->getProperty(self::KEY_DISTINGUISHED_NAME)) | $conf->getProperty(self::KEY_DISTINGUISHED_NAME)) | ||||
| ->setSearchAttributes($search_attributes) | ->setSearchAttributes($search_attributes) | ||||
| ->setUsernameAttribute( | ->setUsernameAttribute( | ||||
| $conf->getProperty(self::KEY_USERNAME_ATTRIBUTE)) | $conf->getProperty(self::KEY_USERNAME_ATTRIBUTE)) | ||||
| ->setRealNameAttributes($realname_attributes) | ->setRealNameAttributes($realname_attributes) | ||||
| ->setEmailAttribute( | |||||
| $conf->getProperty(self::KEY_EMAIL_ATTRIBUTE)) | |||||
| ->setLDAPVersion( | ->setLDAPVersion( | ||||
| $conf->getProperty(self::KEY_VERSION)) | $conf->getProperty(self::KEY_VERSION)) | ||||
| ->setLDAPReferrals( | ->setLDAPReferrals( | ||||
| $conf->getProperty(self::KEY_REFERRALS)) | $conf->getProperty(self::KEY_REFERRALS)) | ||||
| ->setLDAPStartTLS( | ->setLDAPStartTLS( | ||||
| $conf->getProperty(self::KEY_START_TLS)) | $conf->getProperty(self::KEY_START_TLS)) | ||||
| ->setAlwaysSearch($conf->getProperty(self::KEY_ALWAYS_SEARCH)) | ->setAlwaysSearch($conf->getProperty(self::KEY_ALWAYS_SEARCH)) | ||||
| ->setAnonymousUsername( | ->setAnonymousUsername( | ||||
| ▲ Show 20 Lines • Show All 128 Lines • ▼ Show 20 Lines | final class PhabricatorLDAPAuthProvider extends PhabricatorAuthProvider { | ||||
| } | } | ||||
| const KEY_HOSTNAME = 'ldap:host'; | const KEY_HOSTNAME = 'ldap:host'; | ||||
| const KEY_PORT = 'ldap:port'; | const KEY_PORT = 'ldap:port'; | ||||
| const KEY_DISTINGUISHED_NAME = 'ldap:dn'; | const KEY_DISTINGUISHED_NAME = 'ldap:dn'; | ||||
| const KEY_SEARCH_ATTRIBUTES = 'ldap:search-attribute'; | const KEY_SEARCH_ATTRIBUTES = 'ldap:search-attribute'; | ||||
| const KEY_USERNAME_ATTRIBUTE = 'ldap:username-attribute'; | const KEY_USERNAME_ATTRIBUTE = 'ldap:username-attribute'; | ||||
| const KEY_EMAIL_ATTRIBUTE = 'ldap:email-attribute'; | |||||
| const KEY_REALNAME_ATTRIBUTES = 'ldap:realname-attributes'; | const KEY_REALNAME_ATTRIBUTES = 'ldap:realname-attributes'; | ||||
| const KEY_VERSION = 'ldap:version'; | const KEY_VERSION = 'ldap:version'; | ||||
| const KEY_REFERRALS = 'ldap:referrals'; | const KEY_REFERRALS = 'ldap:referrals'; | ||||
| const KEY_START_TLS = 'ldap:start-tls'; | const KEY_START_TLS = 'ldap:start-tls'; | ||||
| const KEY_ANONYMOUS_USERNAME = 'ldap:anoynmous-username'; | const KEY_ANONYMOUS_USERNAME = 'ldap:anoynmous-username'; | ||||
| const KEY_ANONYMOUS_PASSWORD = 'ldap:anonymous-password'; | const KEY_ANONYMOUS_PASSWORD = 'ldap:anonymous-password'; | ||||
| const KEY_ALWAYS_SEARCH = 'ldap:always-search'; | const KEY_ALWAYS_SEARCH = 'ldap:always-search'; | ||||
| const KEY_ACTIVEDIRECTORY_DOMAIN = 'ldap:activedirectory-domain'; | const KEY_ACTIVEDIRECTORY_DOMAIN = 'ldap:activedirectory-domain'; | ||||
| private function getPropertyKeys() { | private function getPropertyKeys() { | ||||
| return array_keys($this->getPropertyLabels()); | return array_keys($this->getPropertyLabels()); | ||||
| } | } | ||||
| private function getPropertyLabels() { | private function getPropertyLabels() { | ||||
| return array( | return array( | ||||
| self::KEY_HOSTNAME => pht('LDAP Hostname'), | self::KEY_HOSTNAME => pht('LDAP Hostname'), | ||||
| self::KEY_PORT => pht('LDAP Port'), | self::KEY_PORT => pht('LDAP Port'), | ||||
| self::KEY_DISTINGUISHED_NAME => pht('Base Distinguished Name'), | self::KEY_DISTINGUISHED_NAME => pht('Base Distinguished Name'), | ||||
| self::KEY_SEARCH_ATTRIBUTES => pht('Search Attributes'), | self::KEY_SEARCH_ATTRIBUTES => pht('Search Attributes'), | ||||
| self::KEY_ALWAYS_SEARCH => pht('Always Search'), | self::KEY_ALWAYS_SEARCH => pht('Always Search'), | ||||
| self::KEY_ANONYMOUS_USERNAME => pht('Anonymous Username'), | self::KEY_ANONYMOUS_USERNAME => pht('Anonymous Username'), | ||||
| self::KEY_ANONYMOUS_PASSWORD => pht('Anonymous Password'), | self::KEY_ANONYMOUS_PASSWORD => pht('Anonymous Password'), | ||||
| self::KEY_USERNAME_ATTRIBUTE => pht('Username Attribute'), | self::KEY_USERNAME_ATTRIBUTE => pht('Username Attribute'), | ||||
| self::KEY_EMAIL_ATTRIBUTE => pht('Email Attribute'), | |||||
| self::KEY_REALNAME_ATTRIBUTES => pht('Realname Attributes'), | self::KEY_REALNAME_ATTRIBUTES => pht('Realname Attributes'), | ||||
| self::KEY_VERSION => pht('LDAP Version'), | self::KEY_VERSION => pht('LDAP Version'), | ||||
| self::KEY_REFERRALS => pht('Enable Referrals'), | self::KEY_REFERRALS => pht('Enable Referrals'), | ||||
| self::KEY_START_TLS => pht('Use TLS'), | self::KEY_START_TLS => pht('Use TLS'), | ||||
| self::KEY_ACTIVEDIRECTORY_DOMAIN => pht('ActiveDirectory Domain'), | self::KEY_ACTIVEDIRECTORY_DOMAIN => pht('ActiveDirectory Domain'), | ||||
| ); | ); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | $captions = array( | ||||
| phutil_tag('br'), | phutil_tag('br'), | ||||
| phutil_tag('tt', array(), pht('ldaps://ldaps.example.com/'))), | phutil_tag('tt', array(), pht('ldaps://ldaps.example.com/'))), | ||||
| self::KEY_DISTINGUISHED_NAME => | self::KEY_DISTINGUISHED_NAME => | ||||
| pht('Example: %s', | pht('Example: %s', | ||||
| phutil_tag('tt', array(), pht('ou=People, dc=example, dc=com'))), | phutil_tag('tt', array(), pht('ou=People, dc=example, dc=com'))), | ||||
| self::KEY_USERNAME_ATTRIBUTE => | self::KEY_USERNAME_ATTRIBUTE => | ||||
| pht('Example: %s', | pht('Example: %s', | ||||
| phutil_tag('tt', array(), pht('sn'))), | phutil_tag('tt', array(), pht('sn'))), | ||||
| self::KEY_EMAIL_ATTRIBUTE => | |||||
| pht('Example: %s', | |||||
| phutil_tag('tt', array(), pht('userPrincipalName'))), | |||||
| self::KEY_REALNAME_ATTRIBUTES => | self::KEY_REALNAME_ATTRIBUTES => | ||||
| pht('Example: %s', | pht('Example: %s', | ||||
| phutil_tag('tt', array(), pht('firstname, lastname'))), | phutil_tag('tt', array(), pht('firstname, lastname'))), | ||||
| self::KEY_REFERRALS => | self::KEY_REFERRALS => | ||||
| pht('Follow referrals. Disable this for Windows AD 2003.'), | pht('Follow referrals. Disable this for Windows AD 2003.'), | ||||
| self::KEY_START_TLS => | self::KEY_START_TLS => | ||||
| pht('Start TLS after binding to the LDAP server.'), | pht('Start TLS after binding to the LDAP server.'), | ||||
| self::KEY_ALWAYS_SEARCH => | self::KEY_ALWAYS_SEARCH => | ||||
| ▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | $instructions = array( | ||||
| 'affect the login process, but you can configure it to make sure '. | 'affect the login process, but you can configure it to make sure '. | ||||
| 'users get the same default username as their LDAP username, so '. | 'users get the same default username as their LDAP username, so '. | ||||
| 'usernames remain consistent across systems.'), | 'usernames remain consistent across systems.'), | ||||
| self::KEY_REALNAME_ATTRIBUTES => pht( | self::KEY_REALNAME_ATTRIBUTES => pht( | ||||
| 'Optionally, specify one or more comma-separated attributes to use to '. | 'Optionally, specify one or more comma-separated attributes to use to '. | ||||
| 'prefill the "Real Name" field when registering a new account. This '. | 'prefill the "Real Name" field when registering a new account. This '. | ||||
| 'is purely cosmetic and does not affect the login process, but can '. | 'is purely cosmetic and does not affect the login process, but can '. | ||||
| 'make registration a little easier.'), | 'make registration a little easier.'), | ||||
| self::KEY_EMAIL_ATTRIBUTE => pht( | |||||
| "Optionally, specify an attribute to use to select the user's email."), | |||||
| ); | ); | ||||
| foreach ($labels as $key => $label) { | foreach ($labels as $key => $label) { | ||||
| $caption = idx($captions, $key); | $caption = idx($captions, $key); | ||||
| $type = idx($types, $key); | $type = idx($types, $key); | ||||
| $value = idx($values, $key); | $value = idx($values, $key); | ||||
| $control = null; | $control = null; | ||||
| ▲ Show 20 Lines • Show All 108 Lines • Show Last 20 Lines | |||||