Skip to content

Add documentation for Unix domain socket authenticator #57

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

joechrisellis
Copy link
Contributor

No description provided.

Copy link
Member

@ionut-arm ionut-arm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some more places where adding/modifying documentation is needed:

@@ -7,4 +7,15 @@ named](https://github.com/parallaxsecond/parsec-interface-rs/issues/22) "simple
the code, directly parse the authentication field as a UTF-8 string and uses that as application
identity. The direct authenticator is the one currently used by the Parsec service.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should probably remove the last phrase from here


The Unix domain socket authenticator uses Unix peer credentials to authenticate the user. Unix peer
credentials provide direct access to the (effective) user ID on the other end of a domain socket
connect, without cooperation from the endpoint.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

connect - > connection?

Also, without cooperation from the endpoint sounds a bit forceful, maybe something about it relying on the OS for this information?

credentials provide direct access to the (effective) user ID on the other end of a domain socket
connect, without cooperation from the endpoint.

To use this authenticator, the application must self-declare its UID in the authentication request
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in the authentication request -> in the authentication field of the request

@ionut-arm
Copy link
Member

Changes in the API overview page are also needed, in the Authentication and Sessions section.

Copy link
Member

@ionut-arm ionut-arm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but I think you've only updated the .drawio diagram, not the actual PNG that is displayed on the page

Copy link
Contributor

@paulhowardarm paulhowardarm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall. Suggest more precision when describing how to populate the auth field. Feels a bit vague as it is. Also our messaging around the auth mechanism vs. the transport seems slightly misleading to me.

successful and the application identity is set to the UID.

Currently, the peer credentials authenticator only supports authentication via the peer credentials
sourced from a Unix domain socket. However, the authenticator will likely support different
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about the phrasing here. It seems like the reverse of what we intend. Peer credential specifically requires domain socket to be the transport, because we rely on the ability of UDS to be able to query the credential in a trusted manner. I think it's misleading to say that peer credential would support other transports in the future, unless we're willing to significantly generalise our definition of what a peer credential is (in which case I don't think we can specifically talk about Unix UIDs or GIDs).

It would be more accurate to say the reverse: that a UDS transport could be used with other auth mechanisms and not only peer credential.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That might've been my fault, as I suggested expanding what we assume - the definition of "peer credential" would indeed depend on the transport mechanism, but I don't see an issue in assuming that other IPC mechanisms (e.g. network, d-bus) could be covered with this kind of authentication if we point out that only UDS are supported for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense -- removed mentions of other transports for this section.

@@ -177,6 +187,10 @@ permitted numerical values for this field are given as follows:-
- A value of 2 (`0x02`) indicates authentication tokens. The service will expect the
**authentication** field to contain a JWT token. Tokens must be signed with the private key of
the identity provider and their validity period must cover the moment when the check is done.
- A value of 3 (`0x03`) indicates peer credentials authentication. The service will expect the
**authentication** field to contain the stringified UID of the connecting process. The Parsec
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"stringified uid" feels a bit vague here considering this section is supposed to be the specification of how a client process should populate the auth field. We don't mention that it has to be UTF8 (although that is mentioned somewhere further down, but I think it needs to be here). We also probably want to be very explicit that we expect a UID and not a user name. Also, since UIDs are numerical, we probably want to specify what number format we expect. Decimal? Hex? Will the service parse conventional notations such as the 0x prefix for hex numbers? This is the level of precision that I think we need here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point -- I've changed this to:

- A value of 3 (`0x03`) indicates peer credentials authentication. The service will expect the                                                                                                                                                                                                                                                                                                                                           
  **authentication** field to contain the non-padded decimal UID (**not** username) of the
  connecting process as a UTF-8 string (e.g. `123`). The Parsec service will verify that this
  self-declared UID is consistent with the UID from the peer credentials.

Please let me know if there's any further suggestions!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think to answer to your original question about the format, we need to be clear about the scope of the authentictor. Is it a generic peer credentials authenticator which could be used with other operating systems/listener types or a Unix peer credential authenticator?
If the authenticator that we are describing here is only the later then I think we should:

  • be more precise where we mention "peer credentials" and always say "Unix peer credentials" and make sure that when we say "UID" we mean the specific Unix User identifier
  • the Unix User Identifier is represented with an integer type. Most Unix OS use 32 bits for this, and Linux uses the uid_t type which is an unsigned 32-bits number. For that reason, I think it would be better to expect the authentication payload to be the representation of a u32 value, 4-bytes padded with zeroes. For example the UID 4 would be [0x00, 0x00, 0x00, 0x04] (or reverse depending on our endianess). I think this is more efficient and less error-prone than having to parse/format a UTF-8 string.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think to answer to your original question about the format, we need to be clear about the scope of the authentictor. Is it a generic peer credentials authenticator which could be used with other operating systems/listener types or a Unix peer credential authenticator?

AFAIK 'peer credentials' is a Unix-exclusive thing, but I'm all for being more explicit. 😄

be more precise where we mention "peer credentials" and always say "Unix peer credentials" and make sure that when we say "UID" we mean the specific Unix User identifier

ACK, will do.

the Unix User Identifier is represented with an integer type. Most Unix OS use 32 bits for this, and Linux uses the uid_t type which is an unsigned 32-bits number. For that reason, I think it would be better to expect the authentication payload to be the representation of a u32 value, 4-bytes padded with zeroes. For example the UID 4 would be [0x00, 0x00, 0x00, 0x04] (or reverse depending on our endianess). I think this is more efficient and less error-prone than having to parse/format a UTF-8 string.

Agreed, that's a lot nicer. Will do. 🙂

@joechrisellis joechrisellis force-pushed the uds_authenticator_docs branch from ffe6908 to 3fb63a0 Compare August 11, 2020 16:04
ionut-arm
ionut-arm previously approved these changes Aug 13, 2020
Copy link
Member

@hug-dev hug-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that looks good to me 😃 One comment about the PNG

<mxfile modified="2020-08-11T09:38:52.879Z" host="app.diagrams.net" agent="5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36" etag="YgjPYXcEKpH_Ape6CRQq" version="13.6.2" type="device"><diagram id="r3fCkxUuyQpxchEkL19v" name="Page-1">7V1bd5s6Fv41WWvmwVkgcX1Mk5PTzmmn6WWm7SMxss0qBh/ATdJff8RFGCRhLpYwtuOs1RoBMuz9aWvftHUFb9fPf0bOZvUhdJF/BRT3+QreXQEAVNPC/6UtL0WLohl5yzLy3LxN3TV88X6jolEpWreei+LahUkY+om3qTfOwyBA86TW5kRR+FS/bBH69V/dOEvENHyZOz7b+s1zk1XeagFz1/4WecsV+WXVsPMza4dcXLxJvHLc8KnSBP+4grdRGCb5t/XzLfJT6hG65PfdN5wtHyxCQdLlhuTTe/3TJ/cJap8+P8SJ/cP2vZmp5d38cvxt8cbF0yYvhARRuA1clPaiXME3TysvQV82zjw9+4S5jttWydrHRyr+GidR+BPdhn4YZXfDN9lfeYYQUU0vXni+X7nUdZC1mON29tWKt/2FogQ9V5qKV/0ThWuURC/4kuLsTDUKur+QhuL4acdGVbOKxlWFhwZpdArsLMved+TFXwoK96G2ekxqC6CqpdVpClWdIaqmcGgKpNFUg1JpGoQBYsgJWewuFgswF4RdW6GpzEIX2jwqm7KozCOy4eOfffOIvyyT7MXzhkWIX7xKfuPvbUhOzOJMwt/gC1Rr87w7mYlwQs1dI6YrxJ9qU/5r7704QQGKyK/it8p/uP4wuLnygEKH2v199mQ0NjTc4vjeMsDf5xgD+BGFgAIoyrVew4XFEWgmBxWaLFAYvUHRkcX9wZP/2n2Er/ojcN86getfFjZqyCh1jqNBw2yERmfxoPI4fJureV4YlFCLOHyts1soa5Xsw86wklir2qDGWhUaDGt5SgwEkj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qKOdS8P1jW2HlHvZEn0WpVAYTL8GFWyhZxJYve5eEyYfDbbbgONm5laYwrx2/yJMGATt9ySrytLdQm3wIlBGI13pfPCjw7LVx3Y57yjcN5Tzf/awohpHKtNYFSEJlTy9wdXMQYKJ6mxgNwltGAp5KLQBe0LbpyCan9LbNUZLJFibiwSVgVewUwfU+U3IuCFvANBgl9sjYIpLz3LBVWR/Vb/HuaSOMygMHgGPiqxx8iVjizceXgFybKeIrj/RmQd/4gvBlUdke5a4kVYBpPM1Loy1/cRAD5wmxYtnvBaGLk1VGtolusfM1ITsk8+ElK5noNkyZqyxRQG2hdVaxNaoKHHHatZQcARL5KTBd/bDIWkfX8VBfdSPzWl3OJK7T6nImkaupuJyZmlu6Whaz6x1dg3RZsZGja4S4IzicMdUXYbTGF5BAm2AH0ypcP25jcdIKXDHhsvJKAUJLhXRkVdlVRayqOry5yJZlq5my1lSWKc1FHPUzijdhEKOsx2g7T7ZRFmWdR+h8J6oZFSGFWGXlRUgBh+XAljZdmc1hp8OY/t4Jlltsw1RD6pW9AbAKHMTb9Ya/t+d5IkClrJtZ6UQ+JgCaowwH6p9ZrbMq+32yy+IFMp/eL2+m2gZvIcPY3JeV0Ufm/IbhfxE8V0tulmFl1jzhujNkclxWDcxyD9XL47NC8VkjPqMWtwLoHzrGh1GY0n1nCmB6rD5gYz+94h8=</diagram></mxfile>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for updating the diagram as well! Could you also please keep the white background? I believe that in the png you exported from draw.io the background is transparent. Just so that it is easier to read on our book 😃!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just checked the other .drawio files in the repository and they all seem to have transparent backgrounds as well? Am I missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, you're right -- the .drawio files do have transparent background, but I had selected the 'export with transparent background' option.

Copy link
Member

@hug-dev hug-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes, looks good to me!!

Copy link
Member

@ionut-arm ionut-arm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌

Comment on lines 26 to 27
The GID component of the Unix peer credentials is currently unused by the peer credentials
authenticator.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gonna guess the PID isn't used either.

@hug-dev hug-dev merged commit 23e8872 into parallaxsecond:master Sep 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants