Skip to content

Commit d4467dc

Browse files
committed
Updated man page with auth changes.
1 parent 2d66925 commit d4467dc

File tree

1 file changed

+87
-32
lines changed

1 file changed

+87
-32
lines changed

goaccess.1

Lines changed: 87 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -462,27 +462,56 @@ client. See http://gwsocket.io for more details how the WebSocket server works.
462462

463463
.TP
464464
\fB\-\-ws-auth=<jwt[:secret]> | jwt:verify:secret\fR
465-
Enable WebSocket authentication using a JSON Web Token (JWT). This option supports two formats depending on whether the JWT is locally generated or externally fetched and verified:
466-
.IP
467-
\fB<jwt[:secret]>\fR: Specifies a static JWT for WebSocket authentication, with an optional secret for local generation or validation. If only "jwt" is provided (e.g., \fB\-\-ws-auth=jwt\fR), GoAccess generates a JWT using a secret sourced from the environment variable \fBGOACCESS_WSAUTH_SECRET\fR or a default HS256-compatible secret if unset. If a secret is included (e.g., \fB\-\-ws-auth=jwt:mysecret\fR), it's used directly as the HS256 signing key or read from a file if the value is a valid path (e.g., \fB\-\-ws-auth=jwt:/path/to/secret.key\fR).
468-
.IP
469-
\fBjwt:verify:secret\fR: Enables verification of an externally fetched JWT (e.g., via \fB\-\-ws-auth-url\fR). The "verify" keyword indicates that the JWT is provided by an external source, and the secret must be specified for validation. The secret can be a direct HS256 key (e.g., \fB\-\-ws-auth=jwt:verify:mysecret\fR), a file path (e.g., \fB\-\-ws-auth=jwt:verify:/path/to/secret.key\fR), or an environment variable name (e.g., \fB\-\-ws-auth=jwt:verify:$JWT_SECRET\fR). This format is required when using \fB\-\-ws-auth-url\fR and optionally \fB\-\-ws-auth-refresh-url\fR to fetch and verify JWTs from external endpoints.
470-
.IP
471-
When this option is used, the HTML report will not bootstrap the initial parsed data. Instead, it will only display the report if authentication succeeds, ensuring secure access to real-time data.
465+
Enable WebSocket authentication using a JSON Web Token (JWT). This option
466+
supports two formats depending on whether the JWT is locally generated or
467+
externally fetched and verified:
468+
.IP
469+
\fB<jwt[:secret]>\fR: Specifies a static JWT for WebSocket authentication, with
470+
an optional secret for local generation or validation. If only "jwt" is
471+
provided (e.g., \fB\-\-ws-auth=jwt\fR), GoAccess generates a JWT using a secret
472+
sourced from the environment variable \fBGOACCESS_WSAUTH_SECRET\fR or a default
473+
HS256-compatible secret if unset. If a secret is included (e.g.,
474+
\fB\-\-ws-auth=jwt:mysecret\fR), it's used directly as the HS256 signing key or
475+
read from a file if the value is a valid path (e.g.,
476+
\fB\-\-ws-auth=jwt:/path/to/secret.key\fR).
477+
.IP
478+
\fBjwt:verify:secret\fR: Enables verification of an externally fetched JWT
479+
(e.g., via \fB\-\-ws-auth-url\fR). The "verify" keyword indicates that the JWT
480+
is provided by an external source, and the secret must be specified for
481+
validation. The secret can be a direct HS256 key (e.g.,
482+
\fB\-\-ws-auth=jwt:verify:mysecret\fR), a file path (e.g.,
483+
\fB\-\-ws-auth=jwt:verify:/path/to/secret.key\fR), or an environment variable
484+
name (e.g., \fB\-\-ws-auth=jwt:verify:$JWT_SECRET\fR). This format is required
485+
when using \fB\-\-ws-auth-url\fR and optionally \fB\-\-ws-auth-refresh-url\fR
486+
to fetch and verify JWTs from external endpoints.
487+
.IP
488+
When this option is used, the HTML report will not bootstrap the initial parsed
489+
data. Instead, it will only display the report if authentication succeeds,
490+
ensuring secure access to real-time data.
472491
.IP
473492
The system processes this option as follows:
474493
.IP
475-
For \fB<jwt[:secret]>\fR: If no secret is provided, GoAccess generates a JWT locally using the \fBGOACCESS_WSAUTH_SECRET\fR environment variable or a default secret. If a secret is specified, it's used to sign the JWT (either directly or from a file).
494+
For \fB<jwt[:secret]>\fR: If no secret is provided, GoAccess generates a JWT
495+
locally using the \fBGOACCESS_WSAUTH_SECRET\fR environment variable or a
496+
default secret. If a secret is specified, it's used to sign the JWT (either
497+
directly or from a file).
476498
.IP
477-
For \fBjwt:verify:secret\fR: The secret is mandatory and used to verify externally fetched JWTs. It must match the signing key used by the external authentication server (e.g., at \fB\-\-ws-auth-url\fR).
499+
For \fBjwt:verify:secret\fR: The secret is mandatory and used to verify
500+
externally fetched JWTs. It must match the signing key used by the external
501+
authentication server (e.g., at \fB\-\-ws-auth-url\fR).
502+
.IP
503+
Requires to build GoAccess with
504+
.I --with-openssl.
478505
.TP
479506
\fB\-\-ws-auth-expire=<secs>
480-
Set the time after which the JWT expires. Defaults to 8 hours (28800 seconds) if not specified.
507+
Set the time after which the JWT expires. Defaults to 8 hours (28800 seconds)
508+
if not specified.
481509
.IP
482510
.I Only
483511
available for locally generated JWT.
484512
.IP
485-
Users can specify the expiration time in various formats. The value is converted to seconds for JWT expiration validation. Supported formats:
513+
Users can specify the expiration time in various formats. The value is
514+
converted to seconds for JWT expiration validation. Supported formats:
486515
.RS
487516
.IP \(bu 4
488517
"3600" -> 3600 seconds
@@ -496,43 +525,63 @@ Users can specify the expiration time in various formats. The value is converted
496525
"10d" -> 10 days = 864,000 seconds
497526
.RE
498527
.IP
499-
The expiration time controls how long the JWT remains valid after issuance, ensuring secure WebSocket connections.
528+
The expiration time controls how long the JWT remains valid after issuance,
529+
ensuring secure WebSocket connections.
500530
.TP
501531
\fB\-\-ws-auth-url=<url>
502-
Specifies the URL where GoAccess fetches the initial JWT to authenticate the WebSocket connection.
532+
Specifies the URL where GoAccess fetches the initial JWT to authenticate the
533+
WebSocket connection.
503534
.IP
504-
When this option is used, GoAccess sends a GET request to the specified URL to fetch an initial JWT. The response must be a JSON object containing \fBstatus\fR, \fBaccess_token\fR, \fBrefresh_token\fR, and \fBexpires_in\fR fields.
535+
When this option is used, GoAccess sends a GET request to the specified URL to
536+
fetch an initial JWT. The response must be a JSON object containing
537+
\fBstatus\fR, \fBaccess_token\fR, \fBrefresh_token\fR, and \fBexpires_in\fR
538+
fields.
505539
.IP
506-
Example: \fB\-\-ws-auth-url=https://page.com/api/get-auth-token\fR
540+
Example: \fB\-\-ws-auth-url=https://site.com/api/get-auth-token\fR
507541
.IP
508542
When fetching the token, GoAccess uses
509543
.I { credentials: 'include' }
510-
as part of the request to securely retrieve the access token based on the user’s existing authentication session in your system, ensuring token retrieval is safe as long as your users are authenticated.
544+
as part of the request to securely retrieve the access token based on the
545+
user’s existing authentication session in your system, ensuring token retrieval
546+
is safe as long as your users are authenticated.
511547
.IP
512-
This option allows you to integrate your existing authentication system with the GoAccess dashboard, using token retrieval endpoints.
548+
This option allows you to integrate your existing authentication system with
549+
the GoAccess dashboard, using token retrieval endpoints.
513550
.TP
514551
\fB\-\-ws-auth-refresh-url=<url>
515552
Specifies the URL where GoAccess fetches a new JWT when the current one is about to expire.
516553
.IP
517-
GoAccess proactively refreshes the JWT 60 seconds before expiration by sending a POST request with the refresh_token to this URL. If not provided, it defaults to the same URL as \fB\-\-ws-auth-url\fR.
554+
GoAccess proactively refreshes the JWT 60 seconds before expiration by sending
555+
a POST request with the refresh_token to this URL. If not provided, it defaults
556+
to the same URL as \fB\-\-ws-auth-url\fR.
518557
.IP
519-
Example: \fB\-\-ws-auth-refresh-url=https://page.com/api/refresh-token\fR
558+
Example: \fB\-\-ws-auth-refresh-url=https://site.com/api/refresh-token\fR
520559
.IP
521560
The response format should match that of the initial authentication URL.
522561
.SS "WebSocket Authentication Flow"
523562
.IP
563+
GoAccess offers flexible authentication options, supporting both stateless and
564+
stateful approaches. In the stateless approach, the refresh token is obtained
565+
without cookies or CSRF protection; your backend validates the refresh token’s
566+
signature and issues a new access token. Alternatively, the stateful approach
567+
allows the initial fetch to issue JWTs along with a `csrf_token`, which is
568+
stored in the session. The subsequent refresh request (POST) then performs a
569+
CSRF check, requiring the `X-CSRF-TOKEN` header to match the session’s token.
570+
.IP
524571
\fBInitial Authentication:\fR
525572
.RS
526573
.IP \(bu 4
527-
When started with \fB\-\-ws-auth-url=<url>\fR, GoAccess sends a GET request to fetch an initial JWT.
574+
When started with \fB\-\-ws-auth-url=<url>\fR, GoAccess sends a GET request to
575+
fetch an initial JWT.
528576
.IP \(bu 4
529577
The expected successful response format:
530578
.IP
531579
{
532-
"status": "success",
533-
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
534-
"refresh_token": "refresh123xyz",
535-
"expires_in": 3600
580+
"status" : "success",
581+
"access_token" : "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
582+
"csrf_token" : "3RRjNeR4RTXHmrV1cECkyUmmKeRxm4lzkI0eq41o",
583+
"refresh_token" : "refresh123xyz",
584+
"expires_in" : 3600
536585
}
537586
.IP \(bu 4
538587
If authentication fails, the endpoint should return:
@@ -546,22 +595,30 @@ If authentication fails, the endpoint should return:
546595
\fBToken Refreshing:\fR
547596
.RS
548597
.IP \(bu 4
549-
GoAccess refreshes the JWT 60 seconds before expiration by sending a POST request:
598+
GoAccess refreshes the JWT 60 seconds before expiration by sending a POST
599+
request to the specified URL (defaults to \fB--ws-auth-url\fR if
600+
\fB--ws-auth-refresh-url\fR is not set):
550601
.IP
551-
{
552-
"refresh_token": "refresh123xyz"
553-
}
602+
{ "refresh_token": "refresh123xyz" }
603+
.IP
604+
GoAccess supports both stateless and stateful authentication. For stateless, no
605+
cookies or CSRF are required; your backend validates the refresh token
606+
signature. For stateful, include a \fBcsrf_token\fR in the initial response;
607+
GoAccess sends it as \fBX-CSRF-TOKEN\fR in the refresh request, which your
608+
backend must validate against the session.
554609
.RE
555610
.IP
556611
\fBPeriodic Token Validation:\fR
557612
.RS
558613
.IP \(bu 4
559-
When GoAccess sends a refresh request to the endpoint, it confirms the validity of the updated JWT with the WebSocket server by transmitting this JSON object:
614+
After refreshing, GoAccess confirms the updated JWT’s validity with the
615+
WebSocket server by sending:
560616
.IP
561617
{ "action": "validate_token", "token": "current-jwt" }
562618
.RE
563619
.IP
564-
\fBImportant Note:\fR For these options to function, you must specify \fB\-\-ws-auth=jwt:verify:<secret>\fR where <secret> can be:
620+
\fBImportant Note:\fR For these options to function, you must specify
621+
\fB\-\-ws-auth=jwt:verify:<secret>\fR where <secret> can be:
565622
.RS
566623
.IP \(bu 4
567624
A path to a file containing the secret key (e.g., /path/to/secret.key)
@@ -572,8 +629,6 @@ The actual HS256 secret key as a string (e.g., mysecretkey123)
572629
.RE
573630
.IP
574631
Example: \fB\-\-ws-auth=jwt:verify:/path/to/secret.key\fR
575-
576-
577632
.TP
578633
\fB\-\-ws-url=<[scheme://]url[:port]>
579634
URL to which the WebSocket server responds. This is the URL supplied to the

0 commit comments

Comments
 (0)