Skip to content

Commit 500bdc3

Browse files
committed
🔖 release v0.6.1 - deb/rpm binary packages
1 parent c8c3d15 commit 500bdc3

10 files changed

Lines changed: 150 additions & 10 deletions

File tree

.earthignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
target/
2+
.config.toml

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "aeneid"
3-
version = "0.6.0"
3+
version = "0.6.1"
44
authors = ["Nikhil Jha <mail@nikhiljha.com>"]
55
edition = "2018"
66
description = "use GitHub as a free, zero-ops Identity Provider"
@@ -11,7 +11,30 @@ license = "GPL-3.0-only"
1111
keywords = ["github", "openssh"]
1212
categories = ["authentication"]
1313

14-
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
14+
[package.metadata.deb]
15+
maintainer = "Nikhil Jha <mail@nikhiljha.com>"
16+
copyright = "2021, Nikhil Jha <mail@nikhiljha.com>"
17+
extended-description = """\
18+
Use GitHub as a free, zero-ops Identity Provider \
19+
by using github authorized_keys for your sshd."""
20+
maintainer-scripts = "pkg/deb/"
21+
conf-files = ["etc/aeneid/config.toml"]
22+
assets = [
23+
["target/release/aeneid", "usr/bin/", "755"],
24+
["README.md", "usr/share/doc/aeneid/README", "644"],
25+
["src/config.toml", "etc/aeneid/config.toml", "700"],
26+
]
27+
28+
[package.metadata.rpm]
29+
package = "aeneid"
30+
config = "pkg/rpm"
31+
files = {"../../src/config.toml" = {path = "/etc/aeneid/config.toml"}}
32+
33+
[package.metadata.rpm.cargo]
34+
buildflags = ["--release"]
35+
36+
[package.metadata.rpm.targets]
37+
aeneid = { path = "/usr/bin/aeneid" }
1538

1639
[dependencies]
1740
reqwest = { version = "0.11.4", features = ["blocking", "json", "rustls-tls"], default-features = false }
@@ -20,3 +43,4 @@ regex = "1.4.5"
2043
toml = "0.5.8"
2144
serde_derive = "1.0.127"
2245
serde = "1.0.127"
46+

Earthfile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
FROM rust:1.54-slim
2+
WORKDIR .
3+
4+
debian:
5+
RUN apt-get update
6+
RUN apt-get install -y gnulib
7+
RUN cargo install cargo-deb
8+
COPY Cargo.toml ./
9+
COPY Cargo.lock ./
10+
COPY src src
11+
COPY pkg pkg
12+
COPY README.md README.md
13+
RUN cargo deb
14+
SAVE ARTIFACT /target/debian /debian AS LOCAL target/debian
15+
16+
rpm:
17+
RUN apt-get update
18+
RUN apt-get install -y rpm
19+
RUN cargo install --git https://github.com/iqlusioninc/cargo-rpm
20+
COPY Cargo.toml ./
21+
COPY Cargo.lock ./
22+
COPY src src
23+
COPY pkg pkg
24+
COPY README.md README.md
25+
RUN cargo rpm build
26+
SAVE ARTIFACT /target/release/rpmbuild /rpm AS LOCAL target/release/rpmbuild

README.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,19 @@ GitHub's "teams" feature is basically a free, zero-ops [IdP](https://en.wikipedi
1515

1616
Install aeneid with your usual package manager. If that's not possible, you can use cargo.
1717

