Skip to content

Commit 462f830

Browse files
author
Anselm Lingnau
committed
Merge branch 'fix/make-ourselves-at-home-in-new-repo' into 'master'
Fix: Make ourselves at home in new repo See merge request dev/linotp/linotp-adminclient-cli!1
2 parents daefc32 + b9b6f42 commit 462f830

13 files changed

Lines changed: 378 additions & 38 deletions

File tree

.gitlab-ci.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
include:
2+
- ci/gitbox-ci.yml
3+
4+
build:jessie:
5+
extends: .build-jessie
6+
7+
build:stretch:
8+
extends: .build-stretch
9+
10+
build:buster:
11+
extends: .build-buster

DESCRIPTION

Lines changed: 0 additions & 7 deletions
This file was deleted.

README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# LinOTP Command-Line Administration Client
2+
3+
LinOTP - the Open Source solution for multi-factor authentication
4+
5+
Copyright © 2010-2019 KeyIdentity GmbH
6+
Coypright © 2019- arxes-tolina GmbH
7+
8+
## About LinOTP
9+
10+
LinOTP is truly open in two ways. Its modules and components are
11+
licensed under the AGPLv3 and give you a complete working open-source
12+
solution for strong multi-factor authentication.
13+
14+
But LinOTP also uses an open and modular architecture. LinOTP aims not
15+
to lock you into any particular authentication method or protocol or
16+
user information storage.
17+
18+
LinOTP accommodates many different OTP algorithms using a modular
19+
approach. This includes the OATH standards such as HMAC (RFC 4226) and
20+
time-based HMAC. But LinOTP's design makes it easy to create your own
21+
tokens with different algorithms, including challenge-response tokens,
22+
tokens based on QR codes, and tokens based on push-type messages.
23+
24+
Other components like the LinOTP authentication modules or the LinOTP
25+
administration clients make it easy to integrate strong multi-factor
26+
authentication into your environment.
27+
28+
This package contains the LinOTP Command-Line Administration Client,
29+
which lets you manage a LinOTP server from the command line. It is
30+
supremely uninteresting unless you have a LinOTP server running on
31+
your network.
32+
33+
**IMPORTANT:** This program has been around for a while and hasn't
34+
been looked at a lot in recent days. Stuff may work but then again it
35+
may not. USE AT YOUR OWN RISK.
36+
37+
## Installation
38+
39+
1. Installation from PyPI: Use the
40+
```terminal
41+
$ pip install LinOTPAdminClientCLI
42+
```
43+
command.
44+
45+
2. Installation from source: Download the source code from
46+
https://github.com/linotp-adminclient-cli and, in the top-level
47+
directory of the source code distribution, say
48+
```
49+
$ python setup.py install
50+
```
51+
(You may wish to do this in a virtualenv.)
52+
53+
## Usage
54+
55+
Refer to the man page, linotpadm(1), or try
56+
```
57+
$ linotpadm # no arguments
58+
```
59+

README.txt

Whitespace-only changes.

Readme.rst

Lines changed: 0 additions & 7 deletions
This file was deleted.

