Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Lx9FNLG2CqeBbVGGd9bFsP
20 lines
559 B
Go
20 lines
559 B
Go
package api
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/v10networks/nmon/internal/auth"
|
|
)
|
|
|
|
// anonymousActor names the caller when no auth middleware ran (unit tests that call the API directly).
|
|
const anonymousActor = "anonymous"
|
|
|
|
// actorOf names the authenticated caller for the audit log, acknowledgements and maintenance windows:
|
|
// the OIDC subject, "token:<name>" for an API token, "breakglass", or "dev" in development-open mode.
|
|
func actorOf(ctx context.Context) string {
|
|
if p, ok := auth.FromContext(ctx); ok {
|
|
return p.Actor()
|
|
}
|
|
return anonymousActor
|
|
}
|