Hi,
I was just reading over the quite nicely written design document of pubsub.
That triggered me to think a bit about authentication on a topic level, that’s basically the AuthOpts in that document.
While thinking about it i’m stuck in the thought of “who manages the registration”?
Assume an implementation would set the AuthMode
to key
. This means that any key in the keys
array is allowed to publish on that topic. But who determines which keys
(peer id’s) are allowed to be in that array? Who is the “authority” of key changes?
In pubsub i can’t even figure out who the topic author is, at all. I can see who a “message” author is. It’s the message.from
value which is optional. But i can’t figure out who the topic author is.
Anyhow, i’m just going to assume for this post that the first one creating a topic (what creates a topic, a subscribe or a publish?) is in effect the author of the topic. So with that assumption in place…
Currently the AuthOpts looks like this:
message AuthOpts {
optional AuthMode mode = 1;
repeated bytes keys = 2;
enum AuthMode {
NONE = 0;
KEY = 1;
WOT = 2;
}
}
I’m afraid that this won’t scale well. As said before, the document states that the keys of those that are allowed to publish should be stored in the keys array. That likely works fine with small numbers. Say 0-100 allowed publishers. But that will become much more data if you expand it into thousands. A usecase for that would potentially be a chat place where you need to “register” to say something. Each of those registrants should then be in the keys array.
Furthermore, revoking someone’s access for whatever reason isn’t easily possible in this design. As how would you notify all your subscribers of a topic that one peer id is now removed from the list. Or added.
But i think there is a solution to solve both problems.
IPNS over PubSub!
First of all, i would change the AuthOpts slightly:
message AuthOpts {
optional AuthMode mode = 1;
string ipnsKeys = 2;
optional string ipnsKeysAuthor = 3;
enum AuthMode {
NONE = 0;
KEY = 1;
WOT = 2;
}
}
So i’ve added string ipnsKeys and optional string ipnsKeysAuthor.
First for the ipnsKeys
. This should just be a single IPNS hash pointing to a document that contains an array of peer id’s. This means the topic message won’t grow or shrink in byte size as the peers that are allowed to publish are now abstracted away in an IPNS record.
And due to it being IPNS, it’s now also possible to revoke access. And to keep these IPNS record updates fast, the user should have IPNS over pubsub enabled.
If the ipnsKeys
is of a type that includes the public key already then the optional string ipnsKeysAuthor can be omitted. Otherwise the author’s public key should be added here to verify that the ipnsKeys
is created by the ipnsKeysAuthor
. (side note, both cases do need an added signature, right? If yes, that would have to be added too as a required property.)
Both those values should be set at topic creating time, whenever that is.
There is still an issue though.
All of this still relies on a list of all peerids that are allowed to publish. That is a centralized concept (the list part). We can do better, can’t we?
We don’t need a list! All we need to know is basically asking “are you allowed to publish?”.
For this to work there needs to be a peer that can - and is allowed to - allow someone access on a topic. Say that peer is the “topic author”. In this case a new arbitrary peer id that isn’t the author should ask the author “can i join”. This too can be done on a side pubsub channel. How i envision it is the peer author to sign the following document structure:
message TopicApproval {
// topic to which the peer asks permission
string topic = 1;
// peer id of the author of the topic
string topicAuthor = 2;
// peer id of of peer asking to join
string peer = 3;
// signature of author with this peer id
string signature = 4;
}
The peer that joins must now host that file as it’s proof to talk on that topic.
The file must then be accessible under: <peerid>/pubsub/topic/<sha256 hashed topic>/proof
.
That structure or something alike. When that peer publishes something to that topic, all those that are subscribed can verify that <peerid>/pubsub/topic/<sha256 hashed topic>/proof
is allowed to post. I assume this to be cashed so the traffic of these proof messages doesn’t need to be high.
A downside in this last proposal is that you lose the ability to block peers. I can think of ways to add means to fix that, but to prevent this post to become too super long i’ll just call it “to be thought of in the future”.
This discuss board seems fairly low traffic. Therefore i’m just tagging the people i could find in git and here so you’re aware the topic exists.
@whyrusleeping @raul @vyzo
@stebalien @vasco-santos << For the first 3, could one of the later two mention them?)
(i couldn’t find @yusefnapora, @jamesray1, @protolambda
in this discuss board)
I’m really looking forward to your thoughts!
Best regards,
Mark
Note: i had to remove links and mentions because i’m newly registered here and can only post 2 of each… -_-