Sobre
A Simple URL forwarder service
Sistemas e infraestruturaCrescimento medido de estrelas
- em 24 h
- 0
- em 7 dias
- 0
- em 15 dias
- 0
- em 1 mês
- Coletando histórico
Variações líquidas em períodos sobrepostos, não totais diários. Medições ausentes ficam em branco. Estrelas indicam interesse, não qualidade.
README.md
OriginalElf
The link forward service used by https://go.edi.wang. It generates static URLs for redirecting third party URLs. It's similar to, but NOT a URL shorter.
- Use a static token to adapt changes to origin url.
- Track user click to generate report.
e.g.:
https://www.somewebsite.com/a-very-long-and-complicated-link-that-can-also-change?with=parameters
will be translate to https://yourdomain/fw/token or https://yourdomain/aka/name

Development
Run the full test suite from the repository root:
dotnet test src/Elf.slnx
Forwarder Logic
flowchart TD
A[Request] --> B[Token]
B --> C{Request Rate Limit}
C -->|Allow| D{Parse}
C -->|Rejected| E[Too Many Requests 429]
D -->|Valid| F{Cache Lookup}
D -->|Invalid| G[Bad Request 400]
F -->|Found| H{Verify Origin URL}
F -->|Not Found| I[Search Link Repository]
I --> J{Link Exists}
J -->|Yes| K{Link Enabled}
J -->|No| L[Get Default Redirection URL]
K --> M[Add to Cache]
M --> H
L --> N{URL Present}
N -->|Yes| O{Verify Default URL}
N -->|No| P[Not Found 404]
H -->|Safe| Q[Track Redirection<br/>IP / User Agent]
H -->|Unsafe| G
Q --> R[Redirect to Origin URL]
O -->|Valid| S[Redirect to Default URL]
O -->|Invalid| T[Not Found 404]
%% Style the terminal nodes
E:::error
G:::error
P:::error
T:::error
R:::success
S:::success
classDef error fill:#ff6b35
classDef success fill:#4CAF50
Deployment
Local Deployment with Docker Compose (Recommended)
This starts PostgreSQL and one Elf application image. The same application serves public /fw/* and /aka/* redirects and the Admin UI under /admin.
Prerequisites:
- Docker with Docker Compose
- Local ports
5432and8080available
Create the local environment file and set a strong database password.
Copy-Item .env.example .env
Set ELF_POSTGRES_PASSWORD to a strong value containing only letters, digits, _, or -; Compose embeds it in the PostgreSQL connection string. Keep production passwords and OIDC client secrets in the deployment secret store.
The Compose file uses postgres:18-alpine and ediwang/elf:latest. It configures Elf to use PostgreSQL and local Admin sign-in. The application port is published on 127.0.0.1 so a reverse proxy on the same host can reach it.
Pull the Docker Hub images and start all services:
docker compose pull
docker compose up -d
docker compose ps
Elf initializes an empty database schema during startup. Open the application at:
- Health: http://localhost:8080/health
- Admin UI: http://localhost:8080/admin
- Public redirects: http://localhost:8080/fw/{token} and http://localhost:8080/aka/{akaName}
Open Admin while access is restricted to the operator. Set the administrator username and password in the browser, then verify the authenticator code. Elf opens Admin and enables public redirects when setup succeeds. Admin generates public forward links using the scheme, hostname, and port shown in the browser.
PostgreSQL data is stored in the named Docker volume elf-postgres-data. Stop the services while keeping the data with:
docker compose down
Pushes to master run the tests and build the Docker image without publishing it. When master is ready for release, merge it into release. A push to release runs the tests, builds the image, and publishes ediwang/elf:latest and ediwang/elf:<commit-sha>. Deployment is handled separately. To pin a published build, set ELF_IMAGE in .env to its commit tag or registry digest before docker compose pull.
To remove the database volume and start over, run the following only when you intentionally want to delete the local database:
docker compose down -v
Setup Authentication
The administrator setup and OIDC runbook covers Compose, standalone deployment, and verifying the public HTTPS callback.
Elf protects Admin with a single local administrator account. Sign-in uses a password and, by default, a TOTP authenticator. The public /fw/* and /aka/* routes are accessible without signing in.
Local Account
Restrict access to Admin through the internal network or reverse proxy until setup is complete. Anyone who can reach the setup page before completion can create the administrator.
Open /admin and follow the setup page. Choose a username and password. When Authentication:Totp:Enabled is true, scan the QR code and verify a current code to finish. Elf then signs you in automatically. During setup, health checks at / and /health continue to respond. Public redirects and Admin APIs return HTTP 503 until the administrator is configured.
An existing installation with the current schema also requires this setup once when moving to this version. Use the newly chosen credentials after setup. Finishing setup invalidates previous sessions and clears the OIDC identity binding. The provider settings and key ring stay in the database, so the administrator can bind the intended identity again from Account.
Reverse Proxy and Forwarded Headers
When TLS terminates at a reverse proxy, enable ForwardedHeaders:Enabled to process headers from trusted proxies. Configure each proxy hop with its address as seen by the application or container.
ForwardedHeaders__Enabled=true
ForwardedHeaders__KnownProxies__0=203.0.113.10
Keep the /admin path prefix when proxying. Bind the application port to loopback if Caddy or another host-local proxy fronts it. The proxy forwards requests to Elf, which enforces its own Admin sign-in.
TOTP Recovery
If you still have a valid Admin session, use the Account page to reset the authenticator. This signs out the current session and forces TOTP setup on the next password login.
If all administrator access is lost, restrict access to Admin, stop Elf, and back up the database. Removing the LocalAccount row from ElfConfiguration while Elf is stopped reopens browser setup on the next start. That removal also deletes the associated OIDC provider settings and binding. Configure the replacement account before reopening Admin to other users.
Authentication Storage
Keep DataProtectionKeys and OidcProvider with the database when backing up or restoring Elf. The key ring protects sign-in cookies, antiforgery tokens, and OIDC client secrets. Restrict access to the database and its backups and use encryption at rest for both. The same backup should include both the encrypted credentials and their keys. If the keys are lost, restore the matching key ring if available. With a replacement key ring, sign in with the local password and TOTP again, then save the provider's client secret again in Account.
Bind an OpenID Connect Provider
In Account → Manage third-party sign-in, copy the HTTPS callback URL and register it with the provider. For example, register https://elf.example.com/admin/signin-oidc. Use a public HTTPS provider that supports authorization code flow with PKCE.
Save the provider's display name, authority, client ID, and client secret. On Bind account, enter the local password and applicable authenticator code, then select Start binding. After authenticating at the provider, check the external identity and select Confirm binding.
Editing an already bound provider or rotating its client secret requires the local password and applicable authenticator code. To change the authority or client ID, first unbind the external account. Unbinding and deletion require an authenticator code when the local account has TOTP configured. Accounts without TOTP use the local password for these two actions. Unbinding retains the provider configuration. Deleting the provider requires explicit confirmation and removes both its settings and binding.
Deployment Topology
Run Elf as a single application instance. Elf uses ASP.NET Core's process-local IMemoryCache; do not deploy multiple instances or replicas behind a load balancer. Cache invalidation from link edits, enable/disable changes, and deletes only affects the instance handling the Admin request, so another instance could continue serving a cached link until its TTL expires. Multi-instance deployment is unsupported.
Only links with a positive TTL are cached. A TTL of 0 disables caching for that link.
Explore projetos relacionados
Carregando…