dsriseah / ursys

an opinionated javascript library for prototyping realtime web apps
1 stars 2 forks source link

"Auth-Ready" URSYS Networking Test Bed #13

Closed dsriseah closed 1 month ago

dsriseah commented 1 month ago

The URSYS Networking modules and related demo app are ready to use as an integration testbed with third-party authentication systems. With luck, it will be useful for:

WHAT'S NEW

Setup

Observations

Shutting Down

QUICK PR TESTING on SERVER

You can run it in the same way, substituting 127.0.0.1:8080 for the domain name where you are hosting it. You can see what the server is running on in the terminal:

image

[!NOTE] The AppServer is compatible with nginx https proxying, and assumes that the websocket server is listening at /urnet-http on the same port. The nginx configuration is documented on the WIKI in Guide: Securing URSYS

AUTHENTICATION METHOD PROTOTYPING

Authentication is part of the URSYS Network connection protocol which uses special NetPackets.

Currently, there is no actual authentication happening so it always succeeds. There are two placeholder locations.

_handleAuthRequest(pkt,socket) in class-urnet-endpoint.ts

The server invokes this through _ingestClientPacket(json,socket). It's currently coded to allow each socket to authenticate once, setting the authenticated flag on the socket, but this is not a hard requirement.

image

Connect() in client-http.ts

The client-http module is loaded by the example chat webapp, and exposes the Connect() as part of its API.

In the line commented as // 2. start client; EP handles the rest you can see the auth object being populated with credentials to be sent to the server. This is fed into the Endpoint.connectAsClient(client_sock, auth) call which will do the actual client handshake.

If the authentication fails, then no other packets are accepted. The promise resolves with { error } on rejection. If there is no error property the resolved value is { uaddr, cli_auth } but it is not necessary for you to save them as the Endpoint code will retain it for you.

image