Skip to content

websocket client basic authentication #2227

Discussion options

You must be logged in to vote

There is no authentication in WS but in HTTP
It is you who has to write the code to check for authentication and upgrade the connection to WS after authenticating the URL.
https://mongoose.ws/documentation/tutorials/device-dashboard/

} else if (u == NULL && mg_http_match_uri(hm, "/api/#")) {
// All URIs starting with /api/ must be authenticated
mg_http_reply(c, 403, "", "Denied\n");

} else if (mg_http_match_uri(hm, "/api/watch")) {
c->data[0] = 'W'; // Mark ourselves as a event listener
mg_ws_upgrade(c, hm

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
3 replies
@Yhee2
Comment options

@cpq
Comment options

@Yhee2
Comment options

Answer selected by scaprile
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants
Converted from issue

This discussion was converted from issue #2226 on May 31, 2023 17:09.