packages/ak-lib: init (#21257)

* packages/ak-lib: init

Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space>

* fixup

Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space>

---------

Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space>
This commit is contained in:
Marc 'risson' Schmitt
2026-03-31 09:33:46 +00:00
committed by GitHub
parent b9cc9e9cc3
commit 55e555c047
8 changed files with 69 additions and 5 deletions

5
.cargo/config.toml Normal file
View File

@@ -0,0 +1,5 @@
[alias]
t = ["nextest", "run"]
[build]
rustflags = ["--cfg", "tokio_unstable"]

View File

@@ -10,4 +10,4 @@ build_docs/**
blueprints/local
.git
.venv
target/
target

View File

@@ -27,6 +27,7 @@ Makefile @goauthentik/infrastructure
.editorconfig @goauthentik/infrastructure
CODEOWNERS @goauthentik/infrastructure
# Backend packages
packages/ak-* @goauthentik/backend
packages/client-rust @goauthentik/backend
packages/django-channels-postgres @goauthentik/backend
packages/django-postgres-cache @goauthentik/backend

5
Cargo.lock generated
View File

@@ -102,6 +102,10 @@ dependencies = [
"uuid",
]
[[package]]
name = "authentik-lib"
version = "2026.5.0-rc1"
[[package]]
name = "autocfg"
version = "1.5.0"
@@ -1814,6 +1818,7 @@ dependencies = [
"signal-hook-registry",
"socket2",
"tokio-macros",
"tracing",
"windows-sys 0.61.2",
]

View File

@@ -1,5 +1,9 @@
[workspace]
members = ["packages/client-rust", "website/scripts/docsmg"]
members = [
"packages/ak-lib",
"packages/client-rust",
"website/scripts/docsmg",
]
resolver = "3"
[workspace.package]
@@ -42,11 +46,15 @@ serde_repr = "= 0.1.20"
serde_with = { version = "= 3.18.0", default-features = false, features = [
"base64",
] }
tokio = { version = "= 1.50.0", features = ["full"] }
tokio = { version = "= 1.50.0", features = ["full", "tracing"] }
tokio-util = { version = "= 0.7.18", features = ["full"] }
url = "= 2.5.8"
uuid = { version = "= 1.23.0", features = ["serde", "v4"] }
lib = { package = "authentik-lib", version = "2026.5.0-rc1", path = "./packages/ak-lib" }
authentik-client = { version = "2026.5.0-rc1", path = "./packages/client-rust" }
[profile.dev.package.backtrace]
opt-level = 3
@@ -89,12 +97,20 @@ perf = { priority = -1, level = "warn" }
style = { priority = -1, level = "warn" }
suspicious = { priority = -1, level = "warn" }
### and disable the ones we don't want
### cargo group
multiple_crate_versions = "allow"
### pedantic group
missing_errors_doc = "allow"
missing_panics_doc = "allow"
must_use_candidate = "allow"
redundant_closure_for_method_calls = "allow"
struct_field_names = "allow"
too_many_lines = "allow"
### nursery
redundant_pub_crate = "allow"
missing_const_for_fn = "allow"
option_if_let_else = "allow"
redundant_pub_crate = "allow"
significant_drop_tightening = "allow"
### restriction group
allow_attributes = "warn"
allow_attributes_without_reason = "warn"
@@ -107,7 +123,6 @@ create_dir = "warn"
dbg_macro = "warn"
default_numeric_fallback = "warn"
disallowed_script_idents = "warn"
doc_paragraphs_missing_punctuation = "warn"
empty_drop = "warn"
empty_enum_variants_with_brackets = "warn"
empty_structs_with_brackets = "warn"

View File

@@ -153,6 +153,7 @@ endif
$(eval current_version := $(shell cat ${PWD}/internal/constants/VERSION))
$(SED_INPLACE) 's/^version = ".*"/version = "$(version)"/' ${PWD}/pyproject.toml
$(SED_INPLACE) 's/^VERSION = ".*"/VERSION = "$(version)"/' ${PWD}/authentik/__init__.py
$(SED_INPLACE) "s/version = \"${current_version}\"/version = \"$(version)\"" ${PWD}/Cargo.toml ${PWD}/Cargo.lock
$(MAKE) gen-build gen-compose aws-cfn
$(SED_INPLACE) "s/\"${current_version}\"/\"$(version)\"/" ${PWD}/package.json ${PWD}/package-lock.json ${PWD}/web/package.json ${PWD}/web/package-lock.json
echo -n $(version) > ${PWD}/internal/constants/VERSION

View File

@@ -0,0 +1,17 @@
[package]
name = "authentik-lib"
version.workspace = true
authors.workspace = true
edition.workspace = true
readme.workspace = true
homepage.workspace = true
repository.workspace = true
license-file.workspace = true
publish.workspace = true
[dependencies]
[dev-dependencies]
[lints]
workspace = true

View File

@@ -0,0 +1,20 @@
//! Various utilities used by other crates
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
pub fn authentik_build_hash(fallback: Option<String>) -> String {
std::env::var("GIT_BUILD_HASH").unwrap_or_else(|_| fallback.unwrap_or_default())
}
pub fn authentik_full_version() -> String {
let build_hash = authentik_build_hash(None);
if build_hash.is_empty() {
VERSION.to_owned()
} else {
format!("{VERSION}+{build_hash}")
}
}
pub fn authentik_user_agent() -> String {
format!("authentik@{}", authentik_full_version())
}