Compare commits
12 Commits
15f7f016a8
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
f03ab650fd
|
|||
|
7512ed35b8
|
|||
|
3b439f15e2
|
|||
|
e9fe169a9a
|
|||
|
d602220c4b
|
|||
|
988c475c5e
|
|||
|
3470d4ca4f
|
|||
|
e78a7b63da
|
|||
|
3b09655783
|
|||
|
9ef64b56ed
|
|||
|
922291dd02
|
|||
|
758b7cd760
|
2
.cargo/config.toml
Normal file
2
.cargo/config.toml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
[env]
|
||||||
|
RUSTC_BOOTSTRAP = "1"
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
*
|
*
|
||||||
!src
|
!src
|
||||||
!Cargo.*
|
!Cargo.*
|
||||||
|
!.cargo/config.toml
|
||||||
|
|||||||
@@ -7,89 +7,10 @@ on:
|
|||||||
tags:
|
tags:
|
||||||
- v*.*.*
|
- v*.*.*
|
||||||
|
|
||||||
env:
|
|
||||||
OCI_REPO: git.huizinga.dev/dreaded_x/${{ gitea.event.repository.name}}
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
name: Build container and manifests
|
uses: dreaded_x/workflows/.gitea/workflows/rust-kubernetes.yaml@66ab50c3ac239dbdd1e42e6276ec2e65b6a79379
|
||||||
runs-on: ubuntu-latest
|
secrets: inherit
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
generate_crds: true
|
||||||
fetch-tags: true
|
webhook_url: ${{ secrets.WEBHOOK_URL }}
|
||||||
|
|
||||||
# TODO: Actually set an env variable and use it in the application
|
|
||||||
- name: Set version string
|
|
||||||
run: |
|
|
||||||
git describe --always --dirty="-modified"
|
|
||||||
|
|
||||||
- name: Get Git commit timestamps
|
|
||||||
run: echo "TIMESTAMP=$(git log -1 --pretty=%ct)" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Login to registry
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
registry: git.huizinga.dev
|
|
||||||
username: ${{ gitea.actor }}
|
|
||||||
password: ${{ secrets.REGISTRY_TOKEN }}
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
|
|
||||||
- name: Install kustomize
|
|
||||||
run: |
|
|
||||||
curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
|
|
||||||
|
|
||||||
- name: Setup Flux CLI
|
|
||||||
uses: https://github.com/fluxcd/flux2/action@main
|
|
||||||
with:
|
|
||||||
version: v2.5.0
|
|
||||||
|
|
||||||
- name: Docker meta
|
|
||||||
id: meta
|
|
||||||
uses: docker/metadata-action@v5
|
|
||||||
with:
|
|
||||||
images: ${{ env.OCI_REPO }}
|
|
||||||
tags: |
|
|
||||||
type=edge
|
|
||||||
type=ref,event=branch
|
|
||||||
type=semver,pattern=v{{version}}
|
|
||||||
type=semver,pattern=v{{major}}.{{minor}}
|
|
||||||
type=semver,pattern=v{{major}}
|
|
||||||
|
|
||||||
- name: Build container
|
|
||||||
id: build
|
|
||||||
uses: docker/build-push-action@v6
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
push: true
|
|
||||||
sbom: true
|
|
||||||
provenance: mode=max
|
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
|
||||||
annotations: ${{ steps.meta.outputs.annotations }}
|
|
||||||
cache-from: type=gha
|
|
||||||
cache-to: type=gha,mode=max
|
|
||||||
env:
|
|
||||||
SOURCE_DATE_EPOCH: ${{ env.TIMESTAMP }}
|
|
||||||
|
|
||||||
- name: Generate CRDs
|
|
||||||
run: |
|
|
||||||
docker run --rm ${{ env.OCI_REPO }}@${{ steps.build.outputs.imageid }} /crdgen > ./manifests/crds.yaml
|
|
||||||
|
|
||||||
- name: Kustomize manifests
|
|
||||||
run: |
|
|
||||||
./kustomize build ./manifests | sed "s/\${DIGEST}/${{ steps.build.outputs.digest }}/" > ./manifests.yaml
|
|
||||||
|
|
||||||
- name: Push manifests
|
|
||||||
run: |
|
|
||||||
flux push artifact oci://${{ env.OCI_REPO }}/manifests:${{ gitea.head_ref || gitea.ref_name }} \
|
|
||||||
--path="./manifests.yaml" \
|
|
||||||
--source="$(git config --get remote.origin.url)" \
|
|
||||||
--revision="$(git rev-parse HEAD)" \
|
|
||||||
$(echo "${{ steps.meta.outputs.labels }}" | sed -e 's/^/-a /')
|
|
||||||
|
|
||||||
flux tag artifact oci://${{ env.OCI_REPO }}/manifests:${{ gitea.head_ref || gitea.ref_name }} \
|
|
||||||
$(echo "${{ steps.meta.outputs.tags }}" | sed -e 's/^.*:/--tag /')
|
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ repos:
|
|||||||
- id: udeps
|
- id: udeps
|
||||||
name: unused
|
name: unused
|
||||||
description: Check for unused crates
|
description: Check for unused crates
|
||||||
entry: cargo udeps
|
entry: cargo +nightly udeps
|
||||||
args: ["--workspace"]
|
args: ["--workspace"]
|
||||||
language: system
|
language: system
|
||||||
types: [file]
|
types: [file]
|
||||||
|
|||||||
21
Cargo.lock
generated
21
Cargo.lock
generated
@@ -97,6 +97,7 @@ dependencies = [
|
|||||||
"color-eyre",
|
"color-eyre",
|
||||||
"dotenvy",
|
"dotenvy",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
|
"git-version",
|
||||||
"k8s-openapi",
|
"k8s-openapi",
|
||||||
"kube",
|
"kube",
|
||||||
"schemars",
|
"schemars",
|
||||||
@@ -555,6 +556,26 @@ version = "0.28.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253"
|
checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "git-version"
|
||||||
|
version = "0.3.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1ad568aa3db0fcbc81f2f116137f263d7304f512a1209b35b85150d3ef88ad19"
|
||||||
|
dependencies = [
|
||||||
|
"git-version-macro",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "git-version-macro"
|
||||||
|
version = "0.3.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "53010ccb100b96a67bc32c0175f0ed1426b31b655d562898e57325f81c023ac0"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gloo-timers"
|
name = "gloo-timers"
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ default-run = "authelia-controller"
|
|||||||
color-eyre = "0.6.3"
|
color-eyre = "0.6.3"
|
||||||
dotenvy = "0.15.7"
|
dotenvy = "0.15.7"
|
||||||
futures-util = "0.3.31"
|
futures-util = "0.3.31"
|
||||||
|
git-version = "0.3.9"
|
||||||
k8s-openapi = { version = "0.24.0", features = ["v1_31"] }
|
k8s-openapi = { version = "0.24.0", features = ["v1_31"] }
|
||||||
kube = { version = "0.99.0", features = ["derive", "runtime"] }
|
kube = { version = "0.99.0", features = ["derive", "runtime"] }
|
||||||
schemars = "0.8.22"
|
schemars = "0.8.22"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
FROM rust:1.85 AS base
|
FROM rust:1.86 AS base
|
||||||
ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse
|
ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse
|
||||||
RUN cargo install cargo-chef --locked --version 0.1.71 && \
|
RUN cargo install cargo-chef --locked --version 0.1.71 && \
|
||||||
cargo install cargo-auditable --locked --version 0.6.6
|
cargo install cargo-auditable --locked --version 0.6.6
|
||||||
@@ -13,7 +13,8 @@ COPY --from=planner /app/recipe.json recipe.json
|
|||||||
RUN cargo chef cook --release --recipe-path recipe.json
|
RUN cargo chef cook --release --recipe-path recipe.json
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
ENV RUSTC_BOOTSTRAP=1
|
ARG RELEASE_VERSION
|
||||||
|
ENV RELEASE_VERSION=${RELEASE_VERSION}
|
||||||
RUN cargo auditable build --release
|
RUN cargo auditable build --release
|
||||||
|
|
||||||
FROM gcr.io/distroless/cc-debian12:nonroot AS runtime
|
FROM gcr.io/distroless/cc-debian12:nonroot AS runtime
|
||||||
|
|||||||
@@ -15,6 +15,11 @@ rules:
|
|||||||
- ""
|
- ""
|
||||||
resources:
|
resources:
|
||||||
- secrets
|
- secrets
|
||||||
|
verbs:
|
||||||
|
- "*"
|
||||||
|
- apiGroups:
|
||||||
|
- "apps"
|
||||||
|
resources:
|
||||||
- deployments
|
- deployments
|
||||||
verbs:
|
verbs:
|
||||||
- "*"
|
- "*"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
kind: Kustomization
|
kind: Kustomization
|
||||||
namespace: lldap
|
namespace: authelia
|
||||||
resources:
|
resources:
|
||||||
- ./crds.yaml
|
- ./crds.yaml
|
||||||
- ./service-account.yaml
|
- ./service-account.yaml
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
[toolchain]
|
[toolchain]
|
||||||
channel = "1.85"
|
channel = "1.86"
|
||||||
profile = "default"
|
profile = "default"
|
||||||
components = ["rust-analyzer"]
|
components = ["rust-analyzer"]
|
||||||
|
|||||||
@@ -1,2 +1,6 @@
|
|||||||
|
#![feature(let_chains)]
|
||||||
pub mod context;
|
pub mod context;
|
||||||
pub mod resources;
|
pub mod resources;
|
||||||
|
mod version;
|
||||||
|
|
||||||
|
pub use version::VERSION;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
|
use authelia_controller::VERSION;
|
||||||
use authelia_controller::context::Context;
|
use authelia_controller::context::Context;
|
||||||
use authelia_controller::resources::AccessControlRule;
|
use authelia_controller::resources::AccessControlRule;
|
||||||
use color_eyre::eyre::Context as _;
|
use color_eyre::eyre::Context as _;
|
||||||
@@ -39,7 +40,7 @@ async fn main() -> color_eyre::Result<()> {
|
|||||||
})
|
})
|
||||||
.unwrap_or(Ok(15))?;
|
.unwrap_or(Ok(15))?;
|
||||||
|
|
||||||
info!("Starting");
|
info!(version = VERSION, "Starting");
|
||||||
|
|
||||||
let client = Client::try_default().await?;
|
let client = Client::try_default().await?;
|
||||||
let access_control_rules = Api::<AccessControlRule>::all(client.clone());
|
let access_control_rules = Api::<AccessControlRule>::all(client.clone());
|
||||||
|
|||||||
@@ -29,12 +29,17 @@ enum AccessPolicy {
|
|||||||
)]
|
)]
|
||||||
#[kube(
|
#[kube(
|
||||||
shortname = "acl",
|
shortname = "acl",
|
||||||
doc = "Custom resource for managing authelia access rules"
|
doc = "Custom resource for managing authelia access rules",
|
||||||
|
printcolumn = r#"{"name":"Domain", "type":"string", "jsonPath":".spec.domain"}"#,
|
||||||
|
printcolumn = r#"{"name":"Policy", "type":"string", "jsonPath":".spec.policy"}"#,
|
||||||
|
printcolumn = r#"{"name":"Subject", "type":"string", "jsonPath":".spec.subject"}"#,
|
||||||
|
printcolumn = r#"{"name":"Age", "type":"date", "jsonPath":".metadata.creationTimestamp"}"#
|
||||||
)]
|
)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct AccessControlRuleSpec {
|
pub struct AccessControlRuleSpec {
|
||||||
domain: String,
|
domain: String,
|
||||||
policy: AccessPolicy,
|
policy: AccessPolicy,
|
||||||
|
subject: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug, Hash)]
|
#[derive(Serialize, Deserialize, Clone, Debug, Hash)]
|
||||||
@@ -72,6 +77,7 @@ impl AccessControlRule {
|
|||||||
|
|
||||||
let secret = Secret {
|
let secret = Secret {
|
||||||
metadata: ObjectMeta {
|
metadata: ObjectMeta {
|
||||||
|
name: Some(ctx.secret_name.clone()),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
string_data: Some(contents),
|
string_data: Some(contents),
|
||||||
|
|||||||
11
src/version.rs
Normal file
11
src/version.rs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
pub const VERSION: &str = get_version();
|
||||||
|
|
||||||
|
const fn get_version() -> &'static str {
|
||||||
|
if let Some(version) = std::option_env!("RELEASE_VERSION")
|
||||||
|
&& !version.is_empty()
|
||||||
|
{
|
||||||
|
version
|
||||||
|
} else {
|
||||||
|
git_version::git_version!(fallback = "unknown")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,3 +5,4 @@ metadata:
|
|||||||
spec:
|
spec:
|
||||||
domain: "test-2.domain"
|
domain: "test-2.domain"
|
||||||
policy: one_factor
|
policy: one_factor
|
||||||
|
subject: group:lldap_admin
|
||||||
|
|||||||
Reference in New Issue
Block a user