ci/copy-to-golden

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash
2+
#
3+
# Copy distribution packages from $DIST to $DIST-golden.
4+
# This usually happens when the commit in question has a `release/*` tag,
5+
# but it is the caller's responsibility to ensure this. It will be of no
6+
# conceivable interest to you whatsoever unless you're doing official
7+
# LinOTP development.
8+
#
9+
# This command is called with the desired base distribution (e.g., `buster`)
10+
# and the names of one or more *.changes files – usually produced as Gitlab
11+
# CI/CD artifacts – as parameters.
12+
# We get the actual distribution and package names from the changes file.
13+
14+
WANTED_DIST=$1
15+
GOLDEN_DIST=$1-golden
16+
shift
17+
18+
declare -a PKGS # List of packages to be copied
19+
for chf do
20+
PKG=$(sed -ne '/^Binary:/{s/^.*: //p;q}' $chf) # Find package name
21+
DIST=$(sed -ne '/^Distribution:/{s/^.*: //p;q}' $chf) # Find distribution name
22+
if [ -z "$DIST" ]; then
23+
echo >&2 "E:Couldn't find 'Distribution:' line in $chf, skipping"
24+
continue
25+
elif [ -z "$PKG" ]; then
26+
echo >&2 "E:Couldn't find 'Binary:' line in $chf, skipping"
27+
continue
28+
fi
29+
echo >&2 "I:Considering $PKG ($chf)"
30+
if [ "$DIST" != "$WANTED_DIST" ]; then
31+
echo >&2 "W:$PKG's distribution is $DIST, not $WANTED_DIST, skipping"
32+
continue
33+
fi
34+
PKGS+=($PKG)
35+
done
36+
37+
if [ "${#PKGS[*]}" -gt 0 ]; then # Do we have work to do?
38+
echo >&2 "I:Copying ${PKGS[@]} to ${GOLDEN_DIST}"
39+
ssh dists@$DEV_REPO_HOST reprepro copy ${GOLDEN_DIST} ${WANTED_DIST} ${PKGS[@]}
40+
EXITCODE=$?
41+
echo >&2 "I:Done"
42+
else
43+
echo >&2 "I:Nothing to do"
44+
EXITCODE=0
45+
fi
46+
47+
exit $EXITCODE

