Permalink
Browse files

Reflect current implementation in security doc

  • Loading branch information...
michaellperry committed Nov 17, 2015
1 parent d4899fb commit 15bbc736403ffd6882c1dd697b3e903cae843673
Showing with 31 additions and 29 deletions.
  1. +31 −29 security.md
View
@@ -1,89 +1,91 @@
# Security
-A message can be used to identify an individual user of the application. Such a message will have a public key, represented as a base-64 encoded string, as a property called **__publicKey**.
+A message can be used to identify an individual user of the application. Such a message will have a public key, represented as a base-64 encoded string, as a property called **publicKey**.
```JavaScript
var user = {
- type: "User",
- __publicKey: "...nbZ15mk0zNC/WJWjM3vDRB3"
+ type: "Jinaga.User",
+ publicKey: "-----BEGIN RSA PUBLIC KEY-----\nMIGJAoG...MBAAE=\n-----END RSA PUBLIC KEY-----\n"
}
```
-Your client-side app won't need to generate this key. The distributor will manage the user's identity for you. Just call the distributor to get the user's identity based on their current OAuth2 token.
+Your client-side app won't need to generate this key. The distributor will manage the user's identity for you. Just call Jinaga to get the user's identity based on their current OAuth2 token.
```JavaScript
-distributor.login(function (err, identity) {
- user = identity;
+j.login(function (u) {
+ if (!u)
+ window.location = "http://jinaga.cloudapp.net/login";
+ else
+ user = u;
});
```
The distributor retains the user's private key, so that any messages posted with the user's OAuth2 token will be correctly decrypted and signed.
## Privacy
-To send a private message to an individual, set the individual as the **__to** property of the message. The distributor will encrypt the message using that user's public key.
+To send a private message to an individual, set the individual as the **to** property of the message. The distributor will encrypt the message using that user's public key.
```JavaScript
var secret {
type: "Secret",
- __to: flynn,
+ to: flynn,
password: "Reindeer Flotilla"
};
-q.fact(secret);
+j.fact(secret);
```
The distributor will store the encrypted message. It will only decrypt the message for the user to which it is sent. That user must supply an OAuth2 token so that the distributor can access their private key. No other users will receive the message, even if they submit a query that would match it.
## Authenticity
-To sign a message, set your own user object as the **__from** property of the message. The distributor will sign the message using your private key when you post it using your OAuth2 token.
+To sign a message, set your own user object as the **from** property of the message. The distributor will sign the message using your private key when you post it using your OAuth2 token.
```JavaScript
var email {
type: "Email",
- __to: alan1,
- __from: flynn,
+ to: alan1,
+ from: flynn,
content: "It's all in the wrists."
};
-q.fact(email);
+j.fact(email);
```
-The distributor will verify signatures before delivering any messages. The client application never sees the signature, but the message would not be delivered if the signature was invalid. Upon receiving a message with a **__from** property, you can be certain that it was from that sender and was not tampered with.
+The distributor will verify signatures before delivering any messages. The client application never sees the signature, but the message would not be delivered if the signature was invalid. Upon receiving a message with a **from** property, you can be certain that it was from that sender and was not tampered with.
## Secrecy
-A shared key can be used to encrypt messages that multiple people can all see. Set the **__locked** property to true to tell the distributor that a message should have a shared key. Set the **__admin** property of a successor message to indicate that a user has admin privileges for that object.
+A shared key can be used to encrypt messages that multiple people can all see. Set the **admin** property of a successor message to indicate that a user has admin privileges for that object. The shared key will be encrypted using that user's public key.
```JavaScript
var project {
type: "Project",
name: "Space Paranoids",
- __locked: true
};
var flynnPrivilege {
type: "Privilege",
- __admin: project,
- __to: flynn,
- __from: flynn
+ admin: project,
+ to: flynn,
+ from: flynn
};
-q.fact(project);
-q.fact(flynnPrivilege);
+j.fact(project);
+j.fact(flynnPrivilege);
```
Your client app does not need to generate the shared key. The distributor will generate it and store it in the successor message.
-The successor must be encrypted. So it must have a **__to** predecessor. The admin can generate additional messages to assign privileges to other users. Set the **__read** or **__write** properties for these additional privileges.
+The successor must be encrypted. So it must have a **to** predecessor. The admin can generate additional messages to assign privileges to other users. Set the **read** or **write** properties for these additional privileges.
```JavaScript
-q.fact({
+j.fact({
type: "Privilege",
- __write: project,
- __to: alan1,
- __from: flynn
+ write: project,
+ to: alan1,
+ from: flynn
});
```
@@ -92,10 +94,10 @@ This message contains the shared key for the project. It is encrypted using Alan
Now that Flynn has write privileges to the project, he can create successors.
```JavaScript
-q.fact({
+j.fact({
type: "Instruction",
- __in: project,
- __from alan1,
+ in: project,
+ from alan1,
program: "TRON"
});
```

0 comments on commit 15bbc73

Please sign in to comment.