Module Password

Hey there,

I’m trying to set a password to a module (site.com/admin) via basic http auth (normally via .htaccess).

Normally I would just create the .htaccess file but of course yii uses virtual URLs so the folders don’t exist.

httpd.conf has a <Location> directive which I could use but I really would like to keep the configuration contained within the application (either a Yii/PHP setting, or a .htaccess thing…)

Anyone had this problem and/or got any solutions?

I found beforeControllerAction and ended up doing some sort of hacky job:


public function beforeControllerAction($controller, $action)

	{

		if(parent::beforeControllerAction($controller, $action))

		{

			// this method is called before any module controller action is performed

			// you may place customized code here

			$loginUrl = $this->name.'/site/login';

			session_start();

			if (

				!isset($_SESSION['logged_in'])

				&&

				Yii::app()->request->requestUri != Yii::app()->request->baseUrl.'/'.$loginUrl

			)

			{

				$controller->redirect(Yii::app()->request->baseUrl.'/'.$loginUrl);

				return false;

			}

			return true;

		}

		else

			return false;

	}

Would still like a HTTP auth popup type deal though…