github.com/slspeek/camlistore_namedsearch@v0.0.0-20140519202248-ed6f70f7721a/website/content/docs/sharing (about)

     1  <h1>Sharing</h1>
     2  
     3  <p><b>TODO:</b> finish documenting this. In particular, add example with camget -shared.</p>
     4  
     5  <p>The basic summary is that you create
     6  a <a href="/docs/terms#claim">claim</a> that a user has access to
     7  something, and then your blobserver's public frontend authenticates
     8  (if applicable) a remote user and gives them access as permitted by
     9  your claim.</p>
    10  
    11  <p>Reproducing an email from <a
    12  href="http://groups.google.com/group/camlistore/browse_thread/thread/a4920d6a1c5fc3ce">this
    13  thread</a> for some background:</p>
    14  
    15  <center>*</center>
    16  
    17  <div style='font-style: italic'>
    18  
    19  <p>This is an example walk-though of (working) sharing on Camlistore.   Brett and I got this working last night (the basic "have a link" use case with no addition auth)</p>
    20  
    21  <p>Let's say I have a private blobserver:</p>
    22  
    23  <a href="http://camlistore.org:3179/">http://camlistore.org:3179/</a>
    24  
    25  <p>And I have a file, "Hi.txt".</p>
    26  
    27  <p>Its bytes are blob <code>sha1-3dc1d1cfe92fce5f09d194ba73a0b023102c9b25</code><br />
    28  Its metadata (inode, filename, etc) is blob <code>sha1-0e5e60f367cc8156ae48198c496b2b2ebdf5313d</code></p>
    29  
    30  <p>You don't have access to those, even though you know their names.  Verify the 401 errors:</p>
    31  
    32  <p><a href="http://camlistore.org:3179/camli/sha1-3dc1d1cfe92fce5f09d194ba73a0b023102c9b25">http://camlistore.org:3179/camli/sha1-3dc1d1cfe92fce5f09d194ba73a0b023102c9b25</a><br />
    33  <a href="http://camlistore.org:3179/camli/sha1-0e5e60f367cc8156ae48198c496b2b2ebdf5313d">http://camlistore.org:3179/camli/sha1-0e5e60f367cc8156ae48198c496b2b2ebdf5313d</a></p>
    34  
    35  <p>(hm, those are returning Unauthorized errors, but no Content Body... will fix later)</p>
    36  
    37  <p>Note also that any errors you get from my private blob server always delay for at least 200 ms to mask timing attacks that could otherwise reveal the existence or non-existence of a blob on my private server.</p>
    38  
    39  <p>Note that in order to have all of the following working, your server needs to have a share handler, so you need to have the line</br>
    40  <b><code>"shareHandler"</code></b>: true,</br>
    41  in your server <a href="/docs/server-config">config</a>.</p>
    42  
    43  <p>Now I want to share Hi.txt with you, so I create a share blob (e.g <code><a href="/cmd/camput">camput</a> share --transitive sha1-0e5e60f367cc8156ae48198c496b2b2ebdf5313d</code>).</p>
    44  
    45  <p>I've created this, and its name is <code>sha1-102758fb54521cb6540d256098e7c0f1625b33e3</code></p>
    46  
    47  <p>Note that you can fetch it without authentication, because you're using the url prefix <code>/share/</code>, which delegates the task to the share handler, and because the share handler checks that it's a share blob that doesn't require auth (<code>authType</code> == "haveref" ... like "Share with others that have the link")</p>
    48  
    49  <p>Here's you getting the blob:</p>
    50  
    51  <pre class='sty' style='overflow: auto'>$ curl <a href="http://camlistore.org:3179/share/sha1-102758fb54521cb6540d256098e7c0f1625b33e3">http://camlistore.org:3179/share/sha1-102758fb54521cb6540d256098e7c0f1625b33e3</a>
    52  {"camliVersion": 1,
    53    "authType": "haveref",
    54    "camliSigner": "sha1-3bee195d0dada92a9d88e67f731124238e65a916",
    55    "camliType": "claim",
    56    "claimDate": "2013-06-24T14:17:02.791613849Z",
    57    "claimType": "share",
    58    "target": "sha1-0e5e60f367cc8156ae48198c496b2b2ebdf5313d",
    59    "transitive": true
    60  ,"camliSig":"wsBcBAABCAAQBQJRyFTeCRApy/NNAr6GZgAAKmgIAGbCCn1YPoZuqz+mcMaLN09J3rJYZPnjICp9at9UL7fFJ6izzDFLi6gq9ae/Kou51VRnuLYvRXGvqgZ9HCTTJiGaET8I6c3gBvQWMC/NOS/B9Y+CcZ5qEsz84Dk2D6zMIC9adQjN4yjtcsVtKYDVDQ5SCkCE6sOaUebGBS22TOhZMXPalIyzf2EPSiXdeEKtsMwg+sbd4EmpQHeE3XqzI8gbcsUX6VdCp6zU81Y71pNuYdmEVBPY5gVch2Xe1gJQICOatiAi4W/1nrTLB73sKEeulzRMbIDB4rgWooKKmnBPI1ZOTyg/fkKmfWfuJKSU0ySiPwVHn4aPFwCGrBRladE==KjfB"}</pre>
    61  
    62  <p>Note the "target" and "transitive".</p>
    63  
    64  <p>Now we present this proof of access in subsequent requests in the "via" parameter, with the in-order path of access.</p>
    65  
    66  <p>Here's the first hop to the metadata, in which we discover the blobRef of the bytes of the file (in this case, just one part is the whole file bytes...)  I already told you this earlier in the email, but assume you're just discovering this now.</p>
    67  
    68  <pre class='sty' style='overflow: auto'>$ curl <a href="http://camlistore.org:3179/share/sha1-0e5e60f367cc8156ae48198c496b2b2ebdf5313d?via=sha1-102758fb54521cb6540d256098e7c0f1625b33e3">http://camlistore.org:3179/share/sha1-0e5e60f367cc8156ae48198c496b2b2ebdf5313d<b>?via=</b>sha1-102758fb54521cb6540d256098e7c0f1625b33e3</a>
    69  {"camliVersion": 1,
    70    "camliType": "file",
    71    "contentParts": [
    72      {
    73        "blobRef": "sha1-3dc1d1cfe92fce5f09d194ba73a0b023102c9b25",
    74        "size": 14
    75      }
    76    ],
    77    "fileName": "Hi.txt",
    78    "size": 14,
    79    "unixGroup": "camli",
    80    "unixGroupId": 1000,
    81    "unixMtime": "2011-01-26T21:11:22.152868825Z",
    82    "unixOwner": "camli",
    83    "unixOwnerId": 1000,
    84    "unixPermission": "0644"
    85  }</pre>
    86  
    87  <p>Now let's get the final bytes of the file:</p>
    88  
    89  <pre class='sty' style='overflow: auto'>$ curl <a href="http://camlistore.org:3179/share/sha1-3dc1d1cfe92fce5f09d194ba73a0b023102c9b25?via=sha1-102758fb54521cb6540d256098e7c0f1625b33e3,sha1-0e5e60f367cc8156ae48198c496b2b2ebdf5313d">http://camlistore.org:3179/share/sha1-3dc1d1cfe92fce5f09d194ba73a0b023102c9b25<b>?via=</b>sha1-102758fb54521cb6540d256098e7c0f1625b33e3,sha1-0e5e60f367cc8156ae48198c496b2b2ebdf5313d</a>
    90  Hello, Camli!</pre>
    91  
    92  <p>That's it.</p>
    93  
    94  <p>Now imagine different <code>authType</code> parameters (passwords, SSL
    95  certs, SSH, openid, oauth, facebook, membership in a group,
    96  whatever... )</p>
    97  
    98  </div>