code
stringlengths
15
9.96M
docstring
stringlengths
1
10.1k
func_name
stringlengths
1
124
language
stringclasses
1 value
repo
stringlengths
7
63
path
stringlengths
6
186
url
stringlengths
50
236
license
stringclasses
4 values
private function loadMercurialBranchPositions( PhabricatorRepository $repository) { return id(new DiffusionLowLevelMercurialBranchesQuery()) ->setRepository($repository) ->execute(); }
@task hg
loadMercurialBranchPositions
php
phorgeit/phorge
src/applications/repository/engine/PhabricatorRepositoryRefEngine.php
https://github.com/phorgeit/phorge/blob/master/src/applications/repository/engine/PhabricatorRepositoryRefEngine.php
Apache-2.0
private function loadMercurialBookmarkPositions( PhabricatorRepository $repository) { // TODO: Implement support for Mercurial bookmarks. return array(); }
@task hg
loadMercurialBookmarkPositions
php
phorgeit/phorge
src/applications/repository/engine/PhabricatorRepositoryRefEngine.php
https://github.com/phorgeit/phorge/blob/master/src/applications/repository/engine/PhabricatorRepositoryRefEngine.php
Apache-2.0
public function setRepository(PhabricatorRepository $repository) { $this->repository = $repository; return $this; }
@task config
setRepository
php
phorgeit/phorge
src/applications/repository/engine/PhabricatorRepositoryEngine.php
https://github.com/phorgeit/phorge/blob/master/src/applications/repository/engine/PhabricatorRepositoryEngine.php
Apache-2.0
protected function getRepository() { if ($this->repository === null) { throw new PhutilInvalidStateException('setRepository'); } return $this->repository; }
@task config
getRepository
php
phorgeit/phorge
src/applications/repository/engine/PhabricatorRepositoryEngine.php
https://github.com/phorgeit/phorge/blob/master/src/applications/repository/engine/PhabricatorRepositoryEngine.php
Apache-2.0
public function setVerbose($verbose) { $this->verbose = $verbose; return $this; }
@task config
setVerbose
php
phorgeit/phorge
src/applications/repository/engine/PhabricatorRepositoryEngine.php
https://github.com/phorgeit/phorge/blob/master/src/applications/repository/engine/PhabricatorRepositoryEngine.php
Apache-2.0
public function getVerbose() { return $this->verbose; }
@task config
getVerbose
php
phorgeit/phorge
src/applications/repository/engine/PhabricatorRepositoryEngine.php
https://github.com/phorgeit/phorge/blob/master/src/applications/repository/engine/PhabricatorRepositoryEngine.php
Apache-2.0
protected function log($pattern /* ... */) { if ($this->getVerbose()) { $console = PhutilConsole::getConsole(); $argv = func_get_args(); array_unshift($argv, "%s\n"); call_user_func_array(array($console, 'writeOut'), $argv); } return $this; }
@task internal
log
php
phorgeit/phorge
src/applications/repository/engine/PhabricatorRepositoryEngine.php
https://github.com/phorgeit/phorge/blob/master/src/applications/repository/engine/PhabricatorRepositoryEngine.php
Apache-2.0
private function executeGitCreate() { $repository = $this->getRepository(); $path = rtrim($repository->getLocalPath(), '/'); // See T13448. In all cases, we create repositories by using "git init" // to build a bare, empty working copy. If we try to use "git clone" // instead, we'll pull in too many refs if "Fetch Refs" is also // configured. There's no apparent way to make "git clone" behave narrowly // and no apparent reason to bother. $repository->execxRemoteCommand( 'init --bare -- %s', $path); }
@task git
executeGitCreate
php
phorgeit/phorge
src/applications/repository/engine/PhabricatorRepositoryPullEngine.php
https://github.com/phorgeit/phorge/blob/master/src/applications/repository/engine/PhabricatorRepositoryPullEngine.php
Apache-2.0
private function installGitHook() { $repository = $this->getRepository(); $root = $repository->getLocalPath(); if ($repository->isWorkingCopyBare()) { $path = '/hooks/pre-receive'; } else { $path = '/.git/hooks/pre-receive'; } $this->installHook($root.$path); }
@task git
installGitHook
php
phorgeit/phorge
src/applications/repository/engine/PhabricatorRepositoryPullEngine.php
https://github.com/phorgeit/phorge/blob/master/src/applications/repository/engine/PhabricatorRepositoryPullEngine.php
Apache-2.0
private function executeMercurialCreate() { $repository = $this->getRepository(); $path = rtrim($repository->getLocalPath(), '/'); if ($repository->isHosted()) { $repository->execxRemoteCommand( 'init -- %s', $path); } else { $remote = $repository->getRemoteURIEnvelope(); // NOTE: Mercurial prior to 3.2.4 has an severe command injection // vulnerability. See: <http://bit.ly/19B58E9> // On vulnerable versions of Mercurial, we refuse to clone remotes which // contain characters which may be interpreted by the shell. $hg_binary = PhutilBinaryAnalyzer::getForBinary('hg'); $is_vulnerable = $hg_binary->isMercurialVulnerableToInjection(); if ($is_vulnerable) { $cleartext = $remote->openEnvelope(); // The use of "%R" here is an attempt to limit collateral damage // for normal URIs because it isn't clear how long this vulnerability // has been around for. $escaped = csprintf('%R', $cleartext); if ((string)$escaped !== (string)$cleartext) { throw new Exception( pht( 'You have an old version of Mercurial (%s) which has a severe '. 'command injection security vulnerability. The remote URI for '. 'this repository (%s) is potentially unsafe. Upgrade Mercurial '. 'to at least 3.2.4 to clone it.', $hg_binary->getBinaryVersion(), $repository->getMonogram())); } } try { $repository->execxRemoteCommand( 'clone --noupdate -- %P %s', $remote, $path); } catch (Exception $ex) { $message = $ex->getMessage(); $message = $this->censorMercurialErrorMessage($message); throw new Exception($message); } } }
@task hg
executeMercurialCreate
php
phorgeit/phorge
src/applications/repository/engine/PhabricatorRepositoryPullEngine.php
https://github.com/phorgeit/phorge/blob/master/src/applications/repository/engine/PhabricatorRepositoryPullEngine.php
Apache-2.0
private function executeMercurialUpdate() { $repository = $this->getRepository(); $path = $repository->getLocalPath(); // This is a local command, but needs credentials. $remote = $repository->getRemoteURIEnvelope(); $future = $repository->getRemoteCommandFuture('pull -- %P', $remote); $future->setCWD($path); try { $future->resolvex(); } catch (CommandException $ex) { $err = $ex->getError(); $stdout = $ex->getStdout(); // NOTE: Between versions 2.1 and 2.1.1, Mercurial changed the behavior // of "hg pull" to return 1 in case of a successful pull with no changes. // This behavior has been reverted, but users who updated between Feb 1, // 2012 and Mar 1, 2012 will have the erroring version. Do a dumb test // against stdout to check for this possibility. // NOTE: Mercurial has translated versions, which translate this error // string. In a translated version, the string will be something else, // like "aucun changement trouve". There didn't seem to be an easy way // to handle this (there are hard ways but this is not a common problem // and only creates log spam, not application failures). Assume English. // TODO: Remove this once we're far enough in the future that deployment // of 2.1 is exceedingly rare? if ($err == 1 && preg_match('/no changes found/', $stdout)) { return; } else { $message = $ex->getMessage(); $message = $this->censorMercurialErrorMessage($message); throw new Exception($message); } } }
@task hg
executeMercurialUpdate
php
phorgeit/phorge
src/applications/repository/engine/PhabricatorRepositoryPullEngine.php
https://github.com/phorgeit/phorge/blob/master/src/applications/repository/engine/PhabricatorRepositoryPullEngine.php
Apache-2.0
private function censorMercurialErrorMessage($message) { return preg_replace( '/^---%<---.*/sm', pht('<Response body omitted from Mercurial error message.>')."\n", $message); }
Censor response bodies from Mercurial error messages. When Mercurial attempts to clone an HTTP repository but does not receive a response it expects, it emits the response body in the command output. This represents a potential SSRF issue, because an attacker with permission to create repositories can create one which points at the remote URI for some local service, then read the response from the error message. To prevent this, censor response bodies out of error messages. @param string $message Uncensored Mercurial command output. @return string Censored Mercurial command output.
censorMercurialErrorMessage
php
phorgeit/phorge
src/applications/repository/engine/PhabricatorRepositoryPullEngine.php
https://github.com/phorgeit/phorge/blob/master/src/applications/repository/engine/PhabricatorRepositoryPullEngine.php
Apache-2.0
private function installMercurialHook() { $repository = $this->getRepository(); $path = $repository->getLocalPath().'/.hg/hgrc'; $identifier = $this->getHookContextIdentifier($repository); $root = dirname(phutil_get_library_root('phabricator')); $bin = $root.'/bin/commit-hook'; $data = array(); $data[] = '[hooks]'; // This hook handles normal pushes. $data[] = csprintf( 'pretxnchangegroup.phabricator = TERM=dumb %s %s %s', $bin, $identifier, 'pretxnchangegroup'); // This one handles creating bookmarks. $data[] = csprintf( 'prepushkey.phabricator = TERM=dumb %s %s %s', $bin, $identifier, 'prepushkey'); $data[] = null; $data = implode("\n", $data); $this->log('%s', pht('Installing commit hook config to "%s"...', $path)); Filesystem::writeFile($path, $data); }
@task hg
installMercurialHook
php
phorgeit/phorge
src/applications/repository/engine/PhabricatorRepositoryPullEngine.php
https://github.com/phorgeit/phorge/blob/master/src/applications/repository/engine/PhabricatorRepositoryPullEngine.php
Apache-2.0
private function executeSubversionCreate() { $repository = $this->getRepository(); $path = rtrim($repository->getLocalPath(), '/'); execx('svnadmin create -- %s', $path); }
@task svn
executeSubversionCreate
php
phorgeit/phorge
src/applications/repository/engine/PhabricatorRepositoryPullEngine.php
https://github.com/phorgeit/phorge/blob/master/src/applications/repository/engine/PhabricatorRepositoryPullEngine.php
Apache-2.0
private function installSubversionHook() { $repository = $this->getRepository(); $root = $repository->getLocalPath(); $path = '/hooks/pre-commit'; $this->installHook($root.$path); $revprop_path = '/hooks/pre-revprop-change'; $revprop_argv = array( '--hook-mode', 'svn-revprop', ); $this->installHook($root.$revprop_path, $revprop_argv); }
@task svn
installSubversionHook
php
phorgeit/phorge
src/applications/repository/engine/PhabricatorRepositoryPullEngine.php
https://github.com/phorgeit/phorge/blob/master/src/applications/repository/engine/PhabricatorRepositoryPullEngine.php
Apache-2.0
public function isCreateable() { return true; }
Can users create new credentials of this type? @return bool True if new credentials of this type can be created.
isCreateable
php
phorgeit/phorge
src/applications/passphrase/credentialtype/PassphraseCredentialType.php
https://github.com/phorgeit/phorge/blob/master/src/applications/passphrase/credentialtype/PassphraseCredentialType.php
Apache-2.0
public function shouldShowPasswordField() { return false; }
Return true to show an additional "Password" field. This is used by SSH credentials to strip passwords off private keys. @return bool True if a password field should be shown to the user. @task password
shouldShowPasswordField
php
phorgeit/phorge
src/applications/passphrase/credentialtype/PassphraseCredentialType.php
https://github.com/phorgeit/phorge/blob/master/src/applications/passphrase/credentialtype/PassphraseCredentialType.php
Apache-2.0
public function getPasswordLabel() { return pht('Password'); }
Return the label for the password field, if one is shown. @return string Human-readable field label. @task password
getPasswordLabel
php
phorgeit/phorge
src/applications/passphrase/credentialtype/PassphraseCredentialType.php
https://github.com/phorgeit/phorge/blob/master/src/applications/passphrase/credentialtype/PassphraseCredentialType.php
Apache-2.0
public function generateData() { return PhabricatorStartup::getPhases(); }
@phutil-external-symbol class PhabricatorStartup
generateData
php
phorgeit/phorge
src/applications/console/plugin/DarkConsoleStartupPlugin.php
https://github.com/phorgeit/phorge/blob/master/src/applications/console/plugin/DarkConsoleStartupPlugin.php
Apache-2.0
private static function startProfiler() { PhabricatorStartup::beginStartupPhase('profiler.init'); self::includeXHProfLib(); xhprof_enable(); self::$profilerStarted = true; self::$profilerRunning = true; }
@phutil-external-symbol class PhabricatorStartup
startProfiler
php
phorgeit/phorge
src/applications/console/plugin/xhprof/DarkConsoleXHProfPluginAPI.php
https://github.com/phorgeit/phorge/blob/master/src/applications/console/plugin/xhprof/DarkConsoleXHProfPluginAPI.php
Apache-2.0
public static function getProfileFilePHID() { if (!self::isProfilerRunning()) { return; } PhabricatorStartup::beginStartupPhase('profiler.stop'); self::stopProfiler(); PhabricatorStartup::beginStartupPhase('profiler.done'); return self::$profileFilePHID; }
@phutil-external-symbol class PhabricatorStartup
getProfileFilePHID
php
phorgeit/phorge
src/applications/console/plugin/xhprof/DarkConsoleXHProfPluginAPI.php
https://github.com/phorgeit/phorge/blob/master/src/applications/console/plugin/xhprof/DarkConsoleXHProfPluginAPI.php
Apache-2.0
public function setKey($key) { $this->key = $key; return $this; }
Set the primary key for the field, like `projectPHIDs`. You can set human-readable aliases with @{method:setAliases}. The key should be a short, unique (within a search engine) string which does not contain any special characters. @param string $key Unique key which identifies the field. @return $this @task config
setKey
php
phorgeit/phorge
src/applications/search/field/PhabricatorSearchField.php
https://github.com/phorgeit/phorge/blob/master/src/applications/search/field/PhabricatorSearchField.php
Apache-2.0
public function getKey() { return $this->key; }
Get the field's key. @return string Unique key for this field. @task config
getKey
php
phorgeit/phorge
src/applications/search/field/PhabricatorSearchField.php
https://github.com/phorgeit/phorge/blob/master/src/applications/search/field/PhabricatorSearchField.php
Apache-2.0
public function setLabel($label) { $this->label = $label; return $this; }
Set a human-readable label for the field. This should be a short text string, like "Reviewers" or "Colors". @param string $label Short, human-readable field label. @return $this task config
setLabel
php
phorgeit/phorge
src/applications/search/field/PhabricatorSearchField.php
https://github.com/phorgeit/phorge/blob/master/src/applications/search/field/PhabricatorSearchField.php
Apache-2.0
public function getLabel() { return $this->label; }
Get the field's human-readable label. @return string Short, human-readable field label. @task config
getLabel
php
phorgeit/phorge
src/applications/search/field/PhabricatorSearchField.php
https://github.com/phorgeit/phorge/blob/master/src/applications/search/field/PhabricatorSearchField.php
Apache-2.0
public function setViewer(PhabricatorUser $viewer) { $this->viewer = $viewer; return $this; }
Set the acting viewer. Engines do not need to do this explicitly; it will be done on their behalf by the caller. @param PhabricatorUser $viewer Viewer. @return $this @task config
setViewer
php
phorgeit/phorge
src/applications/search/field/PhabricatorSearchField.php
https://github.com/phorgeit/phorge/blob/master/src/applications/search/field/PhabricatorSearchField.php
Apache-2.0
public function getViewer() { return $this->viewer; }
Get the acting viewer. @return PhabricatorUser Viewer. @task config
getViewer
php
phorgeit/phorge
src/applications/search/field/PhabricatorSearchField.php
https://github.com/phorgeit/phorge/blob/master/src/applications/search/field/PhabricatorSearchField.php
Apache-2.0
public function setAliases(array $aliases) { $this->aliases = $aliases; return $this; }
Provide alternate field aliases, usually more human-readable versions of the key. These aliases can be used when building GET requests, so you can provide an alias like `authors` to let users write `&authors=alincoln` instead of `&authorPHIDs=alincoln`. This is a little easier to use. @param list<string> $aliases List of aliases for this field. @return $this @task config
setAliases
php
phorgeit/phorge
src/applications/search/field/PhabricatorSearchField.php
https://github.com/phorgeit/phorge/blob/master/src/applications/search/field/PhabricatorSearchField.php
Apache-2.0
public function getAliases() { return $this->aliases; }
Get aliases for this field. @return list<string> List of aliases for this field. @task config
getAliases
php
phorgeit/phorge
src/applications/search/field/PhabricatorSearchField.php
https://github.com/phorgeit/phorge/blob/master/src/applications/search/field/PhabricatorSearchField.php
Apache-2.0
public function setConduitKey($conduit_key) { $this->conduitKey = $conduit_key; return $this; }
Provide an alternate field key for Conduit. This can allow you to choose a more usable key for API endpoints. If no key is provided, the main key is used. @param string $conduit_key Alternate key for Conduit. @return $this @task config
setConduitKey
php
phorgeit/phorge
src/applications/search/field/PhabricatorSearchField.php
https://github.com/phorgeit/phorge/blob/master/src/applications/search/field/PhabricatorSearchField.php
Apache-2.0
public function getConduitKey() { if ($this->conduitKey !== null) { return $this->conduitKey; } return $this->getKey(); }
Get the field key for use in Conduit. @return string Conduit key for this field. @task config
getConduitKey
php
phorgeit/phorge
src/applications/search/field/PhabricatorSearchField.php
https://github.com/phorgeit/phorge/blob/master/src/applications/search/field/PhabricatorSearchField.php
Apache-2.0
public function setDescription($description) { $this->description = $description; return $this; }
Set a human-readable description for this field. @param string $description Human-readable description. @return $this @task config
setDescription
php
phorgeit/phorge
src/applications/search/field/PhabricatorSearchField.php
https://github.com/phorgeit/phorge/blob/master/src/applications/search/field/PhabricatorSearchField.php
Apache-2.0
public function getDescription() { return $this->description; }
Get this field's human-readable description. @return string|null Human-readable description. @task config
getDescription
php
phorgeit/phorge
src/applications/search/field/PhabricatorSearchField.php
https://github.com/phorgeit/phorge/blob/master/src/applications/search/field/PhabricatorSearchField.php
Apache-2.0
public function setIsHidden($is_hidden) { $this->isHidden = $is_hidden; return $this; }
Hide this field from the web UI. @param bool $is_hidden True to hide the field from the web UI. @return $this @task config
setIsHidden
php
phorgeit/phorge
src/applications/search/field/PhabricatorSearchField.php
https://github.com/phorgeit/phorge/blob/master/src/applications/search/field/PhabricatorSearchField.php
Apache-2.0
public function getIsHidden() { return $this->isHidden; }
Should this field be hidden from the web UI? @return bool True to hide the field in the web UI. @task config
getIsHidden
php
phorgeit/phorge
src/applications/search/field/PhabricatorSearchField.php
https://github.com/phorgeit/phorge/blob/master/src/applications/search/field/PhabricatorSearchField.php
Apache-2.0
final public function getConduitParameterType() { if (!$this->getEnableForConduit()) { return false; } $type = $this->newConduitParameterType(); if ($type) { $type->setViewer($this->getViewer()); } return $type; }
@task conduit
getConduitParameterType
php
phorgeit/phorge
src/applications/search/field/PhabricatorSearchField.php
https://github.com/phorgeit/phorge/blob/master/src/applications/search/field/PhabricatorSearchField.php
Apache-2.0
protected function getListFromRequest( AphrontRequest $request, $key) { $list = $request->getArr($key, null); if ($list === null) { $list = $request->getStrList($key); } if (!$list) { return array(); } return $list; }
Read a list of items from the request, in either array format or string format: list[]=item1&list[]=item2 list=item1,item2 This provides flexibility when constructing URIs, especially from external sources. @param AphrontRequest $request Request to read strings from. @param string $key Key to read in the request. @return list<string> List of values. @task utility
getListFromRequest
php
phorgeit/phorge
src/applications/search/field/PhabricatorSearchField.php
https://github.com/phorgeit/phorge/blob/master/src/applications/search/field/PhabricatorSearchField.php
Apache-2.0
private function applyStemmer($normalized_token) { // If the token has internal punctuation, handle it literally. This // deals with things like domain names, Conduit API methods, and other // sorts of informal tokens. if (preg_match('/[._]/', $normalized_token)) { return $normalized_token; } static $loaded; if ($loaded === null) { $root = dirname(phutil_get_library_root('phabricator')); require_once $root.'/externals/porter-stemmer/src/Porter.php'; $loaded = true; } $stem = Porter::stem($normalized_token); // If the stem is too short, it won't be a candidate for indexing. These // tokens are also likely to be acronyms (like "DNS") rather than real // English words. if (strlen($stem) < 3) { return $normalized_token; } return $stem; }
@phutil-external-symbol class Porter
applyStemmer
php
phorgeit/phorge
src/applications/search/compiler/PhutilSearchStemmer.php
https://github.com/phorgeit/phorge/blob/master/src/applications/search/compiler/PhutilSearchStemmer.php
Apache-2.0
public function isMenuEnginePinnable() { return !$this->isMenuEnginePersonalizable(); }
Does this engine support pinning items? Personalizable menus disable pinning by default since it creates a number of weird edge cases without providing many benefits for current menus. @return bool True if items may be pinned as default items.
isMenuEnginePinnable
php
phorgeit/phorge
src/applications/search/engine/PhabricatorProfileMenuEngine.php
https://github.com/phorgeit/phorge/blob/master/src/applications/search/engine/PhabricatorProfileMenuEngine.php
Apache-2.0
protected function willUseSavedQuery(PhabricatorSavedQuery $saved) { return; }
Hook for subclasses to adjust saved queries prior to use. If an application changes how queries are saved, it can implement this hook to keep old queries working the way users expect, by reading, adjusting, and overwriting parameters. @param PhabricatorSavedQuery $saved Saved query which will be executed. @return void
willUseSavedQuery
php
phorgeit/phorge
src/applications/search/engine/PhabricatorApplicationSearchEngine.php
https://github.com/phorgeit/phorge/blob/master/src/applications/search/engine/PhabricatorApplicationSearchEngine.php
Apache-2.0
protected function getHiddenFields() { return array(); }
Return a list of field keys which should be hidden from the viewer. @return list<string> Fields to hide.
getHiddenFields
php
phorgeit/phorge
src/applications/search/engine/PhabricatorApplicationSearchEngine.php
https://github.com/phorgeit/phorge/blob/master/src/applications/search/engine/PhabricatorApplicationSearchEngine.php
Apache-2.0
public function getQueryResultsPageURI($query_key) { return $this->getURI('query/'.$query_key.'/'); }
Return an application URI corresponding to the results page of a query. Normally, this is something like `/application/query/QUERYKEY/`. @param string $query_key The query key to build a URI for. @return string URI where the query can be executed. @task uri
getQueryResultsPageURI
php
phorgeit/phorge
src/applications/search/engine/PhabricatorApplicationSearchEngine.php
https://github.com/phorgeit/phorge/blob/master/src/applications/search/engine/PhabricatorApplicationSearchEngine.php
Apache-2.0
public function getQueryManagementURI() { return $this->getURI('query/edit/'); }
Return an application URI for query management. This is used when, e.g., a query deletion operation is cancelled. @return string URI where queries can be managed. @task uri
getQueryManagementURI
php
phorgeit/phorge
src/applications/search/engine/PhabricatorApplicationSearchEngine.php
https://github.com/phorgeit/phorge/blob/master/src/applications/search/engine/PhabricatorApplicationSearchEngine.php
Apache-2.0
public static function getAllEngines() { return id(new PhutilClassMapQuery()) ->setAncestorClass(__CLASS__) ->execute(); }
Load all available application search engines. @return list<PhabricatorApplicationSearchEngine> All available engines. @task construct
getAllEngines
php
phorgeit/phorge
src/applications/search/engine/PhabricatorApplicationSearchEngine.php
https://github.com/phorgeit/phorge/blob/master/src/applications/search/engine/PhabricatorApplicationSearchEngine.php
Apache-2.0
public static function getEngineByClassName($class_name) { return idx(self::getAllEngines(), $class_name); }
Get an engine by class name, if it exists. @return PhabricatorApplicationSearchEngine|null Engine, or null if it does not exist. @task construct
getEngineByClassName
php
phorgeit/phorge
src/applications/search/engine/PhabricatorApplicationSearchEngine.php
https://github.com/phorgeit/phorge/blob/master/src/applications/search/engine/PhabricatorApplicationSearchEngine.php
Apache-2.0
public function getBuiltinQuery($query_key) { if (!$this->isBuiltinQuery($query_key)) { throw new Exception(pht("'%s' is not a builtin!", $query_key)); } return idx($this->getBuiltinQueries(), $query_key); }
@task builtin
getBuiltinQuery
php
phorgeit/phorge
src/applications/search/engine/PhabricatorApplicationSearchEngine.php
https://github.com/phorgeit/phorge/blob/master/src/applications/search/engine/PhabricatorApplicationSearchEngine.php
Apache-2.0
protected function getBuiltinQueryNames() { return array(); }
@task builtin
getBuiltinQueryNames
php
phorgeit/phorge
src/applications/search/engine/PhabricatorApplicationSearchEngine.php
https://github.com/phorgeit/phorge/blob/master/src/applications/search/engine/PhabricatorApplicationSearchEngine.php
Apache-2.0
public function isBuiltinQuery($query_key) { $builtins = $this->getBuiltinQueries(); return isset($builtins[$query_key]); }
@task builtin
isBuiltinQuery
php
phorgeit/phorge
src/applications/search/engine/PhabricatorApplicationSearchEngine.php
https://github.com/phorgeit/phorge/blob/master/src/applications/search/engine/PhabricatorApplicationSearchEngine.php
Apache-2.0
public function buildSavedQueryFromBuiltin($query_key) { throw new Exception(pht("Builtin '%s' is not supported!", $query_key)); }
@task builtin
buildSavedQueryFromBuiltin
php
phorgeit/phorge
src/applications/search/engine/PhabricatorApplicationSearchEngine.php
https://github.com/phorgeit/phorge/blob/master/src/applications/search/engine/PhabricatorApplicationSearchEngine.php
Apache-2.0
protected function readSubscribersFromRequest( AphrontRequest $request, $key) { return $this->readUsersFromRequest( $request, $key, array( PhabricatorProjectProjectPHIDType::TYPECONST, )); }
Read a list of subscribers from a request in a flexible way. @param AphrontRequest $request Request to read PHIDs from. @param string $key Key to read in the request. @return list<string> List of object PHIDs. @task read
readSubscribersFromRequest
php
phorgeit/phorge
src/applications/search/engine/PhabricatorApplicationSearchEngine.php
https://github.com/phorgeit/phorge/blob/master/src/applications/search/engine/PhabricatorApplicationSearchEngine.php
Apache-2.0
protected function readListFromRequest( AphrontRequest $request, $key) { $list = $request->getArr($key, null); if ($list === null) { $list = $request->getStrList($key); } if (!$list) { return array(); } return $list; }
Read a list of items from the request, in either array format or string format: list[]=item1&list[]=item2 list=item1,item2 This provides flexibility when constructing URIs, especially from external sources. @param AphrontRequest $request Request to read strings from. @param string $key Key to read in the request. @return list<string> List of values.
readListFromRequest
php
phorgeit/phorge
src/applications/search/engine/PhabricatorApplicationSearchEngine.php
https://github.com/phorgeit/phorge/blob/master/src/applications/search/engine/PhabricatorApplicationSearchEngine.php
Apache-2.0
protected function parseDateTime($date_time) { if (!strlen($date_time)) { return null; } return PhabricatorTime::parseLocalTime($date_time, $this->requireViewer()); }
@task dates
parseDateTime
php
phorgeit/phorge
src/applications/search/engine/PhabricatorApplicationSearchEngine.php
https://github.com/phorgeit/phorge/blob/master/src/applications/search/engine/PhabricatorApplicationSearchEngine.php
Apache-2.0
protected function buildDateRange( AphrontFormView $form, PhabricatorSavedQuery $saved_query, $start_key, $start_name, $end_key, $end_name) { $start_str = $saved_query->getParameter($start_key); $start = null; if (strlen($start_str)) { $start = $this->parseDateTime($start_str); if (!$start) { $this->addError( pht( '"%s" date can not be parsed.', $start_name)); } } $end_str = $saved_query->getParameter($end_key); $end = null; if (strlen($end_str)) { $end = $this->parseDateTime($end_str); if (!$end) { $this->addError( pht( '"%s" date can not be parsed.', $end_name)); } } if ($start && $end && ($start >= $end)) { $this->addError( pht( '"%s" must be a date before "%s".', $start_name, $end_name)); } $form ->appendChild( id(new PHUIFormFreeformDateControl()) ->setName($start_key) ->setLabel($start_name) ->setValue($start_str)) ->appendChild( id(new AphrontFormTextControl()) ->setName($end_key) ->setLabel($end_name) ->setValue($end_str)); }
@task dates
buildDateRange
php
phorgeit/phorge
src/applications/search/engine/PhabricatorApplicationSearchEngine.php
https://github.com/phorgeit/phorge/blob/master/src/applications/search/engine/PhabricatorApplicationSearchEngine.php
Apache-2.0
final public function renderNewUserView() { $body = $this->getNewUserBody(); if (!$body) { return null; } return $body; }
Render a content body (if available) to onboard new users. This body is usually visible when you have no elements in a list, or when you force the rendering on a list with the `?nux=1` URL. @return wild|PhutilSafeHTML|null
renderNewUserView
php
phorgeit/phorge
src/applications/search/engine/PhabricatorApplicationSearchEngine.php
https://github.com/phorgeit/phorge/blob/master/src/applications/search/engine/PhabricatorApplicationSearchEngine.php
Apache-2.0
protected function getNewUserHeader() { return null; }
Get a content body to onboard new users. Traditionally this content is shown from an empty list, to explain what a certain entity does, and how to create a new one. @return wild|PhutilSafeHTML|null
getNewUserHeader
php
phorgeit/phorge
src/applications/search/engine/PhabricatorApplicationSearchEngine.php
https://github.com/phorgeit/phorge/blob/master/src/applications/search/engine/PhabricatorApplicationSearchEngine.php
Apache-2.0
public function getService() { return $this->service; }
@return PhabricatorSearchService
getService
php
phorgeit/phorge
src/applications/search/fulltextstorage/PhabricatorFulltextStorageEngine.php
https://github.com/phorgeit/phorge/blob/master/src/applications/search/fulltextstorage/PhabricatorFulltextStorageEngine.php
Apache-2.0
public function indexIsSane() { return $this->indexExists(); }
Is the index in a usable state? @return bool
indexIsSane
php
phorgeit/phorge
src/applications/search/fulltextstorage/PhabricatorFulltextStorageEngine.php
https://github.com/phorgeit/phorge/blob/master/src/applications/search/fulltextstorage/PhabricatorFulltextStorageEngine.php
Apache-2.0
public function initIndex() {}
Do any sort of setup for the search index. @return void
initIndex
php
phorgeit/phorge
src/applications/search/fulltextstorage/PhabricatorFulltextStorageEngine.php
https://github.com/phorgeit/phorge/blob/master/src/applications/search/fulltextstorage/PhabricatorFulltextStorageEngine.php
Apache-2.0
private static function normalizeConfigValue($value) { if ($value === true) { return 'true'; } else if ($value === false) { return 'false'; } return $value; }
Normalize a config value for comparison. Elasticsearch accepts all kinds of config values but it tends to throw back 'true' for true and 'false' for false so we normalize everything. Sometimes, oddly, it'll throw back false for false.... @param mixed $value config value @return mixed value normalized
normalizeConfigValue
php
phorgeit/phorge
src/applications/search/fulltextstorage/PhabricatorElasticFulltextStorageEngine.php
https://github.com/phorgeit/phorge/blob/master/src/applications/search/fulltextstorage/PhabricatorElasticFulltextStorageEngine.php
Apache-2.0
public function shouldAllowEmailTrustConfiguration() { return true; }
Should we allow the adapter to be marked as "trusted". This is true for all adapters except those that allow the user to type in emails (see @{class:PhabricatorPasswordAuthProvider}).
shouldAllowEmailTrustConfiguration
php
phorgeit/phorge
src/applications/auth/provider/PhabricatorAuthProvider.php
https://github.com/phorgeit/phorge/blob/master/src/applications/auth/provider/PhabricatorAuthProvider.php
Apache-2.0
public function hasSetupStep() { return false; }
Return true to use a two-step configuration (setup, configure) instead of the default single-step configuration. In practice, this means that creating a new provider instance will redirect back to the edit page instead of the provider list. @return bool True if this provider uses two-step configuration.
hasSetupStep
php
phorgeit/phorge
src/applications/auth/provider/PhabricatorAuthProvider.php
https://github.com/phorgeit/phorge/blob/master/src/applications/auth/provider/PhabricatorAuthProvider.php
Apache-2.0
public function hasSetupStep() { return true; }
JIRA uses a setup step to generate public/private keys.
hasSetupStep
php
phorgeit/phorge
src/applications/auth/provider/PhabricatorJIRAAuthProvider.php
https://github.com/phorgeit/phorge/blob/master/src/applications/auth/provider/PhabricatorJIRAAuthProvider.php
Apache-2.0
protected function willFinishOAuthHandshake() { $jira_magic_word = 'denied'; if ($this->getVerifier() == $jira_magic_word) { throw new PhutilAuthUserAbortedException(); } }
JIRA indicates that the user has clicked the "Deny" button by passing a well known `oauth_verifier` value ("denied"), which we check for here.
willFinishOAuthHandshake
php
phorgeit/phorge
src/applications/auth/adapter/PhutilJIRAAuthAdapter.php
https://github.com/phorgeit/phorge/blob/master/src/applications/auth/adapter/PhutilJIRAAuthAdapter.php
Apache-2.0
private function shouldBindWithoutIdentity() { return $this->alwaysSearch || strlen($this->anonymousUsername); }
Determine if this adapter should attempt to bind to the LDAP server without a user identity. Generally, we can bind directly if we have a username/password, or if the "Always Search" flag is set, indicating that the empty username and password are sufficient. @return bool True if the adapter should perform binds without identity.
shouldBindWithoutIdentity
php
phorgeit/phorge
src/applications/auth/adapter/PhutilLDAPAuthAdapter.php
https://github.com/phorgeit/phorge/blob/master/src/applications/auth/adapter/PhutilLDAPAuthAdapter.php
Apache-2.0
public function getAccountID() { throw new PhutilMethodNotImplementedException(); }
Get a unique identifier associated with the account. This identifier should be permanent, immutable, and uniquely identify the account. If possible, it should be nonsensitive. For providers that have a GUID or PHID value for accounts, these are the best values to use. You can implement @{method:newAccountIdentifiers} instead if a provider is unable to emit identifiers with all of these properties. If the adapter was unable to authenticate an identity, it should return `null`. @return string|null Unique account identifier, or `null` if authentication failed.
getAccountID
php
phorgeit/phorge
src/applications/auth/adapter/PhutilAuthAdapter.php
https://github.com/phorgeit/phorge/blob/master/src/applications/auth/adapter/PhutilAuthAdapter.php
Apache-2.0
public function getAdapterKey() { return $this->getAdapterType().':'.$this->getAdapterDomain(); }
Generate a string uniquely identifying this adapter configuration. Within the scope of a given key, all account IDs must uniquely identify exactly one identity. @return string Unique identifier for this adapter configuration.
getAdapterKey
php
phorgeit/phorge
src/applications/auth/adapter/PhutilAuthAdapter.php
https://github.com/phorgeit/phorge/blob/master/src/applications/auth/adapter/PhutilAuthAdapter.php
Apache-2.0
public function getAccountEmail() { return null; }
Optionally, return an email address associated with this account. @return string|null An email address associated with the account, or `null` if data is not available.
getAccountEmail
php
phorgeit/phorge
src/applications/auth/adapter/PhutilAuthAdapter.php
https://github.com/phorgeit/phorge/blob/master/src/applications/auth/adapter/PhutilAuthAdapter.php
Apache-2.0
public function getAccountName() { return null; }
Optionally, return a human readable username associated with this account. @return string|null Account username, or `null` if data isn't available.
getAccountName
php
phorgeit/phorge
src/applications/auth/adapter/PhutilAuthAdapter.php
https://github.com/phorgeit/phorge/blob/master/src/applications/auth/adapter/PhutilAuthAdapter.php
Apache-2.0
public function getAccountURI() { return null; }
Optionally, return a URI corresponding to a human-viewable profile for this account. @return string|null A profile URI associated with this account, or `null` if the data isn't available.
getAccountURI
php
phorgeit/phorge
src/applications/auth/adapter/PhutilAuthAdapter.php
https://github.com/phorgeit/phorge/blob/master/src/applications/auth/adapter/PhutilAuthAdapter.php
Apache-2.0
public function getAccountImageURI() { return null; }
Optionally, return a profile image URI associated with this account. @return string|null URI for an account profile image, or `null` if one is not available.
getAccountImageURI
php
phorgeit/phorge
src/applications/auth/adapter/PhutilAuthAdapter.php
https://github.com/phorgeit/phorge/blob/master/src/applications/auth/adapter/PhutilAuthAdapter.php
Apache-2.0
public function getAccountRealName() { return null; }
Optionally, return a real name associated with this account. @return string|null A human real name, or `null` if this data is not available.
getAccountRealName
php
phorgeit/phorge
src/applications/auth/adapter/PhutilAuthAdapter.php
https://github.com/phorgeit/phorge/blob/master/src/applications/auth/adapter/PhutilAuthAdapter.php
Apache-2.0
protected function willFinishOAuthHandshake() { return; }
Hook that allows subclasses to take actions before the OAuth handshake is completed.
willFinishOAuthHandshake
php
phorgeit/phorge
src/applications/auth/adapter/PhutilOAuth1AuthAdapter.php
https://github.com/phorgeit/phorge/blob/master/src/applications/auth/adapter/PhutilOAuth1AuthAdapter.php
Apache-2.0
public function isContactNumberFactor() { return false; }
Is this a factor which depends on the user's contact number? If a user has a "contact number" factor configured, they can not modify or switch their primary contact number. @return bool True if this factor should lock contact numbers.
isContactNumberFactor
php
phorgeit/phorge
src/applications/auth/factor/PhabricatorAuthFactor.php
https://github.com/phorgeit/phorge/blob/master/src/applications/auth/factor/PhabricatorAuthFactor.php
Apache-2.0
public static function setClientIDCookie(AphrontRequest $request) { // NOTE: See T3471 for some discussion. Some browsers and browser extensions // can make duplicate requests, so we overwrite this cookie only if it is // not present in the request. The cookie lifetime is limited by making it // temporary and clearing it when users log out. $value = $request->getCookie(self::COOKIE_CLIENTID); if (!phutil_nonempty_string($value)) { $request->setTemporaryCookie( self::COOKIE_CLIENTID, Filesystem::readRandomCharacters(16)); } }
Set the client ID cookie. This is a random cookie used like a CSRF value during authentication workflows. @param AphrontRequest $request Request to modify. @return void @task clientid
setClientIDCookie
php
phorgeit/phorge
src/applications/auth/constants/PhabricatorCookies.php
https://github.com/phorgeit/phorge/blob/master/src/applications/auth/constants/PhabricatorCookies.php
Apache-2.0
public static function setNextURICookie( AphrontRequest $request, $next_uri, $force = false) { if (!$force) { $cookie_value = $request->getCookie(self::COOKIE_NEXTURI); list($set_at, $current_uri) = self::parseNextURICookie($cookie_value); // If the cookie was set within the last 2 minutes, don't overwrite it. // Primarily, this prevents browser requests for resources which do not // exist (like "humans.txt" and various icons) from overwriting a normal // URI like "/feed/". if ($set_at > (time() - 120)) { return; } } $new_value = time().','.$next_uri; $request->setTemporaryCookie(self::COOKIE_NEXTURI, $new_value); }
Set the Next URI cookie. We only write the cookie if it wasn't recently written, to avoid writing over a real URI with a bunch of "humans.txt" stuff. See T3793 for discussion. @param AphrontRequest $request Request to write to. @param string $next_uri URI to write. @param bool $force (optional) Write this cookie even if we have a fresh cookie already. @return void @task next
setNextURICookie
php
phorgeit/phorge
src/applications/auth/constants/PhabricatorCookies.php
https://github.com/phorgeit/phorge/blob/master/src/applications/auth/constants/PhabricatorCookies.php
Apache-2.0
public static function getNextURICookie(AphrontRequest $request) { $cookie_value = $request->getCookie(self::COOKIE_NEXTURI); list($set_at, $next_uri) = self::parseNextURICookie($cookie_value); return $next_uri; }
Read the URI out of the Next URI cookie. @param AphrontRequest $request Request to examine. @return string|null Next URI cookie's URI value. @task next
getNextURICookie
php
phorgeit/phorge
src/applications/auth/constants/PhabricatorCookies.php
https://github.com/phorgeit/phorge/blob/master/src/applications/auth/constants/PhabricatorCookies.php
Apache-2.0
private static function parseNextURICookie($cookie) { // Old cookies look like: /uri // New cookies look like: timestamp,/uri if (!phutil_nonempty_string($cookie)) { return null; } if (strpos($cookie, ',') !== false) { list($timestamp, $uri) = explode(',', $cookie, 2); return array((int)$timestamp, $uri); } return array(0, $cookie); }
Parse a Next URI cookie into its components. @param string $cookie Raw cookie value. @return list<int,string>|null List of timestamp and URI, or null if the cookie is empty or null. @task next
parseNextURICookie
php
phorgeit/phorge
src/applications/auth/constants/PhabricatorCookies.php
https://github.com/phorgeit/phorge/blob/master/src/applications/auth/constants/PhabricatorCookies.php
Apache-2.0
public static function isCommonPassword($password) { static $list; if ($list === null) { $list = self::loadWordlist(); } return isset($list[strtolower($password)]); }
Check if a password is extremely common. @param string $password Password to test. @return bool True if the password is pathologically weak. @task common
isCommonPassword
php
phorgeit/phorge
src/applications/auth/constants/PhabricatorCommonPasswords.php
https://github.com/phorgeit/phorge/blob/master/src/applications/auth/constants/PhabricatorCommonPasswords.php
Apache-2.0
public static function getSessionKindFromToken($session_token) { if (strpos($session_token, '/') === false) { // Old-style session, these are all user sessions. return self::KIND_USER; } list($kind, $key) = explode('/', $session_token, 2); switch ($kind) { case self::KIND_ANONYMOUS: case self::KIND_USER: case self::KIND_EXTERNAL: return $kind; default: return self::KIND_UNKNOWN; } }
Get the session kind (e.g., anonymous, user, external account) from a session token. Returns a `KIND_` constant. @param string $session_token Session token. @return string Session kind constant.
getSessionKindFromToken
php
phorgeit/phorge
src/applications/auth/engine/PhabricatorAuthSessionEngine.php
https://github.com/phorgeit/phorge/blob/master/src/applications/auth/engine/PhabricatorAuthSessionEngine.php
Apache-2.0
public function loadUserForSession($session_type, $session_token) { $session_kind = self::getSessionKindFromToken($session_token); switch ($session_kind) { case self::KIND_ANONYMOUS: // Don't bother trying to load a user for an anonymous session, since // neither the session nor the user exist. return null; case self::KIND_UNKNOWN: // If we don't know what kind of session this is, don't go looking for // it. return null; case self::KIND_USER: break; case self::KIND_EXTERNAL: // TODO: Implement these (T4310). return null; } $session_table = new PhabricatorAuthSession(); $user_table = new PhabricatorUser(); $conn = $session_table->establishConnection('r'); $session_key = PhabricatorAuthSession::newSessionDigest( new PhutilOpaqueEnvelope($session_token)); $cache_parts = $this->getUserCacheQueryParts($conn); list($cache_selects, $cache_joins, $cache_map, $types_map) = $cache_parts; $info = queryfx_one( $conn, 'SELECT s.id AS s_id, s.phid AS s_phid, s.sessionExpires AS s_sessionExpires, s.sessionStart AS s_sessionStart, s.highSecurityUntil AS s_highSecurityUntil, s.isPartial AS s_isPartial, s.signedLegalpadDocuments as s_signedLegalpadDocuments, u.* %Q FROM %R u JOIN %R s ON u.phid = s.userPHID AND s.type = %s AND s.sessionKey = %P %Q', $cache_selects, $user_table, $session_table, $session_type, new PhutilOpaqueEnvelope($session_key), $cache_joins); if (!$info) { return null; } $session_dict = array( 'userPHID' => $info['phid'], 'sessionKey' => $session_key, 'type' => $session_type, ); $cache_raw = array_fill_keys($cache_map, null); foreach ($info as $key => $value) { if (strncmp($key, 's_', 2) === 0) { unset($info[$key]); $session_dict[substr($key, 2)] = $value; continue; } if (isset($cache_map[$key])) { unset($info[$key]); $cache_raw[$cache_map[$key]] = $value; continue; } } $user = $user_table->loadFromArray($info); $cache_raw = $this->filterRawCacheData($user, $types_map, $cache_raw); $user->attachRawCacheData($cache_raw); switch ($session_type) { case PhabricatorAuthSession::TYPE_WEB: // Explicitly prevent bots and mailing lists from establishing web // sessions. It's normally impossible to attach authentication to these // accounts, and likewise impossible to generate sessions, but it's // technically possible that a session could exist in the database. If // one does somehow, refuse to load it. if (!$user->canEstablishWebSessions()) { return null; } break; } $session = id(new PhabricatorAuthSession())->loadFromArray($session_dict); $this->extendSession($session); $user->attachSession($session); return $user; }
Load the user identity associated with a session of a given type, identified by token. When the user presents a session token to an API, this method verifies it is of the correct type and loads the corresponding identity if the session exists and is valid. NOTE: `$session_type` is the type of session that is required by the loading context. This prevents use of a Conduit sesssion as a Web session, for example. @param string $session_type Constant of the type of session to load. @param string $session_token The session token. @return PhabricatorUser|null @task use
loadUserForSession
php
phorgeit/phorge
src/applications/auth/engine/PhabricatorAuthSessionEngine.php
https://github.com/phorgeit/phorge/blob/master/src/applications/auth/engine/PhabricatorAuthSessionEngine.php
Apache-2.0
public function requireHighSecurityToken( PhabricatorUser $viewer, AphrontRequest $request, $cancel_uri) { return $this->newHighSecurityToken( $viewer, $request, $cancel_uri, false, false); }
Require the user respond to a high security (MFA) check. This method differs from @{method:requireHighSecuritySession} in that it does not upgrade the user's session as a side effect. This method is appropriate for one-time checks. @param PhabricatorUser $viewer User whose session needs to be in high security. @param AphrontRequest $request Current request. @param string $cancel_uri URI to return the user to if they cancel. @return PhabricatorAuthHighSecurityToken Security token. @task hisec
requireHighSecurityToken
php
phorgeit/phorge
src/applications/auth/engine/PhabricatorAuthSessionEngine.php
https://github.com/phorgeit/phorge/blob/master/src/applications/auth/engine/PhabricatorAuthSessionEngine.php
Apache-2.0
public function requireHighSecuritySession( PhabricatorUser $viewer, AphrontRequest $request, $cancel_uri, $jump_into_hisec = false) { return $this->newHighSecurityToken( $viewer, $request, $cancel_uri, $jump_into_hisec, true); }
Require high security, or prompt the user to enter high security. If the user's session is in high security, this method will return a token. Otherwise, it will throw an exception which will eventually be converted into a multi-factor authentication workflow. This method upgrades the user's session to high security for a short period of time, and is appropriate if you anticipate they may need to take multiple high security actions. To perform a one-time check instead, use @{method:requireHighSecurityToken}. @param PhabricatorUser $viewer User whose session needs to be in high security. @param AphrontRequest $request Current request. @param string $cancel_uri URI to return the user to if they cancel. @param bool $jump_into_hisec (optional) True to jump partial sessions directly into high security instead of just upgrading them to full sessions. @return PhabricatorAuthHighSecurityToken Security token. @task hisec
requireHighSecuritySession
php
phorgeit/phorge
src/applications/auth/engine/PhabricatorAuthSessionEngine.php
https://github.com/phorgeit/phorge/blob/master/src/applications/auth/engine/PhabricatorAuthSessionEngine.php
Apache-2.0
private function issueHighSecurityToken( PhabricatorAuthSession $session, $force = false) { if ($session->isHighSecuritySession() || $force) { return new PhabricatorAuthHighSecurityToken(); } return null; }
Issue a high security token for a session, if authorized. @param PhabricatorAuthSession $session Session to issue a token for. @param bool $force (optional) Force token issue. @return PhabricatorAuthHighSecurityToken|null Token, if authorized. @task hisec
issueHighSecurityToken
php
phorgeit/phorge
src/applications/auth/engine/PhabricatorAuthSessionEngine.php
https://github.com/phorgeit/phorge/blob/master/src/applications/auth/engine/PhabricatorAuthSessionEngine.php
Apache-2.0
public function exitHighSecurity( PhabricatorUser $viewer, PhabricatorAuthSession $session) { if (!$session->getHighSecurityUntil()) { return; } queryfx( $session->establishConnection('w'), 'UPDATE %T SET highSecurityUntil = NULL WHERE id = %d', $session->getTableName(), $session->getID()); $log = PhabricatorUserLog::initializeNewLog( $viewer, $viewer->getPHID(), PhabricatorExitHisecUserLogType::LOGTYPE); $log->save(); }
Strip the high security flag from a session. Kicks a session out of high security and logs the exit. @param PhabricatorUser $viewer Acting user. @param PhabricatorAuthSession $session Session to return to normal security. @return void @task hisec
exitHighSecurity
php
phorgeit/phorge
src/applications/auth/engine/PhabricatorAuthSessionEngine.php
https://github.com/phorgeit/phorge/blob/master/src/applications/auth/engine/PhabricatorAuthSessionEngine.php
Apache-2.0
public function upgradePartialSession(PhabricatorUser $viewer) { if (!$viewer->hasSession()) { throw new Exception( pht('Upgrading partial session of user with no session!')); } $session = $viewer->getSession(); if (!$session->getIsPartial()) { throw new Exception(pht('Session is not partial!')); } $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); $session->setIsPartial(0); queryfx( $session->establishConnection('w'), 'UPDATE %T SET isPartial = %d WHERE id = %d', $session->getTableName(), 0, $session->getID()); $log = PhabricatorUserLog::initializeNewLog( $viewer, $viewer->getPHID(), PhabricatorFullLoginUserLogType::LOGTYPE); $log->save(); unset($unguarded); }
Upgrade a partial session to a full session. @param PhabricatorUser $viewer Viewer whose session should upgrade. @return void @task partial
upgradePartialSession
php
phorgeit/phorge
src/applications/auth/engine/PhabricatorAuthSessionEngine.php
https://github.com/phorgeit/phorge/blob/master/src/applications/auth/engine/PhabricatorAuthSessionEngine.php
Apache-2.0
public function signLegalpadDocuments(PhabricatorUser $viewer, array $docs) { if (!$viewer->hasSession()) { throw new Exception( pht('Signing session legalpad documents of user with no session!')); } $session = $viewer->getSession(); if ($session->getSignedLegalpadDocuments()) { throw new Exception(pht( 'Session has already signed required legalpad documents!')); } $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); $session->setSignedLegalpadDocuments(1); queryfx( $session->establishConnection('w'), 'UPDATE %T SET signedLegalpadDocuments = %d WHERE id = %d', $session->getTableName(), 1, $session->getID()); if (!empty($docs)) { $log = PhabricatorUserLog::initializeNewLog( $viewer, $viewer->getPHID(), PhabricatorSignDocumentsUserLogType::LOGTYPE); $log->save(); } unset($unguarded); }
Upgrade a session to have all legalpad documents signed. @param PhabricatorUser $viewer User whose session should upgrade. @param array $docs LegalpadDocument objects @return void @task partial
signLegalpadDocuments
php
phorgeit/phorge
src/applications/auth/engine/PhabricatorAuthSessionEngine.php
https://github.com/phorgeit/phorge/blob/master/src/applications/auth/engine/PhabricatorAuthSessionEngine.php
Apache-2.0
public function getOneTimeLoginURI( PhabricatorUser $user, ?PhabricatorUserEmail $email = null, $type = self::ONETIME_RESET, $force_full_session = false) { $key = Filesystem::readRandomCharacters(32); $key_hash = $this->getOneTimeLoginKeyHash($user, $email, $key); $onetime_type = PhabricatorAuthOneTimeLoginTemporaryTokenType::TOKENTYPE; $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); $token = id(new PhabricatorAuthTemporaryToken()) ->setTokenResource($user->getPHID()) ->setTokenType($onetime_type) ->setTokenExpires(time() + phutil_units('1 day in seconds')) ->setTokenCode($key_hash) ->setShouldForceFullSession($force_full_session) ->save(); unset($unguarded); $uri = '/login/once/'.$type.'/'.$user->getID().'/'.$key.'/'; if ($email) { $uri = $uri.$email->getID().'/'; } try { $uri = PhabricatorEnv::getProductionURI($uri); } catch (Exception $ex) { // If a user runs `bin/auth recover` before configuring the base URI, // just show the path. We don't have any way to figure out the domain. // See T4132. } return $uri; }
Retrieve a temporary, one-time URI which can log in to an account. These URIs are used for password recovery and to regain access to accounts which users have been locked out of. @param PhabricatorUser $user User to generate a URI for. @param PhabricatorUserEmail? $email Optionally, email to verify when link is used. @param string $type (optional) Context string for the URI. This is purely cosmetic and used only to customize workflow and error messages. @param bool $force_full_session (optional) True to generate a URI which forces an immediate upgrade to a full session, bypassing MFA and other login checks. @return string Login URI. @task onetime
getOneTimeLoginURI
php
phorgeit/phorge
src/applications/auth/engine/PhabricatorAuthSessionEngine.php
https://github.com/phorgeit/phorge/blob/master/src/applications/auth/engine/PhabricatorAuthSessionEngine.php
Apache-2.0
public function loadOneTimeLoginKey( PhabricatorUser $user, ?PhabricatorUserEmail $email = null, $key = null) { $key_hash = $this->getOneTimeLoginKeyHash($user, $email, $key); $onetime_type = PhabricatorAuthOneTimeLoginTemporaryTokenType::TOKENTYPE; return id(new PhabricatorAuthTemporaryTokenQuery()) ->setViewer($user) ->withTokenResources(array($user->getPHID())) ->withTokenTypes(array($onetime_type)) ->withTokenCodes(array($key_hash)) ->withExpired(false) ->executeOne(); }
Load the temporary token associated with a given one-time login key. @param PhabricatorUser $user User to load the token for. @param PhabricatorUserEmail $email (optional) Email to verify when link is used. @param string $key (optional) Key user is presenting as a valid one-time login key. @return PhabricatorAuthTemporaryToken|null Token, if one exists. @task onetime
loadOneTimeLoginKey
php
phorgeit/phorge
src/applications/auth/engine/PhabricatorAuthSessionEngine.php
https://github.com/phorgeit/phorge/blob/master/src/applications/auth/engine/PhabricatorAuthSessionEngine.php
Apache-2.0
private function getOneTimeLoginKeyHash( PhabricatorUser $user, ?PhabricatorUserEmail $email = null, $key = null) { $parts = array( $key, $user->getAccountSecret(), ); if ($email) { $parts[] = $email->getVerificationCode(); } return PhabricatorHash::weakDigest(implode(':', $parts)); }
Hash a one-time login key for storage as a temporary token. @param PhabricatorUser $user User this key is for. @param PhabricatorUserEmail $email (optional) Email to verify when link is used. @param string $key (optional) The one time login key. @return string Hash of the key. task onetime
getOneTimeLoginKeyHash
php
phorgeit/phorge
src/applications/auth/engine/PhabricatorAuthSessionEngine.php
https://github.com/phorgeit/phorge/blob/master/src/applications/auth/engine/PhabricatorAuthSessionEngine.php
Apache-2.0
protected function isFirstTimeSetup() { // If there are any auth providers, this isn't first time setup, even if // we don't have accounts. if (PhabricatorAuthProvider::getAllEnabledProviders()) { return false; } // Otherwise, check if there are any user accounts. If not, we're in first // time setup. $any_users = id(new PhabricatorPeopleQuery()) ->setViewer(PhabricatorUser::getOmnipotentUser()) ->setLimit(1) ->execute(); return !$any_users; }
Returns true if this install is newly setup (i.e., there are no user accounts yet). In this case, we enter a special mode to permit creation of the first account form the web UI.
isFirstTimeSetup
php
phorgeit/phorge
src/applications/auth/controller/PhabricatorAuthController.php
https://github.com/phorgeit/phorge/blob/master/src/applications/auth/controller/PhabricatorAuthController.php
Apache-2.0
protected function loginUser( PhabricatorUser $user, $force_full_session = false) { $response = $this->buildLoginValidateResponse($user); $session_type = PhabricatorAuthSession::TYPE_WEB; if ($force_full_session) { $partial_session = false; } else { $partial_session = true; } $session_key = id(new PhabricatorAuthSessionEngine()) ->establishSession($session_type, $user->getPHID(), $partial_session); // NOTE: We allow disabled users to login and roadblock them later, so // there's no check for users being disabled here. $request = $this->getRequest(); $request->setCookie( PhabricatorCookies::COOKIE_USERNAME, $user->getUsername()); $request->setCookie( PhabricatorCookies::COOKIE_SESSION, $session_key); $this->clearRegistrationCookies(); return $response; }
Log a user into a web session and return an @{class:AphrontResponse} which corresponds to continuing the login process. Normally, this is a redirect to the validation controller which makes sure the user's cookies are set. However, event listeners can intercept this event and do something else if they prefer. @param PhabricatorUser $user User to log the viewer in as. @param bool $force_full_session (optional) True to issue a full session immediately, bypassing MFA. @return AphrontResponse Response which continues the login process.
loginUser
php
phorgeit/phorge
src/applications/auth/controller/PhabricatorAuthController.php
https://github.com/phorgeit/phorge/blob/master/src/applications/auth/controller/PhabricatorAuthController.php
Apache-2.0
public function shouldRequireMultiFactorEnrollment() { return false; }
Users may need to access these controllers to enroll in SMS MFA during account setup.
shouldRequireMultiFactorEnrollment
php
phorgeit/phorge
src/applications/auth/controller/contact/PhabricatorAuthContactNumberController.php
https://github.com/phorgeit/phorge/blob/master/src/applications/auth/controller/contact/PhabricatorAuthContactNumberController.php
Apache-2.0
public function getMarkupFieldKey($field) { $content = $this->getMarkupText($field); return PhabricatorMarkupEngine::digestRemarkupContent($this, $content); }
@task markup
getMarkupFieldKey
php
phorgeit/phorge
src/applications/maniphest/storage/ManiphestTask.php
https://github.com/phorgeit/phorge/blob/master/src/applications/maniphest/storage/ManiphestTask.php
Apache-2.0
public function getMarkupText($field) { return $this->getDescription(); }
@task markup
getMarkupText
php
phorgeit/phorge
src/applications/maniphest/storage/ManiphestTask.php
https://github.com/phorgeit/phorge/blob/master/src/applications/maniphest/storage/ManiphestTask.php
Apache-2.0
public function newMarkupEngine($field) { return PhabricatorMarkupEngine::newManiphestMarkupEngine(); }
@task markup
newMarkupEngine
php
phorgeit/phorge
src/applications/maniphest/storage/ManiphestTask.php
https://github.com/phorgeit/phorge/blob/master/src/applications/maniphest/storage/ManiphestTask.php
Apache-2.0
public function didMarkupText( $field, $output, PhutilMarkupEngine $engine) { return $output; }
@task markup
didMarkupText
php
phorgeit/phorge
src/applications/maniphest/storage/ManiphestTask.php
https://github.com/phorgeit/phorge/blob/master/src/applications/maniphest/storage/ManiphestTask.php
Apache-2.0
public function shouldUseMarkupCache($field) { return (bool)$this->getID(); }
@task markup
shouldUseMarkupCache
php
phorgeit/phorge
src/applications/maniphest/storage/ManiphestTask.php
https://github.com/phorgeit/phorge/blob/master/src/applications/maniphest/storage/ManiphestTask.php
Apache-2.0
public static function isValidStatusConstant($constant) { if (!strlen($constant) || strlen($constant) > 64) { return false; } // Alphanumeric, but not exclusively numeric if (!preg_match('/^(?![0-9]*$)[a-zA-Z0-9]+$/', $constant)) { return false; } return true; }
@task validate
isValidStatusConstant
php
phorgeit/phorge
src/applications/maniphest/constants/ManiphestTaskStatus.php
https://github.com/phorgeit/phorge/blob/master/src/applications/maniphest/constants/ManiphestTaskStatus.php
Apache-2.0
public static function getKeywordForTaskPriority($priority) { $map = self::getConfig(); $spec = idx($map, $priority); if (!$spec) { return null; } $keywords = idx($spec, 'keywords'); if (!$keywords) { return null; } return head($keywords); }
Get the canonical keyword for a given priority constant. @return string|null Keyword, or `null` if no keyword is configured.
getKeywordForTaskPriority
php
phorgeit/phorge
src/applications/maniphest/constants/ManiphestTaskPriority.php
https://github.com/phorgeit/phorge/blob/master/src/applications/maniphest/constants/ManiphestTaskPriority.php
Apache-2.0
public static function getDefaultPriority() { return PhabricatorEnv::getEnvConfig('maniphest.default-priority'); }
Return the default priority for this instance of Phabricator. @return int The value of the default priority constant.
getDefaultPriority
php
phorgeit/phorge
src/applications/maniphest/constants/ManiphestTaskPriority.php
https://github.com/phorgeit/phorge/blob/master/src/applications/maniphest/constants/ManiphestTaskPriority.php
Apache-2.0