Added very basic and not-very-secure authentication. Smeagol is now usable.

This commit is contained in:
Simon Brooke 2014-11-11 12:24:44 +00:00
parent d437f07fc2
commit fc89b25a2f
12 changed files with 140 additions and 32 deletions

View file

@ -10,11 +10,19 @@ Smeagol uses the Markdown format as provided by [markdown-clj](https://github.co
## Security and authentication
Not done yet.
Currently security is very weak. There is currently a file called *passwd* in the *resources/public* directory, which contains a clojure map of username/plain-text password pairs thus:
{:admin "admin"}
that is to say, the username is a keyword and the corresponding password is a string. Obviously, this is a temporary solution while in development which I will fix later.
## Todo
Git integration!
* Git integration! Smeagol doesn't have any inbuilt versioning or backup mechanism; it's intended that Git will be used as that mechanism. But it isn't implemented yet.
* Image (and other media) upload.
* Improved security.
* Mechanism to add users through the user interface.
* Mechanism to change passwords through the user interface.
## Editing the framing content

View file

@ -18,6 +18,13 @@ body {
background:rgba(40,40,40,0.8);
}
#user {
font-height: 66%;
float: right;
padding: 0.1em 0.75em;
margin: 0;
}
/* only needed for fly-out menu effect on tablet and phone stylesheets */
#nav-icon {
display: none;
@ -120,10 +127,15 @@ input {
background-color: white;
}
input.submit {
input.action {
background-color: green;
}
input.action-dangerous {
color: white;
background-color: red;
}
input.required:after {
content: " \*";
color: red;

1
resources/public/passwd Normal file
View file

@ -0,0 +1 @@
{:admin "admin"}

View file

@ -0,0 +1,33 @@
{% extends "templates/base.html" %}
{% block content %}
<div id="header" class="wiki">
<h1>{{title}}</h1>
{{header|safe}}
</div>
<div id="left-bar" class="wiki">
{{left-bar|safe}}
</div>
<div id="content" class="wiki">
<form action="{{servlet-context}}/auth" method="POST">
{% if user %}
<p class="widget">
<label for="submit">To finish editing</label>
<input name="action" id="action" type="submit" class="action-dangerous" value="Logout!"/>
</p>
{% else %}
<p class="widget">
<label for="username">Your username</label>
<input name="username" id="username" type="text"/>
</p>
<p class="widget">
<label for="password">Your password</label>
<input name="password" id="password" type="password"/>
</p>
<p class="widget">
<label for="submit">To edit this wiki</label>
<input name="action" id="action" type="submit" class="action" value="Login!"/>
</p>
{% endif %}
</form>
</div>
{% endblock %}

View file

@ -13,10 +13,19 @@
<body>
<!-- navbar -->
<div id="nav">
{% if user %}
<p class="user" id="user">You are logged in as {{user}}</p>
{% endif %}
<img id="nav-icon" src="{{servlet-context}}/img/threelines.png" alt="Menu"/>
<ul id="nav-menu" class="nav">
<li class="{{home-selected}}"><a href="{{servlet-context}}/">Home</a></li>
<li class="{{wiki-selected}}"><a href="{{servlet-context}}/">Home</a></li>
<li class="{{edit-selected}}"><a href="{{servlet-context}}/edit?content={{title}}">Edit this page</a></li>
<li class="{{auth-selected}}"><a href="{{servlet-context}}/auth">
{% if user %}
Log out
{% else %}
Log in
{% endif %}</a></li>
</ul>
</div>

View file

@ -13,7 +13,7 @@
<textarea name="src" id="src" rows="25" cols="80">{{content}}</textarea>
<p class="widget">
<label for="submit">When you have finished editing</label>
<input name="submit" id="submit" type="submit" value="Save!"/>
<input name="submit" id="submit" type="submit" class="action" value="Save!"/>
</p>
</form>
</div>