aboutsummaryrefslogtreecommitdiffstats
path: root/src/cynagora-protocol.txt
blob: ea3c1c2eb4b4272849354eed5ebfafb1c80f1f72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
The cynagora protocol
=====================

Introduction
------------

### Notations:

 - c->s:    from client to cynagora server
 - s->c:    from cynagora server to client
 - CACHEID: a 32 bits positive integer
 - ID:      a string
 - EXPIRE:  if missing, means: can cache forever
            if '-', means: don't cache
            if TIMESPEC (see below), means: valid until given relative time
 - SEXPIRE: Same as EXPIRE but also allows TIMESPEC prefixed with '-', meaning
            valid until given relative time and don't cache

For TIMESPEC see notes.

Messages
--------

### hello

synopsis:

	c->s cynagora 1
	s->c done 1 CACHEID

The client present itself with the version of the protocol it expects to
speak (today version 1 only). The server answer yes with the acknoledged
version it will use and the CACHEID that identify the cache (see note on
CACHEID)

If hello is used, it must be the first message. If it is not used, the
protocol implicitely switch to the default version.


### invalidate cache

synopsis:

	s->c clear CACHEID

The server ask the client to clear its cache and to start the cache whose
identifier is CACHEID
  

### test a permission

synopsis:

	c->s test ID CLIENT SESSION USER PERMISSION
	s->c (ack|yes|no) ID [EXPIRE]

Check whether the permission is granted (yes) or not granted (no)
or undecidable without querying an agent (ack).


### check a permission

synopsis:

	c->s check ID CLIENT SESSION USER PERMISSION
	s->c (yes|no) ID [EXPIRE]

Check whether the permission is granted (yes) or not granted (no) and invoke
agent if needed.


### enter critical (admin)

synopsis:

	c->s enter
	s->c done

Start modifications (prior to set or drop).


### leave critical (admin)

synopsis:

	c->s leave [commit|rollback]
	s->c done|error ...

Terminate modifications and commit it (commit) or cancel it (rollback).


### erase (admin)

synopsis:

	c->s drop CLIENT SESSION USER PERMISSION
	s->c done|error ...

Drop the rule matching the given filter.


### set (admin)

synopsis:

	c->s set CLIENT SESSION USER PERMISSION VALUE [SEXPIRE]
	s->c done|error ...

Create the rule as given.


### list permissions (admin):

synopsis:

	c->s get CLIENT SESSION USER PERMISSION
	s->c item CLIENT SESSION USER PERMISSION VALUE [SEXPIRE]
	s->c ...
	s->c done

List the rules matching the given filter.


### logging set/get (admin)

synopsis:

	c->s log [on|off]
	s->c done (on|off)

Tell to log or not the queries or query the current state.


### register agent (agent)

synopsis:

	c->s agent NAME
	s->c done|error ...

Register the agent of NAME


### ask agent (agent):

synopsis:

	s->c ask ASKID NAME VALUE CLIENT SESSION USER PERMISSION
	c->s reply ASKID ([yes|no] [always|session|one-time|EXPIRE])

Receive an agent resolution request.


### sub check (agent):

synopsis:

	c->s sub ASKID ID CLIENT SESSION USER PERMISSION
	s->c (yes|no) ID [EXPIRE]

Make a check in the context of an agent resolution.


Notes
-----

### TIMESPEC

The TIMESPEC describe a number of seconds in the futur relative to now.
It can be a simple decimal integer. I can also use letters to designate
year (letter `y`), week (letter `w`), day (letter `d`), hour (letter `h`),
minute (letter `m`), second (letter `s`).

Examples:

	- 15d


### CACHEID

The cacheid identify the current cache. It changes each time the database
changes. After a disconnection, clients can use HELLO to check whether their
version of cache is still valid. This is implemented by the default C library.