mirror of
https://github.com/TecharoHQ/anubis.git
synced 2026-04-12 03:28:45 +00:00
Compare commits
2 Commits
Xe/double-
...
Xe/nginx-m
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
022f9ab9cd | ||
|
|
6104af3ddb |
1
.github/actions/spelling/expect.txt
vendored
1
.github/actions/spelling/expect.txt
vendored
@@ -344,7 +344,6 @@ yeet
|
|||||||
yeetfile
|
yeetfile
|
||||||
yourdomain
|
yourdomain
|
||||||
yoursite
|
yoursite
|
||||||
yyz
|
|
||||||
Zenos
|
Zenos
|
||||||
zizmor
|
zizmor
|
||||||
zombocom
|
zombocom
|
||||||
|
|||||||
@@ -19,3 +19,5 @@ npm-debug.log*
|
|||||||
yarn-debug.log*
|
yarn-debug.log*
|
||||||
yarn-error.log*
|
yarn-error.log*
|
||||||
|
|
||||||
|
# Kubernetes manifests
|
||||||
|
/manifest
|
||||||
@@ -7,5 +7,4 @@ RUN npm ci && npm run build
|
|||||||
|
|
||||||
FROM ghcr.io/xe/nginx-micro
|
FROM ghcr.io/xe/nginx-micro
|
||||||
COPY --from=build /app/build /www
|
COPY --from=build /app/build /www
|
||||||
COPY ./manifest/cfg/nginx/nginx.conf /conf
|
|
||||||
LABEL org.opencontainers.image.source="https://github.com/TecharoHQ/anubis"
|
LABEL org.opencontainers.image.source="https://github.com/TecharoHQ/anubis"
|
||||||
@@ -13,6 +13,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
<!-- This changes the project to: -->
|
<!-- This changes the project to: -->
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
Anubis now supports these new languages:
|
||||||
|
|
||||||
|
- [Italian](https://github.com/TecharoHQ/anubis/pull/778)
|
||||||
|
|
||||||
## v1.21.0: Minfilia Warde
|
## v1.21.0: Minfilia Warde
|
||||||
|
|
||||||
> Please, be at ease. You are among friends here.
|
> Please, be at ease. You are among friends here.
|
||||||
@@ -34,16 +40,11 @@ Anubis now is able to store things persistently [in memory](./admin/policies.mdx
|
|||||||
Anubis now supports localized responses. Locales can be added in [lib/localization/locales/](https://github.com/TecharoHQ/anubis/tree/main/lib/localization/locales). This release includes support for the following languages:
|
Anubis now supports localized responses. Locales can be added in [lib/localization/locales/](https://github.com/TecharoHQ/anubis/tree/main/lib/localization/locales). This release includes support for the following languages:
|
||||||
|
|
||||||
- [Brazilian Portugese](https://github.com/TecharoHQ/anubis/pull/726)
|
- [Brazilian Portugese](https://github.com/TecharoHQ/anubis/pull/726)
|
||||||
- [Chinese (Simplified)](https://github.com/TecharoHQ/anubis/pull/774)
|
|
||||||
- [Chinese (Traditional)](https://github.com/TecharoHQ/anubis/pull/759)
|
- [Chinese (Traditional)](https://github.com/TecharoHQ/anubis/pull/759)
|
||||||
- English
|
- English
|
||||||
- [Estonian](https://github.com/TecharoHQ/anubis/pull/783)
|
- [Estonian](https://github.com/TecharoHQ/anubis/pull/783)
|
||||||
- [Filipino](https://github.com/TecharoHQ/anubis/pull/775)
|
|
||||||
- [French](https://github.com/TecharoHQ/anubis/pull/716)
|
- [French](https://github.com/TecharoHQ/anubis/pull/716)
|
||||||
- [German](https://github.com/TecharoHQ/anubis/pull/741)
|
- [German](https://github.com/TecharoHQ/anubis/pull/741)
|
||||||
- [Icelandic](https://github.com/TecharoHQ/anubis/pull/780)
|
|
||||||
- [Italian](https://github.com/TecharoHQ/anubis/pull/778)
|
|
||||||
- [Japanese](https://github.com/TecharoHQ/anubis/pull/772)
|
|
||||||
- [Spanish](https://github.com/TecharoHQ/anubis/pull/716)
|
- [Spanish](https://github.com/TecharoHQ/anubis/pull/716)
|
||||||
- [Turkish](https://github.com/TecharoHQ/anubis/pull/751)
|
- [Turkish](https://github.com/TecharoHQ/anubis/pull/751)
|
||||||
|
|
||||||
@@ -102,18 +103,6 @@ There are a bunch of other assorted features and fixes too:
|
|||||||
|
|
||||||
### Potentially breaking changes
|
### Potentially breaking changes
|
||||||
|
|
||||||
We try to introduce breaking changes as much as possible, but these are the changes that may be relevant for you as an administrator:
|
|
||||||
|
|
||||||
#### Challenge format change
|
|
||||||
|
|
||||||
Previously Anubis did no accounting for challenges that it issued. This means that if Anubis restarted during a client, the client would be able to proceed once Anubis came back online.
|
|
||||||
|
|
||||||
During the upgrade to v1.21.0 and when v1.21.0 (or later) restarts with the [in-memory storage backend](./admin/policies.mdx#memory), you may see a higher rate of failed challenges than normal. If this persists beyond a few minutes, [open an issue](https://github.com/TecharoHQ/anubis/issues/new).
|
|
||||||
|
|
||||||
If you are using the in-memory storage backend, please consider using [a different storage backend](./admin/policies.mdx#storage-backends).
|
|
||||||
|
|
||||||
#### Systemd service changes
|
|
||||||
|
|
||||||
The following potentially breaking change applies to native installs with systemd only:
|
The following potentially breaking change applies to native installs with systemd only:
|
||||||
|
|
||||||
Each instance of systemd service template now has a unique `RuntimeDirectory`, as opposed to each instance of the service sharing a `RuntimeDirectory`. This change was made to avoid [the `RuntimeDirectory` getting nuked any time one of the Anubis instances restarts](https://github.com/TecharoHQ/anubis/issues/748).
|
Each instance of systemd service template now has a unique `RuntimeDirectory`, as opposed to each instance of the service sharing a `RuntimeDirectory`. This change was made to avoid [the `RuntimeDirectory` getting nuked any time one of the Anubis instances restarts](https://github.com/TecharoHQ/anubis/issues/748).
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ Test to make sure it's running with `curl`:
|
|||||||
curl http://localhost:8240/metrics
|
curl http://localhost:8240/metrics
|
||||||
```
|
```
|
||||||
|
|
||||||
Then set up your reverse proxy (Nginx, Caddy, etc.) to point to the Anubis port. Anubis will then reverse proxy all requests that meet the policies in `/etc/anubis/gitea.botPolicies.yaml` to the target service.
|
Then set up your reverse proxy (Nginx, Caddy, etc.) to point to the Anubis port. Anubis will then reverse proxy all requests that meet the policies in `/etc/anubis/gitea.botPolicies.json` to the target service.
|
||||||
|
|
||||||
For more details on particular reverse proxies, see here:
|
For more details on particular reverse proxies, see here:
|
||||||
|
|
||||||
|
|||||||
@@ -268,12 +268,6 @@ The memory backend is an in-memory cache. This backend works best if you don't u
|
|||||||
|
|
||||||
The biggest downside is that there is not currently a limit to how much data can be stored in memory. This will be addressed at a later time.
|
The biggest downside is that there is not currently a limit to how much data can be stored in memory. This will be addressed at a later time.
|
||||||
|
|
||||||
:::warning
|
|
||||||
|
|
||||||
The in-memory backend exists mostly for validation, testing, and to ensure that the default configuration of Anubis works as expected. Do not use this persistently in production.
|
|
||||||
|
|
||||||
:::
|
|
||||||
|
|
||||||
#### Configuration
|
#### Configuration
|
||||||
|
|
||||||
The memory backend does not require any configuration to use.
|
The memory backend does not require any configuration to use.
|
||||||
|
|||||||
@@ -53,10 +53,6 @@ This page contains a non-exhaustive list with all websites using Anubis.
|
|||||||
- https://marginalia-search.com/
|
- https://marginalia-search.com/
|
||||||
- https://repositorio.ufrn.br/home/
|
- https://repositorio.ufrn.br/home/
|
||||||
- https://mozillazine.org/
|
- https://mozillazine.org/
|
||||||
- https://clew.se/
|
|
||||||
- https://tumfatig.net/
|
|
||||||
- https://rpmfusion.org/
|
|
||||||
- https://wiki.freepascal.org/
|
|
||||||
- <details>
|
- <details>
|
||||||
<summary>FreeCAD</summary>
|
<summary>FreeCAD</summary>
|
||||||
- https://forum.freecad.org/
|
- https://forum.freecad.org/
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
app = 'anubis-docs'
|
|
||||||
primary_region = 'yyz'
|
|
||||||
|
|
||||||
[build]
|
|
||||||
image = "ghcr.io/techarohq/anubis/docs:main"
|
|
||||||
|
|
||||||
[http_service]
|
|
||||||
internal_port = 80
|
|
||||||
force_https = true
|
|
||||||
auto_stop_machines = true
|
|
||||||
auto_start_machines = true
|
|
||||||
min_machines_running = 0
|
|
||||||
processes = ['app']
|
|
||||||
|
|
||||||
[[vm]]
|
|
||||||
cpu_kind = 'shared'
|
|
||||||
cpus = 1
|
|
||||||
memory_mb = 256
|
|
||||||
|
|
||||||
@@ -1,99 +0,0 @@
|
|||||||
|
|
||||||
types {
|
|
||||||
text/html html htm shtml;
|
|
||||||
text/css css;
|
|
||||||
text/xml xml;
|
|
||||||
image/gif gif;
|
|
||||||
image/jpeg jpeg jpg;
|
|
||||||
application/javascript js;
|
|
||||||
application/atom+xml atom;
|
|
||||||
application/rss+xml rss;
|
|
||||||
|
|
||||||
text/mathml mml;
|
|
||||||
text/plain txt;
|
|
||||||
text/vnd.sun.j2me.app-descriptor jad;
|
|
||||||
text/vnd.wap.wml wml;
|
|
||||||
text/x-component htc;
|
|
||||||
|
|
||||||
image/avif avif;
|
|
||||||
image/png png;
|
|
||||||
image/svg+xml svg svgz;
|
|
||||||
image/tiff tif tiff;
|
|
||||||
image/vnd.wap.wbmp wbmp;
|
|
||||||
image/webp webp;
|
|
||||||
image/x-icon ico;
|
|
||||||
image/x-jng jng;
|
|
||||||
image/x-ms-bmp bmp;
|
|
||||||
|
|
||||||
font/woff woff;
|
|
||||||
font/woff2 woff2;
|
|
||||||
|
|
||||||
application/java-archive jar war ear;
|
|
||||||
application/json json;
|
|
||||||
application/mac-binhex40 hqx;
|
|
||||||
application/msword doc;
|
|
||||||
application/pdf pdf;
|
|
||||||
application/postscript ps eps ai;
|
|
||||||
application/rtf rtf;
|
|
||||||
application/vnd.apple.mpegurl m3u8;
|
|
||||||
application/vnd.google-earth.kml+xml kml;
|
|
||||||
application/vnd.google-earth.kmz kmz;
|
|
||||||
application/vnd.ms-excel xls;
|
|
||||||
application/vnd.ms-fontobject eot;
|
|
||||||
application/vnd.ms-powerpoint ppt;
|
|
||||||
application/vnd.oasis.opendocument.graphics odg;
|
|
||||||
application/vnd.oasis.opendocument.presentation odp;
|
|
||||||
application/vnd.oasis.opendocument.spreadsheet ods;
|
|
||||||
application/vnd.oasis.opendocument.text odt;
|
|
||||||
application/vnd.openxmlformats-officedocument.presentationml.presentation
|
|
||||||
pptx;
|
|
||||||
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
|
|
||||||
xlsx;
|
|
||||||
application/vnd.openxmlformats-officedocument.wordprocessingml.document
|
|
||||||
docx;
|
|
||||||
application/vnd.wap.wmlc wmlc;
|
|
||||||
application/wasm wasm;
|
|
||||||
application/x-7z-compressed 7z;
|
|
||||||
application/x-cocoa cco;
|
|
||||||
application/x-java-archive-diff jardiff;
|
|
||||||
application/x-java-jnlp-file jnlp;
|
|
||||||
application/x-makeself run;
|
|
||||||
application/x-perl pl pm;
|
|
||||||
application/x-pilot prc pdb;
|
|
||||||
application/x-rar-compressed rar;
|
|
||||||
application/x-redhat-package-manager rpm;
|
|
||||||
application/x-sea sea;
|
|
||||||
application/x-shockwave-flash swf;
|
|
||||||
application/x-stuffit sit;
|
|
||||||
application/x-tcl tcl tk;
|
|
||||||
application/x-x509-ca-cert der pem crt;
|
|
||||||
application/x-xpinstall xpi;
|
|
||||||
application/xhtml+xml xhtml;
|
|
||||||
application/xspf+xml xspf;
|
|
||||||
application/zip zip;
|
|
||||||
|
|
||||||
application/octet-stream bin exe dll;
|
|
||||||
application/octet-stream deb;
|
|
||||||
application/octet-stream dmg;
|
|
||||||
application/octet-stream iso img;
|
|
||||||
application/octet-stream msi msp msm;
|
|
||||||
|
|
||||||
audio/midi mid midi kar;
|
|
||||||
audio/mpeg mp3;
|
|
||||||
audio/ogg ogg;
|
|
||||||
audio/x-m4a m4a;
|
|
||||||
audio/x-realaudio ra;
|
|
||||||
|
|
||||||
video/3gpp 3gpp 3gp;
|
|
||||||
video/mp2t ts;
|
|
||||||
video/mp4 mp4;
|
|
||||||
video/mpeg mpeg mpg;
|
|
||||||
video/quicktime mov;
|
|
||||||
video/webm webm;
|
|
||||||
video/x-flv flv;
|
|
||||||
video/x-m4v m4v;
|
|
||||||
video/x-mng mng;
|
|
||||||
video/x-ms-asf asx asf;
|
|
||||||
video/x-ms-wmv wmv;
|
|
||||||
video/x-msvideo avi;
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
user nginx;
|
|
||||||
worker_processes 2;
|
|
||||||
error_log /dev/stdout warn;
|
|
||||||
pid /nginx.pid;
|
|
||||||
|
|
||||||
events {
|
|
||||||
worker_connections 1024;
|
|
||||||
}
|
|
||||||
|
|
||||||
http {
|
|
||||||
include mime.types;
|
|
||||||
default_type application/octet-stream;
|
|
||||||
access_log /dev/stdout;
|
|
||||||
|
|
||||||
sendfile on;
|
|
||||||
keepalive_timeout 65;
|
|
||||||
|
|
||||||
server {
|
|
||||||
listen 80 default_server;
|
|
||||||
server_name _;
|
|
||||||
|
|
||||||
error_page 404 /404.html;
|
|
||||||
|
|
||||||
root /www;
|
|
||||||
index index.html;
|
|
||||||
|
|
||||||
location / {
|
|
||||||
try_files $uri $uri/ =404;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -15,9 +15,6 @@ spec:
|
|||||||
- name: anubis
|
- name: anubis
|
||||||
configMap:
|
configMap:
|
||||||
name: anubis-cfg
|
name: anubis-cfg
|
||||||
- name: nginx
|
|
||||||
configMap:
|
|
||||||
name: nginx-cfg
|
|
||||||
- name: temporary-data
|
- name: temporary-data
|
||||||
emptyDir: {}
|
emptyDir: {}
|
||||||
containers:
|
containers:
|
||||||
@@ -31,9 +28,6 @@ spec:
|
|||||||
requests:
|
requests:
|
||||||
cpu: 250m
|
cpu: 250m
|
||||||
memory: 128Mi
|
memory: 128Mi
|
||||||
volumeMounts:
|
|
||||||
- name: nginx
|
|
||||||
mountPath: /conf
|
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 80
|
- containerPort: 80
|
||||||
- name: anubis
|
- name: anubis
|
||||||
|
|||||||
@@ -11,8 +11,3 @@ configMapGenerator:
|
|||||||
behavior: create
|
behavior: create
|
||||||
files:
|
files:
|
||||||
- ./cfg/anubis/botPolicies.yaml
|
- ./cfg/anubis/botPolicies.yaml
|
||||||
- name: nginx-cfg
|
|
||||||
behavior: create
|
|
||||||
files:
|
|
||||||
- ./cfg/nginx/mime.types
|
|
||||||
- ./cfg/nginx/nginx.conf
|
|
||||||
|
|||||||
1
go.mod
1
go.mod
@@ -97,7 +97,6 @@ require (
|
|||||||
github.com/goreleaser/chglog v0.7.0 // indirect
|
github.com/goreleaser/chglog v0.7.0 // indirect
|
||||||
github.com/goreleaser/fileglob v1.3.0 // indirect
|
github.com/goreleaser/fileglob v1.3.0 // indirect
|
||||||
github.com/goreleaser/nfpm/v2 v2.42.1 // indirect
|
github.com/goreleaser/nfpm/v2 v2.42.1 // indirect
|
||||||
github.com/gorilla/mux v1.8.1 // indirect
|
|
||||||
github.com/hashicorp/go-version v1.7.0 // indirect
|
github.com/hashicorp/go-version v1.7.0 // indirect
|
||||||
github.com/huandu/xstrings v1.5.0 // indirect
|
github.com/huandu/xstrings v1.5.0 // indirect
|
||||||
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
|
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
|
||||||
|
|||||||
2
go.sum
2
go.sum
@@ -212,8 +212,6 @@ github.com/goreleaser/fileglob v1.3.0 h1:/X6J7U8lbDpQtBvGcwwPS6OpzkNVlVEsFUVRx9+
|
|||||||
github.com/goreleaser/fileglob v1.3.0/go.mod h1:Jx6BoXv3mbYkEzwm9THo7xbr5egkAraxkGorbJb4RxU=
|
github.com/goreleaser/fileglob v1.3.0/go.mod h1:Jx6BoXv3mbYkEzwm9THo7xbr5egkAraxkGorbJb4RxU=
|
||||||
github.com/goreleaser/nfpm/v2 v2.42.1 h1:xu2pLRgQuz2ab+YZFoeIzwU/M5jjjCKDGwv1lRbVGvk=
|
github.com/goreleaser/nfpm/v2 v2.42.1 h1:xu2pLRgQuz2ab+YZFoeIzwU/M5jjjCKDGwv1lRbVGvk=
|
||||||
github.com/goreleaser/nfpm/v2 v2.42.1/go.mod h1:dY53KWYKebkOocxgkmpM7SRX0Nv5hU+jEu2kIaM4/LI=
|
github.com/goreleaser/nfpm/v2 v2.42.1/go.mod h1:dY53KWYKebkOocxgkmpM7SRX0Nv5hU+jEu2kIaM4/LI=
|
||||||
github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
|
|
||||||
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
|
|
||||||
github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus v1.1.0 h1:QGLs/O40yoNK9vmy4rhUGBVyMf1lISBGtXRpsu/Qu/o=
|
github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus v1.1.0 h1:QGLs/O40yoNK9vmy4rhUGBVyMf1lISBGtXRpsu/Qu/o=
|
||||||
github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus v1.1.0/go.mod h1:hM2alZsMUni80N33RBe6J0e423LB+odMj7d3EMP9l20=
|
github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus v1.1.0/go.mod h1:hM2alZsMUni80N33RBe6J0e423LB+odMj7d3EMP9l20=
|
||||||
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.3.2 h1:sGm2vDRFUrQJO/Veii4h4zG2vvqG6uWNkBHSTqXOZk0=
|
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.3.2 h1:sGm2vDRFUrQJO/Veii4h4zG2vvqG6uWNkBHSTqXOZk0=
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ import (
|
|||||||
"github.com/golang-jwt/jwt/v5"
|
"github.com/golang-jwt/jwt/v5"
|
||||||
"github.com/google/cel-go/common/types"
|
"github.com/google/cel-go/common/types"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/gorilla/mux"
|
|
||||||
|
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||||
@@ -69,7 +68,7 @@ var (
|
|||||||
|
|
||||||
type Server struct {
|
type Server struct {
|
||||||
next http.Handler
|
next http.Handler
|
||||||
mux *mux.Router
|
mux *http.ServeMux
|
||||||
policy *policy.ParsedConfig
|
policy *policy.ParsedConfig
|
||||||
OGTags *ogtags.OGTagCache
|
OGTags *ogtags.OGTagCache
|
||||||
ed25519Priv ed25519.PrivateKey
|
ed25519Priv ed25519.PrivateKey
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import (
|
|||||||
"github.com/TecharoHQ/anubis/lib/policy/config"
|
"github.com/TecharoHQ/anubis/lib/policy/config"
|
||||||
"github.com/TecharoHQ/anubis/lib/store"
|
"github.com/TecharoHQ/anubis/lib/store"
|
||||||
"github.com/a-h/templ"
|
"github.com/a-h/templ"
|
||||||
"github.com/gorilla/mux"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -59,7 +58,7 @@ type ValidateInput struct {
|
|||||||
|
|
||||||
type Impl interface {
|
type Impl interface {
|
||||||
// Setup registers any additional routes with the Impl for assets or API routes.
|
// Setup registers any additional routes with the Impl for assets or API routes.
|
||||||
Setup(r *mux.Router)
|
Setup(mux *http.ServeMux)
|
||||||
|
|
||||||
// Issue a new challenge to the user, called by the Anubis.
|
// Issue a new challenge to the user, called by the Anubis.
|
||||||
Issue(r *http.Request, lg *slog.Logger, in *IssueInput) (templ.Component, error)
|
Issue(r *http.Request, lg *slog.Logger, in *IssueInput) (templ.Component, error)
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import (
|
|||||||
"github.com/TecharoHQ/anubis/lib/localization"
|
"github.com/TecharoHQ/anubis/lib/localization"
|
||||||
"github.com/TecharoHQ/anubis/web"
|
"github.com/TecharoHQ/anubis/web"
|
||||||
"github.com/a-h/templ"
|
"github.com/a-h/templ"
|
||||||
"github.com/gorilla/mux"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:generate go tool github.com/a-h/templ/cmd/templ generate
|
//go:generate go tool github.com/a-h/templ/cmd/templ generate
|
||||||
@@ -22,7 +21,7 @@ func init() {
|
|||||||
|
|
||||||
type Impl struct{}
|
type Impl struct{}
|
||||||
|
|
||||||
func (i *Impl) Setup(r *mux.Router) {}
|
func (i *Impl) Setup(mux *http.ServeMux) {}
|
||||||
|
|
||||||
func (i *Impl) Issue(r *http.Request, lg *slog.Logger, in *challenge.IssueInput) (templ.Component, error) {
|
func (i *Impl) Issue(r *http.Request, lg *slog.Logger, in *challenge.IssueInput) (templ.Component, error) {
|
||||||
u, err := r.URL.Parse(anubis.BasePrefix + "/.within.website/x/cmd/anubis/api/pass-challenge")
|
u, err := r.URL.Parse(anubis.BasePrefix + "/.within.website/x/cmd/anubis/api/pass-challenge")
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import (
|
|||||||
"github.com/TecharoHQ/anubis/lib/localization"
|
"github.com/TecharoHQ/anubis/lib/localization"
|
||||||
"github.com/TecharoHQ/anubis/web"
|
"github.com/TecharoHQ/anubis/web"
|
||||||
"github.com/a-h/templ"
|
"github.com/a-h/templ"
|
||||||
"github.com/gorilla/mux"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@@ -25,7 +24,7 @@ type Impl struct {
|
|||||||
Algorithm string
|
Algorithm string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *Impl) Setup(r *mux.Router) {
|
func (i *Impl) Setup(mux *http.ServeMux) {
|
||||||
/* no implementation required */
|
/* no implementation required */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import (
|
|||||||
"github.com/TecharoHQ/anubis/lib/challenge"
|
"github.com/TecharoHQ/anubis/lib/challenge"
|
||||||
"github.com/TecharoHQ/anubis/lib/policy"
|
"github.com/TecharoHQ/anubis/lib/policy"
|
||||||
"github.com/TecharoHQ/anubis/lib/policy/config"
|
"github.com/TecharoHQ/anubis/lib/policy/config"
|
||||||
"github.com/gorilla/mux"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func mkRequest(t *testing.T, values map[string]string) *http.Request {
|
func mkRequest(t *testing.T, values map[string]string) *http.Request {
|
||||||
@@ -125,7 +124,7 @@ func TestBasic(t *testing.T) {
|
|||||||
t.Run(cs.name, func(t *testing.T) {
|
t.Run(cs.name, func(t *testing.T) {
|
||||||
lg := slog.With()
|
lg := slog.With()
|
||||||
|
|
||||||
i.Setup(mux.NewRouter())
|
i.Setup(http.NewServeMux())
|
||||||
|
|
||||||
inp := &challenge.IssueInput{
|
inp := &challenge.IssueInput{
|
||||||
Rule: bot,
|
Rule: bot,
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import (
|
|||||||
"github.com/TecharoHQ/anubis/web"
|
"github.com/TecharoHQ/anubis/web"
|
||||||
"github.com/TecharoHQ/anubis/xess"
|
"github.com/TecharoHQ/anubis/xess"
|
||||||
"github.com/a-h/templ"
|
"github.com/a-h/templ"
|
||||||
"github.com/gorilla/mux"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Options struct {
|
type Options struct {
|
||||||
@@ -111,33 +110,25 @@ func New(opts Options) (*Server, error) {
|
|||||||
store: opts.Policy.Store,
|
store: opts.Policy.Store,
|
||||||
}
|
}
|
||||||
|
|
||||||
r := mux.NewRouter()
|
mux := http.NewServeMux()
|
||||||
xess.Mount(r)
|
xess.Mount(mux)
|
||||||
|
|
||||||
// Helper to add global prefix
|
// Helper to add global prefix
|
||||||
registerWithPrefix := func(pattern string, handler http.Handler, method string) {
|
registerWithPrefix := func(pattern string, handler http.Handler, method string) {
|
||||||
|
if method != "" {
|
||||||
|
method = method + " " // methods must end with a space to register with them
|
||||||
|
}
|
||||||
|
|
||||||
// Ensure there's no double slash when concatenating BasePrefix and pattern
|
// Ensure there's no double slash when concatenating BasePrefix and pattern
|
||||||
basePrefix := strings.TrimSuffix(anubis.BasePrefix, "/")
|
basePrefix := strings.TrimSuffix(anubis.BasePrefix, "/")
|
||||||
|
prefix := method + basePrefix
|
||||||
|
|
||||||
// If pattern doesn't start with a slash, add one
|
// If pattern doesn't start with a slash, add one
|
||||||
if !strings.HasPrefix(pattern, "/") {
|
if !strings.HasPrefix(pattern, "/") {
|
||||||
pattern = "/" + pattern
|
pattern = "/" + pattern
|
||||||
}
|
}
|
||||||
|
|
||||||
var route *mux.Route
|
mux.Handle(prefix+pattern, handler)
|
||||||
|
|
||||||
switch strings.HasSuffix(pattern, "/") {
|
|
||||||
case true:
|
|
||||||
route = r.PathPrefix(basePrefix + pattern)
|
|
||||||
case false:
|
|
||||||
route = r.Path(basePrefix + pattern)
|
|
||||||
}
|
|
||||||
|
|
||||||
if method != "" {
|
|
||||||
route = route.Methods(method)
|
|
||||||
}
|
|
||||||
|
|
||||||
route.Handler(handler)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure there's no double slash when concatenating BasePrefix and StaticPath
|
// Ensure there's no double slash when concatenating BasePrefix and StaticPath
|
||||||
@@ -173,10 +164,10 @@ func New(opts Options) (*Server, error) {
|
|||||||
|
|
||||||
for _, implKind := range challenge.Methods() {
|
for _, implKind := range challenge.Methods() {
|
||||||
impl, _ := challenge.Get(implKind)
|
impl, _ := challenge.Get(implKind)
|
||||||
impl.Setup(r)
|
impl.Setup(mux)
|
||||||
}
|
}
|
||||||
|
|
||||||
result.mux = r
|
result.mux = mux
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import (
|
|||||||
|
|
||||||
"github.com/TecharoHQ/anubis"
|
"github.com/TecharoHQ/anubis"
|
||||||
"github.com/TecharoHQ/anubis/internal"
|
"github.com/TecharoHQ/anubis/internal"
|
||||||
"github.com/gorilla/mux"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -21,6 +20,8 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
Mount(http.DefaultServeMux)
|
||||||
|
|
||||||
//goland:noinspection GoBoolExpressions
|
//goland:noinspection GoBoolExpressions
|
||||||
if anubis.Version != "devel" {
|
if anubis.Version != "devel" {
|
||||||
URL = filepath.Join(filepath.Dir(URL), "xess.min.css")
|
URL = filepath.Join(filepath.Dir(URL), "xess.min.css")
|
||||||
@@ -30,10 +31,8 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Mount registers the xess static file handlers on the given mux
|
// Mount registers the xess static file handlers on the given mux
|
||||||
func Mount(r *mux.Router) {
|
func Mount(mux *http.ServeMux) {
|
||||||
prefix := anubis.BasePrefix + "/.within.website/x/xess/"
|
prefix := anubis.BasePrefix + "/.within.website/x/xess/"
|
||||||
|
|
||||||
r.PathPrefix(prefix).
|
mux.Handle(prefix, internal.UnchangingCache(http.StripPrefix(prefix, http.FileServerFS(Static))))
|
||||||
Handler(internal.UnchangingCache(http.StripPrefix(prefix, http.FileServerFS(Static)))).
|
|
||||||
Name("xess")
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user