18-
**cargo** (not recommended, see FAQ): `cargo install aeneid && cp $(whereis aeneid | cut -f 2 -d " ") /usr/local/bin && cargo uninstall aeneid && sudo /usr/local/bin/aeneid --init init`
18+
**deb** (Debian, Ubuntu, etc): [download from GitHub releases](https://github.com/nikhiljha/aeneid/releases) then `dpkg -i /path/to/aeneid.deb`
19+
20+
**rpm** (Fedora, RHEL, etc): [download from GitHub releases](https://github.com/nikhiljha/aeneid/releases) then `rpm -i /path/to/aeneid.rpm`
21+
22+
**nix** (NixOS, etc): coming soon (TM)...
23+
24+
**cargo** (not recommended, see FAQ): `cargo install aeneid && cp $(whereis aeneid | cut -f 2 -d " ") /usr/local/bin && cargo uninstall aeneid && sudo /usr/local/bin/aeneid --init`
1925

2026
## Configuration
2127

2228
**Automatic Configuration**
2329

24-
If you used one of the commands in the installation section, everything should be automatically configured. Just add credentials to `/etc/aeneid/config.toml`.
30+
If you used one of the commands in the installation section, everything should be automatically configured. Just add credentials (and/or overrides) to `/etc/aeneid/config.toml`, and then run `sudo aeneid --init` to automatically configure your sshd. If you'd rather manually configure your sshd, see the paragraph about sshd in the manual configuration section.
2531

2632
**Manual Configuration**
2733

@@ -33,11 +39,12 @@ You'll also need to set `AuthorizedKeysCommand /path/to/bin/aeneid` and `Authori
3339

3440
## Usage
3541

36-
If your GitHub username starts with a number, prefix your username with an `_` to login. Otherwise, your username is your GitHub username. See the `unix_to_github` function in `main.rs` for more information.
42+
If you specified a unix username in `overrides`, use that username. If you're using GitHub teams, and your username starts with a number, prefix your username with an `_` to login. Otherwise, your username is your GitHub username. See the `unix_to_github` function in `main.rs` for more information.
3743

38-
Automatically creating users is currently unsupported, you'll need to create the corresponding user manually before logging in (`adduser username`).
44+
Automatically creating users is currently unsupported, you'll need to create the corresponding user manually before first login (`adduser username`).
3945

4046
```bash
47+
$ # make sure ssh is setup with your GitHub keys, then...
4148
$ ssh username@example.com # that's it
4249
```
4350

pkg/.noinit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# the presence of this file will break aeneid --init

pkg/deb/postinst

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# adapted from PostgreSQL postgresql-common.postinst
2+
if [ "$1" = configure ]; then
3+
# Make sure the administrative user exists
4+
if ! getent passwd aeneid > /dev/null; then
5+
adduser --system $quiet --home /etc/aeneid --no-create-home \
6+
--shell /bin/bash --group --gecos "aeneid user" aeneid
7+
fi
8+
# if the user was created manually, make sure the group is there as well
9+
if ! getent group aeneid > /dev/null; then
10+
addgroup --system $quiet aeneid
11+
fi
12+
# make sure aeneid is in the aeneid group
13+
if ! id -Gn aeneid | grep -qw aeneid; then
14+
adduser $quiet aeneid aeneid
15+
fi
16+
17+
# check validity of aeneid user and group
18+
if [ "`id -u aeneid`" -eq 0 ]; then
19+
echo "The aeneid system user must not have uid 0 (root).
20+
Please fix this and reinstall this package." >&2
21+
exit 1
22+
fi
23+
if [ "`id -g aeneid`" -eq 0 ]; then
24+
echo "The aeneid system user must not have root as primary group.
25+
Please fix this and reinstall this package." >&2
26+
exit 1
27+
fi
28+
29+
# ensure config directory ownership
30+
mkdir -p /etc/aeneid
31+
su -s /bin/sh aeneid -c "test -O /etc/aeneid &&
32+
test -G /etc/aeneid" || \
33+
chown -R aeneid:aeneid /etc/aeneid
34+
fi

pkg/rpm/aeneid.spec

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
%define __spec_install_post %{nil}
2+
%define __os_install_post %{_dbpath}/brp-compress
3+
%define debug_package %{nil}
4+
5+
Name: aeneid
6+
Summary: use GitHub as a free, zero-ops Identity Provider
7+
Version: @@VERSION@@
8+
Release: @@RELEASE@@%{?dist}
9+
License: GPLv3
10+
Group: Applications/System
11+
Source0: %{name}-%{version}.tar.gz
12+
URL: https://nikhiljha.com/projects/
13+
14+
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
15+
16+
%description
17+
%{summary}
18+
19+
%prep
20+
%setup -q
21+
22+
%install
23+
rm -rf %{buildroot}
24+
mkdir -p %{buildroot}
25+
cp -a * %{buildroot}
26+
27+
%clean
28+
rm -rf %{buildroot}
29+
30+
%files
31+
%defattr(-,root,root,-)
32+
%{_bindir}/*
33+
%config(noreplace) %{_sysconfdir}/aeneid/config.toml
34+
35+
%post
36+
# create aeneid user
37+
groupadd -r aeneid >/dev/null 2>&1 || :
38+
useradd -M -n -g aeneid -r -d /etc/aeneid -s /bin/bash \
39+
-c "aeneid user" aeneid >/dev/null 2>&1 || :
40+
# create directories so aeneid can store caches and read config files
41+
install -d -o aeneid -g aeneid /etc/aeneid
42+
chown -R aeneid:aeneid /etc/aeneid

src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ pub(crate) fn init() {
7373
if !cmd_configured.is_match(&*contents) && !user_configured.is_match(&*contents) {
7474
file.write(
7575
format!(
76-
"AuthorizedKeysCommand {}\nAuthorizedKeysCommandUser aeneid",
76+
"\nAuthorizedKeysCommand {}\nAuthorizedKeysCommandUser aeneid\n",
7777
std::env::current_exe()
7878
.expect("get executable")
7979
.to_str()

src/main.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@ fn main() {
1212
.version(env!("CARGO_PKG_VERSION"))
1313
.author("Nikhil Jha <mail@nikhiljha.com>")
1414
.about("authenticate SSH users with their GitHub authorized_keys")
15-
.arg("-i, --init 'initialize aeneid'")
16-
.arg("<username> 'a unix username'")
15+
.arg("-i, --init 'Initializes aeneid'")
16+
.arg(clap::Arg::new("username")
17+
.conflicts_with("init")
18+
.required(true)
19+
.about("a unix username")
20+
)
1721
.get_matches();
1822

1923
if args.is_present("init") {

0 commit comments

Comments
 (0)