Rotating passwords? 
Author Message
 Rotating passwords?

I have a directory with 4 predefined user/password logins (already existing
in an Apache .htaccess file).  I want to only allow 1 per week to work, so
that access will be for that week only. (Eventually I may add more users and
shorten the access period, but this is what I'm starting with).  If the
directory has password protection already, how can I check the username used
to log in?

My original idea:

<?
$mday = $today['mday'];
    if ($mday > 0) && ($mday < 7) {
        $allowuser = "user1";
        }
    elseif ($mday > 6) && ($mday <14) {
        $allowuser = "user2";
        }
    elseif ($mday > 13) && ($mday <21) {
        $allowuser = "user3";
        }
    elseif ($mday > 20) && ($mday <28) {
        $allowuser = "user4";
        }
    elseif ($mday > 27) && ($mday <32) {
        $allowuser = "user5";
        }
if (($_SERVER['PHP_AUTH_USER']) == $allowuser) {

    ...page contents here, possibly via an include statement...?

    }

Is this logical?

Thanx,
Wm



Sat, 25 Jun 2005 22:37:57 GMT  
 Rotating passwords?

Quote:

> I have a directory with 4 predefined user/password logins (already
> existing
> in an Apache .htaccess file).  I want to only allow 1 per week to work, so
> that access will be for that week only. (Eventually I may add more users
> and
> shorten the access period, but this is what I'm starting with).  If the
> directory has password protection already, how can I check the username
> used to log in?

One approach would be to use sed or perl to update your .htaccess once per
week and set an environment or configuration variable there, then simply
check the value of this var. Don't lock yourself in to something as static
as "user1" thru "userN", because growth in the code will then be very
painful for you.

--
----- stephan beal
Registered Linux User #71917 http://counter.li.org
I speak for myself, not my employer. Contents may
be hot. Slippery when wet. Reading disclaimers makes
you go blind. Writing them is worse. You have been Warned.



Sat, 25 Jun 2005 22:51:40 GMT  
 Rotating passwords?

Quote:
> I have a directory with 4 predefined user/password logins (already
existing
> in an Apache .htaccess file).  I want to only allow 1 per week to work, so
> that access will be for that week only. (Eventually I may add more users
and
> shorten the access period, but this is what I'm starting with).  If the
> directory has password protection already, how can I check the username
used
> to log in?

> My original idea:

> <?
> $mday = $today['mday'];
>     if ($mday > 0) && ($mday < 7) {
>         $allowuser = "user1";
>         }
>     elseif ($mday > 6) && ($mday <14) {
>         $allowuser = "user2";
>         }
>     elseif ($mday > 13) && ($mday <21) {
>         $allowuser = "user3";
>         }
>     elseif ($mday > 20) && ($mday <28) {
>         $allowuser = "user4";
>         }
>     elseif ($mday > 27) && ($mday <32) {
>         $allowuser = "user5";
>         }
> if (($_SERVER['PHP_AUTH_USER']) == $allowuser) {

>     ...page contents here, possibly via an include statement...?

>     }

> Is this logical?

> Thanx,
> Wm

Once a week, fire off a cron that does a:

htaccess -cb .htaccess <user> <file>

This will create a new htaccess file with the included user/pass,
effectively removing the old.



Sat, 25 Jun 2005 23:33:14 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. rotating an image does not rotate the canvas

2. how can I rotate images

3. Font methods, rotating text

4. VW Rotated Text

5. How to rotate a picture and draw on canvas

6. rotated text at screen?

7. Q: how can I rotate a picture?

8. Rotating Images

9. Rotating picture 90°?

10. How to rotate a string when printing ?

11. VW 2.5.2 Rotating Text on Forms

12. Rotating pictures in RealBasic

 

 
Powered by phpBB® Forum Software