ci/gitbox-ci.yml

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
variables:
2+
DEV_REPO_URL: http://avocado.corp.lsexperts.de/deb-repo
3+
LANG: C.UTF-8
4+
EMAIL: "KeyIdentity GmbH <[email protected]>"
5+
# Merges/tags to this branch trigger uploads
6+
GITBOX_CI_UPLOAD_BRANCHES: '/^(branch-v|master)/'
7+
# Tags to these release branches trigger golden-repo uploads
8+
GITBOX_CI_RELEASE_TAGS: '/^release/'
9+
GITBOX_CI_GOLDEN_RELEASES: '/^buster$/'
10+
11+
workflow:
12+
rules:
13+
- if: $CI_PIPELINE_SOURCE == 'schedule' # Execute nightly jobs
14+
- if: $CI_MERGE_REQUEST_ID # Execute jobs in MR context
15+
- if: '$CI_COMMIT_BRANCH =~ $GITBOX_CI_UPLOAD_BRANCHES'
16+
# Execute jobs when new commit is pushed to upload branch
17+
18+
stages:
19+
- build
20+
- deploy
21+
- upload-debian-packages
22+
- copy-to-golden
23+
24+
.build-debs:
25+
stage: build
26+
image: debian:${DEBIAN_RELEASE_NAME}
27+
script:
28+
- apt-get update
29+
- apt-get install --yes --no-install-recommends devscripts build-essential equivs git-buildpackage lsb-release libdistro-info-perl
30+
- ci/update-debian-changelog
31+
- mk-build-deps --install --remove --tool "apt-get --yes --no-install-recommends" debian/control
32+
- gbp buildpackage --git-ignore-new --git-ignore-branch -uc -us
33+
- mkdir -p artifacts
34+
- dcmd mv ../*.changes ../*.build artifacts/
35+
artifacts:
36+
paths:
37+
- artifacts/*
38+
39+
.build-jessie:
40+
extends: .build-debs
41+
allow_failure: true
42+
variables:
43+
DEBIAN_RELEASE_NAME: jessie
44+
45+
.build-stretch:
46+
extends: .build-debs
47+
variables:
48+
DEBIAN_RELEASE_NAME: stretch
49+
50+
.build-buster:
51+
extends: .build-debs
52+
variables:
53+
DEBIAN_RELEASE_NAME: buster
54+
55+
# Upload deb packages to development repository.
56+
# We use scp to upload all the files to an incoming directory.
57+
58+
.before_upload: &before_upload
59+
before_script:
60+
# Ensure required variables have been set
61+
- test -n "${DEV_REPO_HOST}"
62+
- test -n "${DEV_REPO_KNOWN_HOSTS}"
63+
- test -n "${DEV_REPO_SSH_SUBMIT_KEY}"
64+
# Install dependencies
65+
- apt-get update && apt-get install --yes --no-install-recommends devscripts openssh-client
66+
# Configure ssh
67+
- eval $(ssh-agent -s)
68+
- echo "$DEV_REPO_SSH_SUBMIT_KEY" | tr -d '\r' | ssh-add - >/dev/null
69+
- mkdir --mode 700 -p ~/.ssh
70+
- echo "CheckHostIP no" >>~/.ssh/config
71+
- echo "$DEV_REPO_KNOWN_HOSTS" >~/.ssh/known_hosts
72+
- chmod 644 ~/.ssh/known_hosts
73+
74+
upload-debs:
75+
stage: upload-debian-packages
76+
image: debian:latest
77+
rules:
78+
- if: $CI_PIPELINE_SOURCE == 'schedule'
79+
when: never # Nightly jobs do not upload
80+
- if: '$CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH =~ $GITBOX_CI_UPLOAD_BRANCHES'
81+
when: always # Auto-upload if merged to upload branch
82+
- if: $CI_COMMIT_TAG
83+
when: always # Auto-upload if tagged
84+
- when: manual # Otherwise allow manual upload from branch
85+
allow_failure: true
86+
<<: *before_upload
87+
script:
88+
- find artifacts/* -ls
89+
# scp all files referenced by the changes files to the repository
90+
- dcmd scp artifacts/*.changes dists@$DEV_REPO_HOST:deb-repo/incoming
91+
92+
# Copy packages to golden repo if they have a `release` tag.
93+
# Note that this must come after `upload-debs`
94+
95+
.copy-to-golden:
96+
stage: copy-to-golden
97+
image: debian:latest
98+
rules:
99+
- if: '$CI_COMMIT_TAG && $CI_COMMIT_TAG =~ $GITBOX_CI_RELEASE_TAGS && $DEBIAN_RELEASE_NAME =~ $GITBOX_CI_GOLDEN_RELEASES'
100+
when: always
101+
- when: manual
102+
allow_failure: true
103+
<<: *before_upload
104+
script:
105+
- ci/copy-to-golden "$DEBIAN_RELEASE_NAME" artifacts/*.changes
106+
107+
.golden-jessie:
108+
extends: .copy-to-golden
109+
allow_failure: true
110+
variables:
111+
DEBIAN_RELEASE_NAME: jessie
112+
113+
.golden-stretch:
114+
extends: .copy-to-golden
115+
variables:
116+
DEBIAN_RELEASE_NAME: stretch
117+
118+
.golden-buster:
119+
extends: .copy-to-golden
120+
variables:
121+
DEBIAN_RELEASE_NAME: buster

ci/update-debian-changelog

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#!/bin/sh
2+
3+
# This script ensures that the package version is appropriate
4+
# for the distribution that we are building for.
5+
#
6+
# = Snapshot builds =
7+
# We use git-buildpackage's dch subcommand to generate a changelog
8+
# containing git commit information. While not as good as a hand
9+
# edited changelog, it contains enough information to help testers
10+
# understand which changes are contained in the package.
11+
#
12+
# We use gbp-dch to set a version number based on the commit date
13+
# and git commit id.
14+
#
15+
# = Building from tags =
16+
# If we are building for a tag, we generate final release packages:
17+
# * Leave the changelog entries as they are
18+
# * If a backport, generate a backport changelog entry
19+
#
20+
# = Distribution flag =
21+
# In all cases, we want to make sure that the distribution name
22+
# is set. This is to ensure that reprepro assigns the package to
23+
# the correct distribution. We determine the distribution
24+
# using lsb_release.
25+
26+
if [ -n "$1" ]
27+
then
28+
# The debian directory is in another directory
29+
DEBIAN_DIR="$1"
30+
if [ ! -d "$DEBIAN_DIR" ]
31+
then
32+
echo >&2 Directory \"$DEBIAN_DIR\" not found
33+
exit 1
34+
fi
35+
GBP_SINCE_PARAM="-s $(git rev-list --max-count=1 HEAD -- "$DEBIAN_DIR"/debian/changelog)"
36+
export GIT_DIR="$(realpath .git)"
37+
cd "$DEBIAN_DIR"
38+
else
39+
DEBIAN_DIR=
40+
GBP_SINCE_PARAM="--auto"
41+
fi
42+
43+
# Determine the release name and number that we are building for
44+
DEBIAN_RELEASE_NAME="$(lsb_release --codename --short)"
45+
46+
# Ensure generated changelog entries have the same
47+
export DEBEMAIL="$(dpkg-parsechangelog --show-field Maintainer)"
48+
49+
# To ensure package version numbers for backports follow in the
50+
# correct order, we treat stable/oldstable as a backport build
51+
if [ "$DEBIAN_RELEASE_NAME" = "bullseye" ]
52+
then
53+
BPO_FLAG=
54+
else
55+
BPO_FLAG=--bpo
56+
fi
57+
58+
# Are we building a snapshot or tag?
59+
if [ -z "${CI_COMMIT_TAG}" ]
60+
then
61+
# Snapshot build
62+
63+
# Install git-buildpackage
64+
which gbp || apt-get install --yes --no-install-recommends git-buildpackage
65+
66+
COMMIT_TS="$(git show --no-patch --pretty=format:%ct HEAD)"
67+
COMMIT_DATE="$(date --date="@${COMMIT_TS}" +%Y%m%d%H%M)"
68+
CURRENT_VERSION="$(dpkg-parsechangelog --show-field Version)"
69+
SINCE_HASH="$(git rev-list --max-count=1 HEAD -- linotpd/src/debian/changelog)"
70+
71+
gbp dch $GBP_SINCE_PARAM --snapshot --snapshot-number="${COMMIT_DATE}" --no-multimaint --ignore-branch $BPO_FLAG
72+
else
73+
# Tagged build
74+
75+
# Only create a changelog entry if we are creating a backport version
76+
if [ -n "$BPO_FLAG" ]
77+
then
78+
dch --bpo "Autobuilt by CI"
79+
fi
80+
fi
81+
82+
# In order to upload to our internal archive, we need to set the distribution to
83+
# correct destination distribution
84+
CURRENT_DISTRIBUTION="$(dpkg-parsechangelog --show-field Distribution)"
85+
sed -i "1s/ ${CURRENT_DISTRIBUTION}\(; urgency=\)/ ${DEBIAN_RELEASE_NAME}\1/" debian/changelog
86+
87+
# Show the results
88+
dpkg-parsechangelog
89+
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272

7373
def usage():
7474
print("usage: %s --url=<url> --admin=<adminusername> --cert=<cert> --key=<rsakey> --command=<command> --version" % sys.argv[0])
75-
print("""" --url/-U : The base url of the LinOTP server. Something like
75+
print(""" --url/-U : The base url of the LinOTP server. Something like
7676
http://localhost:5000 or https://linotp:443
7777
--admin/-a : If the admin interface of the LinOTP service requires authentication
7878
you need to pass the username and will be asked for the password.

linotpadminclientcli/clientutils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ def connect(self, path, param, data={}, json_format=True):
342342

343343
p = None
344344
if req_params:
345-
p = urllib.parse.urlencode(req_params)
345+
p = urllib.parse.urlencode(req_params).encode("utf-8")
346346

347347
req_url = self.protocol + '://' + self.url + path
348348
f = urllib.request.urlopen(urllib.request.Request(req_url, p))

0 commit comments

Comments
 (0)