fission-codes / auth-lobby

The authentication service that Fission services run.
https://auth.fission.codes
GNU Affero General Public License v3.0
12 stars 1 forks source link

docs #97

Closed nichoth closed 1 year ago

nichoth commented 2 years ago

Hello. This issue is to ask if someone can write some more detailed docs about what this module does.

The readme has a high-level view of what this does, but could someone write what happens at a lower level?

Like how does it update state? What interface — indexedDB, IPFS? What, if any, other fission modules does it use to do this? The readme mentions a Shared IPFS Worker, what module is that? How does this use the IPFS worker?

context This is related to a library that uses webnative. I am trying to write tests for it, and I need to authenticate before testing.

bgins commented 2 years ago

Thanks for the questions. I'm writing a concepts section for https://guide.fission.codes/, and they are giving me inspiration for some things to cover. 🙂

I can answer some of the questions about the Shared Worker because I've been working with that code recently. The Shared Worker is implemented in this file https://github.com/fission-suite/auth-lobby/blob/develop/src/Javascript/Worker.js, and it gets loaded here: https://github.com/fission-suite/auth-lobby/blob/a6d7ba313876dffa5ab5f3de074c8c9ffe28a93c/src/Static/Html/Ipfs/v2.html#L13

Apps that use webnative load v2.html into an iframe here: https://github.com/fission-suite/webnative/blob/924db533a842ab80c8f4e59bf1af4c6296d0ee7c/src/ipfs/config.ts#L40.

This sets up a communication channel between the app and the iframe using ipfs-message-port-client and ipfs-message-port-server to transfer IPFS updates. The shared worker initially connects to Fission IPFS peers here: https://github.com/fission-suite/auth-lobby/blob/a6d7ba313876dffa5ab5f3de074c8c9ffe28a93c/src/Javascript/Worker.js#L223-L224

using the SWARM interface from js-ifps core.

That doesn't answer all of your questions, but hopefully fills in some of the mechanics of how the Shared Worker fits into the system.

nichoth commented 2 years ago

thanks @bgins

more research -- https://guide.fission.codes/developers/webnative/auth#authorization

The Auth Lobby creates a User Controlled Authorization Networks (UCAN) token

Webnative checks the UCAN at initialization and returns an auth scenario

In order to mock a 'login'… we need to create a UCAN and save it where webnative will look for it

Is it saved under 'ucan' in localforage?

questions

icidasset commented 1 year ago

This functionality is being moved to Webnative, see capabilities in Webnative v0.35