Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: Tidy contributor onboarding, fix typos. #12700

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions .github/codespell-words.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,32 @@
akadmin
asgi
assertIn
authentik
authn
crate
docstrings
entra
goauthentik
gunicorn
hass
jwe
jwks
keypair
keypairs
hass
warmup
kubernetes
oidc
ontext
openid
passwordless
plex
saml
scim
singed
assertIn
slo
sso
totp
traefik
# https://github.com/codespell-project/codespell/issues/1224
upToDate
warmup
webauthn
22 changes: 0 additions & 22 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,4 @@
{
"cSpell.words": [
"akadmin",
"asgi",
"authentik",
"authn",
"entra",
"goauthentik",
"jwe",
"jwks",
"kubernetes",
"oidc",
"openid",
"passwordless",
"plex",
"saml",
"scim",
"slo",
"sso",
"totp",
"traefik",
"webauthn"
],
"todo-tree.tree.showCountsInTree": true,
"todo-tree.tree.showBadges": true,
"yaml.customTags": [
Expand Down
32 changes: 16 additions & 16 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
identity and expression, level of experience, education, socioeconomic status,
nationality, personal appearance, race, religion, or sexual identity
and orientation.

Expand All @@ -17,24 +17,24 @@ diverse, inclusive, and healthy community.
Examples of behavior that contributes to a positive environment for our
community include:

- Demonstrating empathy and kindness toward other people
- Being respectful of differing opinions, viewpoints, and experiences
- Giving and gracefully accepting constructive feedback
- Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
- Focusing on what is best not just for us as individuals, but for the
overall community
- Demonstrating empathy and kindness toward other people
- Being respectful of differing opinions, viewpoints, and experiences
- Giving and gracefully accepting constructive feedback
- Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
- Focusing on what is best not just for us as individuals, but for the
overall community

Examples of unacceptable behavior include:

- The use of sexualized language or imagery, and sexual attention or
advances of any kind
- Trolling, insulting or derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or email
address, without their explicit permission
- Other conduct which could reasonably be considered inappropriate in a
professional setting
- The use of sexualized language or imagery, and sexual attention or
advances of any kind
- Trolling, insulting or derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or email
address, without their explicit permission
- Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities

Expand Down
43 changes: 14 additions & 29 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
PWD = $(shell pwd)
UID = $(shell id -u)
GID = $(shell id -g)
NPM_VERSION = $(shell python -m scripts.npm_version)
NPM_VERSION = $(shell python -m scripts.generate_semver)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also do this

Suggested change
NPM_VERSION = $(shell python -m scripts.generate_semver)
NPM_VERSION = $(shell poetry run scripts/generate_semver.py)

PY_SOURCES = authentik tests scripts lifecycle .github website/docs/install-config/install/aws
DOCKER_IMAGE ?= "authentik:test"

Expand All @@ -16,20 +16,6 @@ pg_user := $(shell python -m authentik.lib.config postgresql.user 2>/dev/null)
pg_host := $(shell python -m authentik.lib.config postgresql.host 2>/dev/null)
pg_name := $(shell python -m authentik.lib.config postgresql.name 2>/dev/null)

CODESPELL_ARGS = -D - -D .github/codespell-dictionary.txt \
-I .github/codespell-words.txt \
-S 'web/src/locales/**' \
-S 'website/docs/developer-docs/api/reference/**' \
authentik \
internal \
cmd \
web/src \
website/src \
website/blog \
website/docs \
website/integrations \
website/src

all: lint-fix lint test gen web ## Lint, build, and test everything

HELP_WIDTH := $(shell grep -h '^[a-z][^ ]*:.*\#\#' $(MAKEFILE_LIST) 2>/dev/null | \
Expand All @@ -55,23 +41,21 @@ test-docker: ## Run all tests in a docker-compose
rm -f .env

test: ## Run the server tests and produce a coverage report (locally)
coverage run manage.py test --keepdb authentik
coverage html
coverage report
poetry run coverage run manage.py test --keepdb authentik
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually assume devs will already be in a poetry shell, but I don't think this should matter anyway.

However, in CI (.github/workflows/ci-main.yml for instance), we do poetry run make test, so that should be updated as well.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @rissson!

Thanks for reviewing my PR. I'm open to either approach, but it may help to keep the prefix.

When running make test without a Poetry shell activated, make doesn't know where to find the coverage command and emits an error without a hint at the solution.

❯ make test
coverage run manage.py test --keepdb authentik
make: coverage: No such file or directory
make: *** [test] Error 1

The virtual environment instructions appear in the full-stack setup docs, but my concern is that contributors who start with the front-end or docs environments might miss the Python requirements when switching contexts.

Since ci-main.yml uses the poetry prefix consistently, would it make sense to keep it for now? We could look at removing it from both places as a separate task if you think that would be valuable.

Thanks for your feedback!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So if you add poetry run invocations to the Makefile, then it makes sense to remove it from the CI.

Both approaches (having it in CI or having it in the Makefile) are valid, but I think we should only do one of them. I agree that having it in the Makefile is easier for new contributors

poetry run coverage html
poetry run coverage report

lint-fix: lint-codespell ## Lint and automatically fix errors in the python source code. Reports spelling errors.
black $(PY_SOURCES)
ruff check --fix $(PY_SOURCES)
poetry run black $(PY_SOURCES)
poetry run ruff check --fix $(PY_SOURCES)

lint-codespell: ## Reports spelling errors.
codespell -w $(CODESPELL_ARGS)
poetry run codespell -w

lint: ## Lint the python and golang sources
bandit -r $(PY_SOURCES) -x web/node_modules -x tests/wdio/node_modules -x website/node_modules
golangci-lint run -v
Comment on lines -70 to -71
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why those got removed


core-install:
poetry install
poetry run bandit -c pyproject.toml -r $(PY_SOURCES)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
poetry run bandit -c pyproject.toml -r $(PY_SOURCES)
poetry install


migrate: ## Run the Authentik Django server's migrations
python -m lifecycle.migrate
Expand Down Expand Up @@ -193,7 +177,7 @@ gen-client-go: gen-clean-go ## Build and install the authentik API for Golang
rm -rf ./${GEN_API_GO}/config.yaml ./${GEN_API_GO}/templates/

gen-dev-config: ## Generate a local development config file
python -m scripts.generate_config
poetry run scripts/generate_config.py

gen: gen-build gen-client-ts

Expand Down Expand Up @@ -274,16 +258,17 @@ ci--meta-debug:
node --version

ci-black: ci--meta-debug
black --check $(PY_SOURCES)
poetry run black --check $(PY_SOURCES)

ci-ruff: ci--meta-debug
ruff check $(PY_SOURCES)
poetry run ruff check $(PY_SOURCES)

ci-codespell: ci--meta-debug
codespell $(CODESPELL_ARGS) -s
poetry run codespell -s

ci-bandit: ci--meta-debug
bandit -r $(PY_SOURCES)
poetry run bandit -r $(PY_SOURCES)
golangci-lint run -v internal/...
Comment on lines +270 to +271
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
poetry run bandit -r $(PY_SOURCES)
golangci-lint run -v internal/...
poetry run bandit -r $(PY_SOURCES)


ci-pending-migrations: ci--meta-debug
ak makemigrations --check
2 changes: 1 addition & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ authentik takes security very seriously. We follow the rules of [responsible di

## Independent audits and pentests

We are committed to engaging in regular pentesting and security audits of authentik. Defining and adhering to a cadence of external testing ensures a stronger probability that our code base, our features, and our architecture is as secure and non-exploitable as possible. For more details about specfic audits and pentests, refer to "Audits and Certificates" in our [Security documentation](https://docs.goauthentik.io/docs/security).
We are committed to engaging in regular pentesting and security audits of authentik. Defining and adhering to a cadence of external testing ensures a stronger probability that our code base, our features, and our architecture is as secure and non-exploitable as possible. For more details about specific audits and pentests, refer to "Audits and Certificates" in our [Security documentation](https://docs.goauthentik.io/docs/security).

## What authentik classifies as a CVE

Expand Down
4 changes: 3 additions & 1 deletion lifecycle/wait_for_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ def wait_for_db():
# Sanity check, ensure SECRET_KEY is set before we even check for database connectivity
if CONFIG.get("secret_key") is None or len(CONFIG.get("secret_key")) == 0:
CONFIG.log("info", "----------------------------------------------------------------------")
CONFIG.log("info", "Secret key missing, check https://goauthentik.io/docs/installation/.")
CONFIG.log(
"info", "Secret key missing, check https://docs.goauthentik.io/docs/install-config/"
)
CONFIG.log("info", "----------------------------------------------------------------------")
sysexit(1)
check_postgres()
Expand Down
2 changes: 1 addition & 1 deletion manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import sys
import warnings

from authentik.lib.config import CONFIG
from cryptography.hazmat.backends.openssl.backend import backend
from defusedxml import defuse_stdlib
from django.utils.autoreload import DJANGO_AUTORELOAD_ENV

from authentik.lib.config import CONFIG
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
from authentik.lib.config import CONFIG

from lifecycle.migrate import run_migrations
from lifecycle.wait_for_db import wait_for_db

Expand Down
26 changes: 24 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,26 @@ version = "2024.12.2"
description = ""
authors = ["authentik Team <[email protected]>"]

[tool.bandit]
exclude_dirs = ["**/node_modules/**"]

[tool.codespell]
skip = [
"**/node_modules",
"**/package-lock.json",
"schema.yml",
"./blueprints/schema.json",
"go.sum",
"cmd",
"internal",
"web/src",
Comment on lines +17 to +19
Copy link
Member

@rissson rissson Jan 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"cmd",
"internal",
"web/src",

These are source code directories that we don't want to ignore

"locale",
"**/web/xliff/**",
"./website/build/**",
"*.api.mdx",
]
dictionary = ".github/codespell-dictionary.txt,-"
ignore-words = ".github/codespell-words.txt"
[tool.black]
line-length = 100
target-version = ['py312']
Expand All @@ -12,7 +32,7 @@ exclude = 'node_modules'
[tool.ruff]
line-length = 100
target-version = "py312"
exclude = ["**/migrations/**", "**/node_modules/**"]
exclude = ["web/tools/**", "**/migrations/**", "**/node_modules/**"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we excluding those scripts from being linted and formatted?


[tool.ruff.lint]
select = [
Expand Down Expand Up @@ -122,7 +142,9 @@ kubernetes = "*"
ldap3 = "*"
lxml = "*"
msgraph-sdk = "*"
opencontainers = { git = "https://github.com/vsoch/oci-python", rev = "20d69d9cc50a0fef31605b46f06da0c94f1ec3cf", extras = ["reggie"] }
opencontainers = { git = "https://github.com/vsoch/oci-python", rev = "20d69d9cc50a0fef31605b46f06da0c94f1ec3cf", extras = [
"reggie",
] }
packaging = "*"
paramiko = "*"
psycopg = { extras = ["c"], version = "*" }
Expand Down
2 changes: 2 additions & 0 deletions scripts/generate_config.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env python3

"""Generate config for development"""

from yaml import safe_dump
Expand Down
15 changes: 15 additions & 0 deletions scripts/generate_semver.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env python3
"""
Generates a Semantic Versioning identifier, suffixed with a timestamp.
"""

from time import time

from authentik import __version__ as package_version

"""
See: https://semver.org/#spec-item-9 (Pre-release spec)
"""
pre_release_timestamp = int(time())

print(f"{package_version}-{pre_release_timestamp}")
7 changes: 0 additions & 7 deletions scripts/npm_version.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ entryPoints:
web:
address: ":80"

# Re-use the same config file to define everything
# Reuse the same config file to define everything
providers:
file:
filename: /etc/traefik/traefik.yml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ export class ApplicationWizardSubmitStep extends CustomEmitterElement(Applicatio
if (!(this.wizard && app && provider)) {
throw new Error("Submit step received uninitialized wizard context");
}
// An empty object is truthy, an empty array is falsey. *WAT Javascript*.
// An empty object is truthy, an empty array is falsey. *WAT JavaScript*.
const keys = Object.keys(this.wizard.errors);
return match([this.state, keys])
.with(["submitted", P._], () =>
Expand Down
2 changes: 1 addition & 1 deletion website/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ yarn-debug.log*
yarn-error.log*

static/docker-compose.yml
static/schema.yaml
static/schema.yml
docs/developer-docs/api/reference/**
2 changes: 1 addition & 1 deletion website/docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ module.exports = async function (): Promise<Config> {
docsPluginId: "docs",
config: {
authentik: {
specPath: "static/schema.yaml",
specPath: "static/schema.yml",
outputDir: "docs/developer-docs/api/reference/",
hideSendButton: true,
sidebarOptions: {
Expand Down
2 changes: 1 addition & 1 deletion website/integrations/services/frappe/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ These instructions apply to all projects in the Frappe Family.

## What is Frappe

> Frappe is a full stack, batteries-included, web framework written in Python and Javascript.
> Frappe is a full stack, batteries-included, web framework written in Python and JavaScript.
>
> -- https://frappe.io/

Expand Down
Loading
Loading