published: 2022-08-19
title: Introducing Blogging Friday
tags:
previous [‘Remove DRM from ebooks’] next [‘LDAP authentication on Home Assistant’] parent directory [‘Blog’]
It’s not that I don’t have things to write about, in fact I learn interesting new things every week. I have however never integrated a dedicated time to write new posts in my weekly routine. So to not procrastinate any further, I start Blogging Friday right now with some things I did this week.
I’m using lektor[4] as static site generator; it’s lightweight and
lektor [‘lektor’] new posts are
really quick to generate. All it takes is a new sub-folder in my
blog
directory, containing a contents.lr
file
with a tiny bit of meta information. Apparently this little effort is
already enough to trigger my procrastination. So to get this hurdle out
of the way a little shell script is quickly written:
#!/usr/bin/env bash
#filename: new_post.sh
if [ -z $1 ]; then
echo "usage: $0 <title>"
exit 1
fi
posttitle="$*"
basepath="/home/robin/gitrepos/myserver/blog/content/blog"
postdir=$(echo $posttitle | sed -e "s/ /_/g" | tr "[:upper:]" "[:lower:]")
fullpath="$basepath/$postdir"
postdate=$(date --iso)
if [ -e "$fullpath" ]; then
echo "file or directory $postdir already exists"
exit 2
fi
mkdir "$fullpath"
echo "
title: $posttitle
---
pub_date: $postdate
---
author: Robin Schubert
---
tags: miscellaneous, programming
---
status: draft
---
body:
" > "$fullpath/contents.lr"
echo "created empty post: $postdir"
I’ve integrated a few web services in our intranet at work, like a self hosted gitlab server, a zammad ticketing system, nextcloud and the likes. One requirement to integrate well in our ecosystem, is the possibility to authenticate with our OpenLDAP server. Those services I configures so far all had their own way means to authenticate against LDAP; some need external plugins, some are configured in web interfaces and others in configuration files. However, honestly I never understood what they did under the hood.
I had a little epiphany this week, when I tried to integrate a homeassistant[5] instance. Homeassistant does not have
homeassistant [‘homeassistant’] a fancy front-end to do this, instead this is realized with a simple shell script. There’s an example on github[6] which can be used
ldapauth [‘example on github’] and is actually not that hard to comprehend.
In summary what is does is to make a request to the LDAP server,
either via ldapsearch
(part of the
openldap-tools
package) or curl
(needs to be
compiled with LDAP integration). An example to make a request with
ldapsearch
could look like this:
ldapsearch -H ldap://ip.of.ldap.server \
-b "CN=Users,DC=your,DC=domain,DC=com" \
-D "CN=Robin Schubert,CN=Users,DC=your,DC=domain,DC=com" \
-W
Executed from the command line, this will prompt for the user’s
password and make the request to the server. If everything works fine,
the command will exit with exit code 0
; if different from
0, the request failed for whatever reason. This result is passed on.
That’s it. Nothing new. Why then didn’t I think of such a
simple solution? The request over ldapsearch
can of course
be further refined, adding filters and pipe the output through
sed
to map e.g. display names or groups and roles.
I was exploring different means to deal with electronic signatures in
Python this week. First library I found was python-gnupg
; I
should have been more suspicious when I saw that the last update has
been 4 years ago. They may be calling it pretty bad protocol[7] for a
reason. It is a wrapper
gnupg
[‘pretty bad protocol’] around the gpg binary, using Python’s
subprocess
to call it. This was not really what I wanted.
For similar reasons, Kushal started johnnycanencrypt[8] in 2020; a
Python library that interfaces the Rust
jce [‘johnnycanencrypt’] OpenPGP lib sequoia-pgp and which I’m yet to explore further.
A third option I found is PGPy[9], a pure Python implementation of
pgpy [‘PGPy’] OpenPGP. Going through the examples of their documentation it feels straight forward; for the relatively simple use case I have (managing keys, signing and verifying signatures), it should be perfectly usable.
Nothing of what I tried this week was groundbreaking or new, but it either interested me or was keeping me busy in some way. I wonder how statistics would look like if I would count how many times I look up the same issues and problems on the internet. Maybe writing down some of them will help me remember - or at least give me the possibility to look things up offline in my own records ;)