Skip to content

2.0.0#6

Merged
gpappsoft merged 12 commits into
gpappsoft:mainfrom
oermoshkin:main
Apr 14, 2026
Merged

2.0.0#6
gpappsoft merged 12 commits into
gpappsoft:mainfrom
oermoshkin:main

Conversation

@oermoshkin

Copy link
Copy Markdown
Contributor
  • RADIUS server refactor: UDP/listen/worker stay in server.go; PAP/OTP flow lives in handle.go; scope→attribute mapping in attributes.go; client config + ParseClientsConf in types.go (the old auth package removed).
  • Observability: JSON zap logging from main; per-request request_id from newPacket through RADIUS logs and into Keycloak via context + WithRequestID.
  • Keycloak client: Admin token caching; zap instead of raw stdout debug; JWT role parsing without a shared mutable struct (concurrency-safe); AuthenticateUser / HasOTP take context.Context first.
  • Reliability / perf: HTTP client timeout + cloned transport; challenge state TTL + periodic eviction; precompiled regex rules for scope_radius_map; misc PAP/username fix.
  • Repo hygiene: Dropped tracked keyrad binary; .gitignore extended (IDE, build/, etc.); v2.0.0 + author line in main; Makefile added; unit tests for keycloak + radiussrv.
  • Add docker-compose example

@gitguardian

gitguardian Bot commented Apr 12, 2026

Copy link
Copy Markdown

⚠️ GitGuardian has uncovered 1 secret following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

Since your pull request originates from a forked repository, GitGuardian is not able to associate the secrets uncovered with secret incidents on your GitGuardian dashboard.
Skipping this check run and merging your pull request will create secret incidents on your GitGuardian dashboard.

🔎 Detected hardcoded secret in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
- - Generic High Entropy Secret 530164c keycloak/keycloak_test.go View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secret safely. Learn here the best practices.
  3. Revoke and rotate this secret.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@gpappsoft

Copy link
Copy Markdown
Owner

Thx. Will review changes during this week

@gpappsoft gpappsoft self-assigned this Apr 13, 2026
@gpappsoft

gpappsoft commented Apr 14, 2026

Copy link
Copy Markdown
Owner

Key concerns before merging

  • Hardcoded secret in keycloak/keycloak_test.go — must be removed/rotated before merge
  • The default bind address change to 0.0.0.0 is a behaviour-breaking change for non-Docker deployments

@oermoshkin

oermoshkin commented Apr 14, 2026

Copy link
Copy Markdown
Contributor Author

Key concerns before merging

  • Hardcoded secret in keycloak/keycloak_test.go — must be removed/rotated before merge
  • The default bind address change to 0.0.0.0 is a behaviour-breaking change for non-Docker deployments

Hi!
Could you explain the issue with hardcoded secrets in unit tests? Is this normal behavior during testing. How else can we verify functionality?
If we're running the service on 127.0.0.1, does that mean the NAS should be located on the same server? If we're assuming the administrator has to figure out the initial configuration, then okay, we can create a separate config for Docker.

@gpappsoft

Copy link
Copy Markdown
Owner

True: To prevent the security scanner from detecting the next release, the method for 1) is to modify clients.conf to clients.conf.example and add clients.conf to.gitignore.

The 127.0.0.1 bind problem

Yes — listen_addr: "127.0.0.1:1812" means the UDP socket only accepts packets arriving on the loopback interface. Any NAS (router, VPN gateway, switch) sending RADIUS requests from a different host will have its packets dropped at the OS level before keyrad even sees them.

The current config has a mismatch:

File Setting Implication
keyrad.yaml:46 listen_addr: "127.0.0.1:1812" Only loopback traffic accepted
clients.conf:9-12 client 127.0.0.1 Only loopback client registered
main.go:108 fallback 0.0.0.0:1812 Binary default is actually correct

So the example config is more restrictive than the binary's own default. That's the root of the confusion.

Real deployment topology

A NAS (MikroTik, pfSense, Cisco, etc.) is rarely co-located with the RADIUS server. The typical layout is:

[NAS device] --UDP/1812--> [keyrad server] --HTTPS--> [Keycloak] 10.0.0.1 10.0.0.2:1812 keycloak.example.com
For this to work, keyrad must:

  1. Bind to a reachable interface (0.0.0.0 or a specific LAN IP)
  2. Have the NAS IP registered in clients.conf

Two-config approach

Your instinct is right — the cleanest solution is two example configs:

keyrad.yaml (unchanged — local dev, loopback only, safe default for first run)

keyrad.docker.yaml — for containerized production deployments:

listen_addr: "0.0.0.0:1812"
clients.conf.docker (or document in README):

client 172.16.0.0/12 {
    secret = changeme
    shortname = docker-net
}
 #Add your actual NAS IPs here:
 #client 10.0.0.1 {
 #    secret = strongsecrethere
 #    shortname = mikrotik-router
 #}

The Docker image can default to the 0.0.0.0 bind since the container is network-isolated anyway — the clients.conf secret + IP restriction is the real security boundary, not the bind address.

Summary

  • 127.0.0.1 bind is fine for local testing but unusable for any real NAS — they're always on separate hardware.
  • The binary's fallback of 0.0.0.0 (main.go:108) is actually the right production default; the example keyrad.yaml is the outlier.
  • A separate Docker config makes sense (keyrad.docker.yaml and clients.conf.docker).

@gpappsoft
gpappsoft merged commit f4f107c into gpappsoft:main Apr 14, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants