You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by Chris Chabot <ch...@xs4all.nl> on 2008/06/26 01:55:25 UTC
PHP Shindig config changes
Just a heads up: I'm counting on svn to not overwrite the config.php
for people with modifications ... so they never get the new loader,
and their existing config remains unchanged, and un-broken.. well
that's the theory anyhow :)
So nothing breaks with this update, however i do strongly encourage
everyone to move to the new config system, it makes keeping up to date
with svn and/or releases a lot easier. See config/container.php for
instructions on how to use this.
-- Chris
On Jun 26, 2008, at 1:50 AM, chabotc@apache.org wrote:
> Author: chabotc
> Date: Wed Jun 25 16:50:44 2008
> New Revision: 671694
>
> URL: http://svn.apache.org/viewvc?rev=671694&view=rev
> Log:
> Phase 1 of the config rewrite. Configuration values moved to config/
> container.php and you can put your local site values in config/
> local.php. This way you can upgrade/svn update without loosing your
> local config
>
> Added:
> incubator/shindig/trunk/php/config/
> incubator/shindig/trunk/php/config/container.php
> Modified:
> incubator/shindig/trunk/php/config.php
> incubator/shindig/trunk/php/src/common/samplecontainer/
> BasicSecurityTokenDecoder.php
>
> Modified: incubator/shindig/trunk/php/config.php
> URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/config.php?rev=671694&r1=671693&r2=671694&view=diff
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- incubator/shindig/trunk/php/config.php (original)
> +++ incubator/shindig/trunk/php/config.php Wed Jun 25 16:50:44 2008
> @@ -18,127 +18,38 @@
> *
> */
>
> -/*
> - * I really detest such config files to be honest, why put
> configuration in a web document!
> - * But since PHP lacks a propper way to set application
> configurations, and any other method
> - * would be horribly slow (db, xml, ini files etc), so ... here's
> our config.php
> - */
> -$shindigConfig = array(
> - // Plain text tokens are meant for the html / javascript samples
> not for hack-me-please type real-life-scenarios
> - // Set both of these to false on anything resembling a live
> deployment
> - 'debug' => true,
> - 'allow_plaintext_token' => true,
> -
> - // The base prefix under which the our url's live, if its the root
> set this to ''
> - // don't forget to update your .htaccess to reflect this, as well
> as your container
> - // javascript like: gadget.setServerBase('/someBaseUrl');
> - 'web_prefix' => '',
> -
> - // Max age of a security token, defaults to one hour
> - 'st_max_age' => 60 * 60,
> -
> - // Security token keys
> - 'token_cipher_key' => 'INSECURE_DEFAULT_KEY',
> - 'token_hmac_key' => 'INSECURE_DEFAULT_KEY',
> -
> - // Compresses features javascript? can save upto 50% page size
> - 'compress_javascript' => true,
> -
> - // Configurable CSS rules that are injected to the gadget page,
> - // be careful when adjusting these not to break most gadget's
> layouts :)
> - //'gadget_css' => 'body,td,div,span,p{font-family:arial,sans-
> serif;} body {background-color:#ffffff; font-family: arial, sans-
> serif; padding: 0px; margin: 0px; font-size: 12px; color:
> #000000;}a, a:visited {color: #3366CC;text-decoration:
> none; }a:hover {color: #3366CC; text-decoration: underline;} input,
> select { border: 1px solid #bdc7d8;font-size: 11px;padding: 3px;}',
> - 'gadget_css' => 'body,td,div,span,p{font-family:arial,sans-serif;}
> a {color:#0000cc;}a:visited {color:#551a8b;}a:active
> {color:#ff0000;}body{margin: 0px;padding: 0px;background-
> color:white;}',
> -
> - // P3P (Platform for Privacy Preferences) header for allowing
> cross domain cookies.
> - // Setting this to an empty string: '' means no P3P header will be
> send
> - 'P3P' => 'CP="CAO PSA OUR"',
> -
> - // location of the features directory on disk. The default setting
> assumes you did a
> - // full checkout of the shindig project, and not just the php part.
> - // Otherwise also checkout the features, config and javascript
> directories and set
> - // these to their locations
> - 'features_path' => realpath(dirname(__FILE__)) . '/../features/',
> - 'container_path' => realpath(dirname(__FILE__)) . '/../config/',
> - 'javascript_path' => realpath(dirname(__FILE__)) . '/../
> javascript/',
> - 'container_config' => realpath(dirname(__FILE__)) . '/../config/
> container.js',
> -
> - //WARNING: handlers is depreciated in the RESTful protocol, use
> people/activity and appdata service instead
> - // 'handlers' => 'PartuzaHandler',
> - 'handlers' => '',
> -
> - // REST API service adapters
> - 'people_service' => 'BasicPeopleService',
> - 'activity_service' => 'BasicActivitiesService',
> - 'app_data_service' => 'BasicAppDataService',
> -
> - 'focedJsLibs' => '',
> -
> - // Configurable classes to use, this way we provide extensibility
> for what
> - // backends the gadget server uses for its logic functionality.
> - 'blacklist_class' => 'BasicGadgetBlacklist',
> - 'remote_content' => 'BasicRemoteContent',
> - 'security_token_signer' => 'BasicSecurityTokenDecoder',
> - 'security_token' => 'BasicSecurityToken',
> - 'data_cache' => 'CacheFile',
> -
> - // gadget server specific settings
> - 'userpref_param_prefix' => 'up_',
> - 'libs_param_name' => 'libs',
> - // location of the javascript handler (include the full path),
> default this is /gadgets/js
> - 'default_js_prefix' => '/gadgets/js/',
> - // location of the gadget iframe renderer, default this is /
> gadgets/ifr?
> - 'default_iframe_prefix' => '/gadgets/ifr?',
> -
> - // if your using memcached, these values are used for locating the
> server
> - // if your not using memcached, ignore these values
> - 'cache_host' => 'localhost',
> - 'cache_port' => 11211,
> -
> - // global cache age policy and location
> - 'cache_time' => 24 * 60 * 60,
> - 'cache_root' => '/tmp/shindig',
> -
> - // Some people develop living behind a proxy server, setting this
> to your
> - // proxy's url (proxy.mycompany.com) will make curl use that proxy.
> - // On production systems you would not want to do this since it
> would mess up
> - // the refreshInterval and caching policies of shindig
> - 'proxy' => '',
> -
> - // See certs/README on how to generate these keys
> - // OAuth private key path
> - 'private_key_file' => realpath(dirname(__FILE__)) . '/certs/
> private.key',
> - // OAuth public key path
> - 'public_key_file' => realpath(dirname(__FILE__)) . '/certs/
> public.crt',
> - // Phrase to decrypt private key. Leave empty if unencrypted
> - 'private_key_phrase' => 'partuza',
> -
> - // In some cases we need to know the site root (for features
> forinstance)
> - 'base_path' => realpath(dirname(__FILE__))
> -);
> -
> class ConfigException extends Exception {}
>
> /**
> - * Abstracts how to retrieve configuration values so we can replace
> the
> - * not so pretty $shindigConfig array some day.
> + * Configuration class. It uses the keys/values from config/
> container.php
> + * and (if the file exists) config/local.php.
> */
> class Config {
> -
> - static function get($key)
> + static private $config = false;
> +
> + static private function loadConfig()
> {
> global $shindigConfig;
> - if (isset($shindigConfig[$key])) {
> - return $shindigConfig[$key];
> - } else {
> - throw new ConfigException("Invalid Config Key");
> + if (!self::$config) {
> + // load default configuration
> + include_once 'config/container.php';
> + self::$config = $shindigConfig;
> + if (file_exists('config/local.php')) {
> + // include local.php if it exists and merge the config arrays.
> + // the second array values overwrites the first one's
> + include_once 'config/local.php';
> + self::$config = array_merge(self::$config, $shindigConfig);
> + }
> }
> }
> -
> - static function set($key, $val)
> +
> + static function get($key)
> {
> - global $shindigConfig;
> - if (isset($shindigConfig[$key])) {
> - $shindigConfig[$key] = $val;
> + if (!self::$config) {
> + self::loadConfig();
> + }
> + if (isset(self::$config[$key])) {
> + return self::$config[$key];
> } else {
> throw new ConfigException("Invalid Config Key");
> }
>
> Added: incubator/shindig/trunk/php/config/container.php
> URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/config/container.php?rev=671694&view=auto
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- incubator/shindig/trunk/php/config/container.php (added)
> +++ incubator/shindig/trunk/php/config/container.php Wed Jun 25
> 16:50:44 2008
> @@ -0,0 +1,108 @@
> +<?php
> +/*
> + * Licensed to the Apache Software Foundation (ASF) under one
> + * or more contributor license agreements. See the NOTICE file
> + * distributed with this work for additional information
> + * regarding copyright ownership. The ASF licenses this file
> + * to you under the Apache License, Version 2.0 (the
> + * "License"); you may not use this file except in compliance
> + * with the License. You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing,
> + * software distributed under the License is distributed on an
> + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> + * KIND, either express or implied. See the License for the
> + * specific language governing permissions and limitations under
> the License.
> + *
> + */
> +
> +/*
> + * Put any site specific configuration in a config/local.php file,
> this way
> + * your configuration won't be lost when upgrading shindig.
> + *
> + * in local.php you only have to specificy the fields you want to
> overwrite
> + * with other values, for example on a production system you would
> probably have:
> + * $shindigConfig = array(
> + * 'debug' => false,
> + * 'allow_plaintext_token' => false,
> + * 'token_cipher_key' => 'MySecretKey',
> + * 'token_hmac_key' => 'MyOtherSecret',
> + * 'private_key_phrase' => 'MyCertificatePassword',
> + * 'people_service' => 'MyPeopleService',
> + * 'activity_service' => 'MyActivitiesService',
> + * 'app_data_service' => 'MyAppDataService'
> + * );
> + *
> + */
> +
> +$shindigConfig = array(
> + // Show debug backtrace's. Disable this on a production site
> + 'debug' => true,
> + // Allow plain text security tokens, this is only here to allow
> the sample files to work. Disable on a production site
> + 'allow_plaintext_token' => true,
> + // Compress the inlined javascript, saves upto 50% of the document
> size
> + 'compress_javascript' => true,
> +
> + // The URL Prefix under which shindig lives ie if you have http://myhost.com/shindig/php
> set web_prefix to /shindig/php
> + 'web_prefix' => '',
> + // If you changed the web prefix, add the prefix to these too
> + 'default_js_prefix' => '/gadgets/js/',
> + 'default_iframe_prefix' => '/gadgets/ifr?',
> +
> + // The encryption keys for encrypting the security token, and the
> expiration of it. Make sure these match the keys used in your
> container/site
> + 'token_cipher_key' => 'INSECURE_DEFAULT_KEY',
> + 'token_hmac_key' => 'INSECURE_DEFAULT_KEY',
> + 'token_max_age' => 60 * 60,
> +
> + // Ability to customize the style thats injected into the gadget
> document. Don't forget to put the link/etc colors in shindig/config/
> container.js too!
> + 'gadget_css' => 'body,td,div,span,p{font-family:arial,sans-serif;}
> a {color:#0000cc;}a:visited {color:#551a8b;}a:active
> {color:#ff0000;}body{margin: 0px;padding: 0px;background-
> color:white;}',
> +
> + // P3P privacy policy to use for the iframe document
> + 'P3P' => 'CP="CAO PSA OUR"',
> +
> + // The locations of the various required components on disk. If
> you did a normal svn checkout there's no need to change these
> + 'base_path' => realpath(dirname(__FILE__)),
> + 'features_path' => realpath(dirname(__FILE__)) . '/../../features/',
> + 'container_path' => realpath(dirname(__FILE__)) . '/../../config/',
> + 'javascript_path' => realpath(dirname(__FILE__)) . '/../../
> javascript/',
> + 'container_config' => realpath(dirname(__FILE__)) . '/../../config/
> container.js',
> +
> + // The OAuth SSL certificates to use, and the pass phrase for the
> private key
> + 'private_key_file' => realpath(dirname(__FILE__)) . '/../certs/
> private.key',
> + 'public_key_file' => realpath(dirname(__FILE__)) . '/../certs/
> public.crt',
> + 'private_key_phrase' => 'partuza',
> +
> + // Force these libraries to be external (included through <script
> src="..."> tags), this way they could be cached by the browser
> + 'focedJsLibs' => '',
> +
> + // Configurable classes. Change these to the class name to use,
> and make sure the auto-loader can find them
> + 'blacklist_class' => 'BasicGadgetBlacklist',
> + 'remote_content' => 'BasicRemoteContent',
> + 'security_token_signer' => 'BasicSecurityTokenDecoder',
> + 'security_token' => 'BasicSecurityToken',
> + // Caching back-end to use. Shindig ships with CacheFile and
> CacheMemcache out of the box
> + 'data_cache' => 'CacheFile',
> + // Old-style wire format data handler, this is being depreciated
> + 'handlers' => '',
> + // New RESTful API data service classes to use
> + 'people_service' => 'BasicPeopleService',
> + 'activity_service' => 'BasicActivitiesService',
> + 'app_data_service' => 'BasicAppDataService',
> + // Also scan these directories when looking for <Class>.php files.
> You can include multiple paths by seperating them with a ,
> + 'extension_class_paths' => '',
> +
> + 'userpref_param_prefix' => 'up_',
> + 'libs_param_name' => 'libs',
> +
> + // If you use CacheMemcache as caching backend, change these to
> the memcache server settings
> + 'cache_host' => 'localhost',
> + 'cache_port' => 11211,
> + 'cache_time' => 24 * 60 * 60,
> + // If you use CacheFile as caching backend, this is the directory
> where it stores the temporary files
> + 'cache_root' => '/tmp/shindig',
> +
> + // If your development server is behind a proxy, enter the proxy
> details here in 'proxy.host.com:port' format.
> + 'proxy' => ''
> +);
>
> Modified: incubator/shindig/trunk/php/src/common/samplecontainer/
> BasicSecurityTokenDecoder.php
> URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/common/samplecontainer/BasicSecurityTokenDecoder.php?rev=671694&r1=671693&r2=671694&view=diff
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- incubator/shindig/trunk/php/src/common/samplecontainer/
> BasicSecurityTokenDecoder.php (original)
> +++ incubator/shindig/trunk/php/src/common/samplecontainer/
> BasicSecurityTokenDecoder.php Wed Jun 25 16:50:44 2008
> @@ -43,7 +43,7 @@
> $tokens = explode(":", $stringToken);
> return new BasicSecurityToken(null, null,
> urldecode($tokens[$this->OWNER_INDEX]), urldecode($tokens[$this-
> >VIEWER_INDEX]), urldecode($tokens[$this->APP_ID_INDEX]),
> urldecode($tokens[$this->CONTAINER_INDEX]), urldecode($tokens[$this-
> >APP_URL_INDEX]), urldecode($tokens[$this->MODULE_ID_INDEX]));
> } else {
> - return BasicSecurityToken::createFromToken($stringToken,
> Config::get('st_max_age'));
> + return BasicSecurityToken::createFromToken($stringToken,
> Config::get('token_max_age'));
> }
> } catch (Exception $e) {
> throw new GadgetException('INVALID_GADGET_TOKEN');
>