Well-known URLs declared by applications
Problem
External clients read some documents at fixed paths of a site, before they access anything else. Examples: /.well-known/security.txt (RFC 9116), /robots.txt (RFC 9309), /.well-known/apple-app-site-association (iOS universal links), /.well-known/assetlinks.json (Android app links), /.well-known/oauth-protected-resource/<resource> (RFC 9728).
In kajenn an application answers a /.well-known/ document only as a child of a reserved _well_known branch of its router, built in code before the server registers it. A mixin cannot bring its own documents into an application, a fixed path outside /.well-known/ such as /robots.txt has no mechanism, and two applications declaring the same name are resolved silently by registration order.
genropy legacy answers these documents with webtools that declare their public path on the class (alias_url). This proposal brings that model to kajenn applications.
Current state
kajenn today
src/kajenn/server.py:5612026-11-02.well-known followed by a name in well_known_applications: the request goes to that application with its path rewritten as /_well_known/<name>/<rest>.src/kajenn/routed_application.py:1872026-11-02RoutedApplication declares its documents as the children of a _well_known branch of its router. well_known_names returns those children.src/kajenn/server.py:2422026-11-02register_application sets app.server = self, then indexes app.well_known_names once. A name declared by two applications belongs to the last registered. A claimed code or mount raises ValueError.src/kajenn/kbus_mixin.py:2952026-11-02meta["well_known"], a list of strings, when its process joins the KajennBus.src/kajenn/server.py:5402026-11-02/robots.txt and /favicon.ico included, is demuxed like any other path: the root application if there is one, else 404.src/kajenn/site_home.py:832026-11-02SiteHome.static names a folder for the site's static files. No code serves it.src/kajenn/application.py:1662026-11-02BaseApplication.__init__ receives code and mount from the recipe and sets self.mount. The class does not know its mount.src/kajenn/application.py:452026-11-02grammar, inherited by MRO and mounted in the recipe under its application(app_class=...) element. Composition is explicit; a mixin cannot add words.genro_builders/builder/base.py:2302026-11-02genropy legacy
genropy:gnr/web/gnrwsgisite.py:4992026-11-02alias_url from every webtool and builds webtools_static_routes, a dict absolute path → webtool. _dispatcher looks the exact path up before every other rule.genropy:webtools/wku.py:712026-11-02DeepLinkIOS always associates the whole site ("/": "/*"); the configuration only excludes paths. It also emits webcredentials with the same app ids.genropy:webtools/wku.py:942026-11-02DeepLinkAndroid emits package name, certificate fingerprints and the relations handle_all_urls and get_login_creds. It has no paths.Proposed solution
Behaviour
- An application class or a mixin declares the well-known URLs it answers in a class dict
well_known: public path → route path inside the application. - What is well-known is fixed by the standards, not configured:
/.well-known/...(RFC 8615),/robots.txt(RFC 9309),/favicon.ico(the HTML default icon). RFC 8615 cites/robots.txtand/favicon.icoas the site-wide metadata that predates the prefix. - A request whose path is well-known goes to the declared route of the declaring application. A well-known path nobody declared answers 404 with the message "unimplemented well-known URL": for
robots.txta 4xx means "no restrictions" (RFC 9309), for the other documents "not supported". - Two applications declaring the same path stop the server at construction. Inside one application the more derived class wins. A path can also be given as a default (
default_well_known): it answers only when no application declares the path, and two applications giving the same default stop the server. - A path that depends on the mount (OAuth protected resources) is declared once on the class with the marker
{mount}. - The site author is responsible for what a well-known route answers: kajenn does not check that it is public.
Declaring well-known URLs
class MobileMixin:
well_known = {
"/.well-known/apple-app-site-association": "mobile/apple_app_site_association",
"/.well-known/assetlinks.json": "mobile/assetlinks",
}
class OauthApi(RoutedApplication):
well_known = {"/.well-known/oauth-protected-resource/{mount}": "oauth/resource"}
class Shop(MobileMixin, OauthApi):
well_known = {"/robots.txt": "seo/robots"}- Keys are public paths with the leading
/. Values are route paths inside the application, without it. BaseApplication.__init__merges the dicts along the MRO (the more derived class wins on the same key), replaces{mount}withself.mountand stores the result inself.well_known. For the root mount ("") the segment/{mount}is removed whole: RFC 9728 has no trailing slash for a root resource.- A key that is not a well-known path is a construction error.
- An application mounted twice gets one key per mount for
{mount}keys; a key without the marker declared by both instances is a conflict, which is correct: a site has one of each.
Server
- The well-known paths are one kajenn constant:
^/(\.well-known/.+|robots\.txt|favicon\.ico)$. It is not configurable.sitemap.xmlis not in it: the sitemap protocol does not fix its location. register_applicationreadsapp.well_known, checks that each route exists and builds one index public path → (application, route). A path already held by another application raisesValueError, like a claimed code or mount.- The demux matches the constant first. A declared path is forwarded to its application as the route path; an undeclared one answers 404 "unimplemented well-known URL". Other first segments starting with a dot stay 404.
- The
_well_knownbranch,WELL_KNOWN_ROOT,well_known_namesand the rewrite indemux_hiddenare removed. - An external application sends its
well_knowndict when it joins. A path held by another application refuses the join withkbus.Refused; its own re-join replaces its paths.
Documents of the _server application
/.well-known/security.txtand/robots.txtare generated from words ofServerApplicationGrammar.robots.txtrules are validated at boot./favicon.icois served as a file fromhome:/static._servergives each path as a default, only when its words are configured or its file exists. An application declaring the same path answers it instead, for example a favicon per host.
Mobile mixin
- A mixin inside kajenn gives an application its mobile capability: its own grammar words, a routing class under
mobileand the two keys of itswell_known. - The recipe holds only real parameters:
ios(team_id, bundle_id, paths, excluded_paths)andandroid(package_name, fingerprints, paths, excluded_paths). The routes build the fixed JSON. - iOS:
pathsis required, at least one, in Applecomponentssyntax (*,?), copied as is; exclusions are written first. No/*default. - Android:
pathsandexcluded_pathsare optional, same syntax, written asrelation_extensions→dynamic_app_link_components(Dynamic App Links, Android 15 and later; older devices use the app manifest). webcredentials(iOS) andget_login_creds(Android) are always emitted from the same identifiers. The app activates them on its side.- A platform without configuration registers no key. A mixin with no platform configured logs a warning at boot.
Grammar composition
BaseApplication.__init_subclass__ composes cls.grammar from the grammars declared along the MRO, so a mixin brings its words into every application that uses it. Only new elements are composed: an element with the same name replaces the earlier one, as genro-builders does today.
Decisions
Consequences
- The
_well_knownbranch,WELL_KNOWN_ROOTandwell_known_namesare removed: a breaking change, released as a minor version. - The proposal channels-meta-and-server-gui no longer needs a
_meta/well_knownbranch. - A site whose root application answers
/favicon.icotoday must declare it in that application'swell_known. - The guide
docs/guides/hidden-paths.mdis rewritten with one table: for each case, who answers, when construction stops, when the answer is 404 "unimplemented well-known URL". The{mount}marker and the MRO merge are documented with examples. - Tests on the kajenn router cannot prove what an external client sees. A deployment check requests each declared document on the public HTTPS address, through the proxy, and fails on any status other than 200, on a redirect or on a body that does not parse.