# Password Protect A Page with Single Password

**URL:** <https://forum.getkirby.com/t/password-protect-a-page-with-single-password/1472>\
**Category:** Questions\
**Tags:** v2\
**Created:** [June 26, 2015, 9:35pm UTC](https://forum.getkirby.com/t/password-protect-a-page-with-single-password/1472 "2015-06-26T21:35:16Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![gtc](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/gtc/32/119_2.png) [@gtc](https://forum.getkirby.com/u/gtc)\
**Post date:** [June 26, 2015, 9:35pm UTC](https://forum.getkirby.com/t/password-protect-a-page-with-single-password/1472/1 "2015-06-26T21:35:16Z")

</div>

Is there a way to use a page protected by a single password? We’re running a conference and wanted to protect materials behind a password but without creating individual user accounts. Can I so this with Kirby?

Thank you!

---

<div class="post-metadata">

**Author:** ![jbeyerstedt](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/jbeyerstedt/32/3976_2.png) [@jbeyerstedt](https://forum.getkirby.com/u/jbeyerstedt)\
**Post date:** [June 27, 2015, 3:43pm UTC](https://forum.getkirby.com/t/password-protect-a-page-with-single-password/1472/2 "2015-06-27T15:43:06Z")

</div>

There is no direct way to do this that I know, but you can hack a little bit.  
You could do a login page with only a password field and hardcode a username to your login controller. Of course you have to add a user for the authentication first. For all the code see: [http://getkirby.com/docs/solutions/authentication#the-login](http://getkirby.com/docs/solutions/authentication#the-login)

This is a way to do it with kirby users. Or you must do your own password check and php session stuff.

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [June 27, 2015, 7:02pm UTC](https://forum.getkirby.com/t/password-protect-a-page-with-single-password/1472/3 "2015-06-27T19:02:16Z")

</div>

And the easy way: just create a single user with no panel access and distribute username and password. A little bit more typing for the user but easy to set up, no individual user names required.

---

<div class="post-metadata">

**Author:** ![aoimedia](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/aoimedia/32/13722_2.png) [@aoimedia](https://forum.getkirby.com/u/aoimedia)\
**Post date:** [June 27, 2015, 7:09pm UTC](https://forum.getkirby.com/t/password-protect-a-page-with-single-password/1472/4 "2015-06-27T19:09:29Z")

</div>

Niklaus Gerber developed the “Protect Kirby CMS” plugin for Kirby (v1) and can be found here: [https://github.com/niklausgerber/Protect-Kirby-CMS](https://github.com/niklausgerber/Protect-Kirby-CMS).

However, the plugin is now 3 years old and likely incompatible with Kirby v2.

I mention it as it could still make for a good starting/reference point (perhaps with modification) for a similar Kirby 2 solution.

---

<div class="post-metadata">

**Author:** ![gtc](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/gtc/32/119_2.png) [@gtc](https://forum.getkirby.com/u/gtc)\
**Post date:** [June 28, 2015, 12:06am UTC](https://forum.getkirby.com/t/password-protect-a-page-with-single-password/1472/5 "2015-06-28T00:06:28Z")

</div>

Thanks! I think the solution @texnixe suggests might work (and require less hacking).

---

<div class="post-metadata">

**Author:** ![bastianallgeier](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/bastianallgeier/32/7569_2.png) [@bastianallgeier](https://forum.getkirby.com/u/bastianallgeier)\
**Post date:** [June 28, 2015, 10:00am UTC](https://forum.getkirby.com/t/password-protect-a-page-with-single-password/1472/6 "2015-06-28T10:00:44Z")

</div>

If you really want to work around the username input and stick with the official way you could modify the frontend login page so that there’s just a password field and the username would be hard-coded in the submit action. Check out the authentication examples in the solutions section of the docs. Should be very easy to modify that.

---

<div class="post-metadata">

**Author:** ![anon77445132](https://avatars.discourse-cdn.com/v4/letter/a/4da419/32.png) [@anon77445132](https://forum.getkirby.com/u/anon77445132)\
**Post date:** [June 28, 2015, 5:15pm UTC](https://forum.getkirby.com/t/password-protect-a-page-with-single-password/1472/7 "2015-06-28T17:15:10Z")

</div>

@gtc:  
May be the article at [How to build an asset firewall][1] from @bastianallgeier will help you to protect the images and other files in your content folder(s).

This is not accomplished by the normal Kirby login!  
[1]: [How to build an asset firewall](http://forum.getkirby.com/t/how-to-build-an-asset-firewall/1009)

---

<div class="post-metadata">

**Author:** ![anon3573533](https://avatars.discourse-cdn.com/v4/letter/a/848f3c/32.png) [@anon3573533](https://forum.getkirby.com/u/anon3573533)\
**Post date:** [November 11, 2015, 4:47pm UTC](https://forum.getkirby.com/t/password-protect-a-page-with-single-password/1472/8 "2015-11-11T16:47:19Z")

</div>

Hello Texnixe,  
How would you create a single user with no panel access ?  
Thank you.

---

<div class="post-metadata">

**Author:** ![lukasbestle](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/lukasbestle/32/11437_2.png) [@lukasbestle](https://forum.getkirby.com/u/lukasbestle)\
**Post date:** [November 11, 2015, 7:23pm UTC](https://forum.getkirby.com/t/password-protect-a-page-with-single-password/1472/9 "2015-11-11T19:23:44Z")

</div>

It’s two steps:

1. Create a role for the user like [described here](http://getkirby.com/docs/panel/roles). Make sure to set the `panel` option to false to prevent Panel access.
2. Go to the user management page in the Panel and create a new user with the new role.

---

<div class="post-metadata">

**Author:** ![anon3573533](https://avatars.discourse-cdn.com/v4/letter/a/848f3c/32.png) [@anon3573533](https://forum.getkirby.com/u/anon3573533)\
**Post date:** [November 11, 2015, 7:37pm UTC](https://forum.getkirby.com/t/password-protect-a-page-with-single-password/1472/10 "2015-11-11T19:37:11Z")

</div>

Just found the link a few minuts ago,  
Thank you for your response.

---

<div class="post-metadata">

**Author:** ![theseason](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/theseason/32/3958_2.png) [@theseason](https://forum.getkirby.com/u/theseason)\
**Post date:** [August 23, 2016, 2:20am UTC](https://forum.getkirby.com/t/password-protect-a-page-with-single-password/1472/11 "2016-08-23T02:20:49Z")

</div>

I need to limit access to a certain portfolio page. I added the client role in the Panel with no panel access. How do include the login for that certain page?

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [August 23, 2016, 8:50am UTC](https://forum.getkirby.com/t/password-protect-a-page-with-single-password/1472/12 "2016-08-23T08:50:38Z")

</div>

Check out this [recipe in the cookbook](https://getkirby.com/docs/cookbook/authentication),.

---

<div class="post-metadata">

**Author:** ![attaatariq](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/attaatariq/32/2837_2.png) [@attaatariq](https://forum.getkirby.com/u/attaatariq)\
**Post date:** [August 29, 2016, 4:50pm UTC](https://forum.getkirby.com/t/password-protect-a-page-with-single-password/1472/13 "2016-08-29T16:50:13Z")

</div>

Yes, a java script simple way may help you:

I use it in my web page but working with java script, You could drive your requirement through this simple and humble method. THANKS!

 ![](https://europe1.discourse-cdn.com/flex017/uploads/getkirby/original/2X/5/542add007e08cba8ccc130c85090b53c1ec125f5.JPG)

---

<div class="post-metadata">

**Author:** ![lukasbestle](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/lukasbestle/32/11437_2.png) [@lukasbestle](https://forum.getkirby.com/u/lukasbestle)\
**Post date:** [August 29, 2016, 4:55pm UTC](https://forum.getkirby.com/t/password-protect-a-page-with-single-password/1472/14 "2016-08-29T16:55:14Z")

</div>

What exactly does that JavaScript code do? Authentication only works if there is some kind of backend code, otherwise it is very easy to break into protected areas.

---

<div class="post-metadata">

**Author:** ![attaatariq](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/attaatariq/32/2837_2.png) [@attaatariq](https://forum.getkirby.com/u/attaatariq)\
**Post date:** [August 29, 2016, 5:39pm UTC](https://forum.getkirby.com/t/password-protect-a-page-with-single-password/1472/15 "2016-08-29T17:39:12Z")

</div>

Yeah it’s about back end as I explained a little bit but in this regard we may conclude a solution for this problem which about actually I suggested.

---

<div class="post-metadata">

**Author:** ![theseason](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/theseason/32/3958_2.png) [@theseason](https://forum.getkirby.com/u/theseason)\
**Post date:** [September 19, 2016, 7:06pm UTC](https://forum.getkirby.com/t/password-protect-a-page-with-single-password/1472/16 "2016-09-19T19:06:36Z")

</div>

I have the login working perfectly. Is there a way to force a logout after a certain period of time has passed?

---

<div class="post-metadata">

**Author:** ![lukasbestle](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/lukasbestle/32/11437_2.png) [@lukasbestle](https://forum.getkirby.com/u/lukasbestle)\
**Post date:** [September 19, 2016, 7:20pm UTC](https://forum.getkirby.com/t/password-protect-a-page-with-single-password/1472/17 "2016-09-19T19:20:30Z")

</div>

You could use something like this:

```auto
if($user = site()->user()) {
  // Store the current time in the session if not already existing
  $loginTime = s::get('logintime');
  if(!$loginTime) {
    $loginTime = time();
    s::set('logintime', $loginTime);
  }
  
  // Check if the user logged in more than one hour ago
  // If so, logout
  if($loginTime + 3600 < time()) $user->logout();
}

```

---

<div class="post-metadata">

**Author:** ![theseason](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/theseason/32/3958_2.png) [@theseason](https://forum.getkirby.com/u/theseason)\
**Post date:** [September 27, 2016, 11:41am UTC](https://forum.getkirby.com/t/password-protect-a-page-with-single-password/1472/18 "2016-09-27T11:41:58Z")

</div>

I have created a login page as described in the [recipe in the cookbook](https://getkirby.com/docs/cookbook/authentication). If I wanted to make the login be a modal instead of it’s own page, would I need to create a plugin instead of a page?

At the moment, I have a login page that refers to a login.php controller. But if I want the login to be available on every page, I need to change the method, right?

Thanks again for the help.

---

<div class="post-metadata">

**Author:** ![lukasbestle](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/lukasbestle/32/11437_2.png) [@lukasbestle](https://forum.getkirby.com/u/lukasbestle)\
**Post date:** [September 27, 2016, 11:51am UTC](https://forum.getkirby.com/t/password-protect-a-page-with-single-password/1472/19 "2016-09-27T11:51:43Z")

</div>

You could a lightbox with an iframe for this, but that’s not an optimal solution.

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [September 27, 2016, 11:55am UTC](https://forum.getkirby.com/t/password-protect-a-page-with-single-password/1472/20 "2016-09-27T11:55:37Z")

</div>

Edit: You could just put the login form into the modal and call the url of the login page in the action attribute.

[Next page](https://forum.getkirby.com/t/password-protect-a-page-with-single-password/1472.md?page=2)
