This file is indexed.

/usr/share/doc/ikiwiki-hosting-common/design/customersite.html is in ikiwiki-hosting-common 0.20170622ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
185
186
187
188
189
190
191
192
193
194
195
196
197
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>customersite</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />

<link rel="stylesheet" href="../style.css" type="text/css" />

<link rel="stylesheet" href="../local.css" type="text/css" />










</head>
<body>

<div class="page">

<div class="pageheader">
<div class="header">
<span>
<span class="parentlinks">

<a href="../index.html">ikiwiki hosting internals</a>/ 

<a href="../design.html">design</a>/ 

</span>
<span class="title">
customersite

</span>
</span>



</div>









</div>





<div id="pagebody">

<div id="content" role="main">
<p>When ikiwiki-hosting is used as a business, information about customers
needs to be stored. Rather than use a database, we use the customersite,
accessed by the <code>IkiWiki::Customer</code> module.</p>

<p>This is a regular site managed by ikiwiki-hosting like any other. Its
configuration is somewhat special though. When setting it up:</p>

<ul>
<li>Be sure to configure ikiwiki to <code>exclude:
customer/*</code>, and turn off branchability, to avoid customer data leaking
out! Also, disable recentchanges, that can leak data too.</li>
<li>Configure it to accept a ssh key owned by the controlsite, so that
site can push into it.</li>
<li>Configure its <code>git_wrapper_background_command</code> to update
the controlsite's checkout of the customersite, by having it run
". /etc/ikiwiki-hosting/ikiwiki-hosting.conf; ikisite-wrapper updatecustomersite $controlsite"</li>
</ul>


<p>Inside the customersite, there is a <code>customer</code> directory, which holds
information about all the customers. Each customer has a subdirectory
there, which holds files for each piece of data tracked about a customer.</p>

<p>The name of a customer's subdirectory is obtained by taking the sha1sum of
their username. If a customer has multiple openids or emails used for
login, they can have multiple subdirectories, symlinked together. (ikiwiki
will not render the symlinks, but that's ok; it's not rendering customer
data at all if configured right.)</p>

<p>The individual files hold one single piece of data, or a unordered
list (ie, a list of email addresses). Files holding a list have "_list"
in their filename.</p>

<p>This design is intended to allow changes to be made to multiple branches
of the customersite, and merged together with little chance of conflicts.
Git's union merge driver can be used to merge the list files. Other
fields may have custom merge drivers.</p>

<h2>locking</h2>

<p>A file named <code>lock</code> in each customer's directory is used as a lock file
by anything that reads or writes a customer's data.</p>

<p>A file named <code>lock</code> in the top of the customersite is used as a lock file
for anything that needs to change arbitrary files anywhere in the
customersite. (For example, a git pull.) This lock should be taken first,
as a shared lock by things that do customer-level locking.</p>

<h2>fields</h2>

<ul>
<li><code>notes.mdwn</code> freeform notes about customer</li>
<li><code>currentplan</code> holds the name of the price plan the user has agreed to</li>
<li><code>email</code> holds the current contact email of the user</li>
<li><code>email_list</code> holds all known emails of the user</li>
<li><code>name</code> holds the user's name (preferably full name, but may be whatever
is available from openid, or possibly derived from email address).</li>
<li><code>openid_list</code> holds the openid(s) of the user</li>
<li><code>startdate</code> when this customer's account was first created (represented
as time from unix epoch)</li>
<li><code>balance</code> amount of money owed (in cents) (a negative balance indicates
the customer has a credit)</li>
<li><code>previousbalance</code> what the balance was before the last billing or payment
 event (be sure to update this when changing the balance)</li>
<li><code>lastbilldate</code> when user was last billed (represented as time
from unix epoch)</li>
<li><code>disable_billing</code> if set to a true value, bills will not be sent
(used for test accounts)</li>
<li><code>lastreminderdate</code> when last billing reminder was sent</li>
<li><code>bill_startdate</code> start of billing period for last bill</li>
<li><code>bill_enddate</code> end of billing period for last bill</li>
<li><code>lastinvoiceid</code> id of the last invoice sent</li>
<li><code>lastplan</code> name of the price plan used in the last invoice sent</li>
</ul>


<h2>non-customer data</h2>

<p>In a charming example of scope creep, we're storing a bit of
non-customer-specific data in the customersite already:</p>

<ul>
<li><code>invoice/last</code> - stores the last used invoice id.</li>
<li><code>invoice/YYY-MM/</code> - stores copies of invoices sent to customers</li>
</ul>


</div>







</div>

<div id="footer" class="pagefooter" role="contentinfo">

<div id="pageinfo">






<div id="backlinks">
Links:

<a href="../design.html">design</a>


</div>






<div class="pagedate">
Last edited <span class="date">Thu Jun 22 09:08:31 2017</span>
<!-- Created <span class="date">Thu Jun 22 09:08:31 2017</span> -->
</div>

</div>


<!-- from ikiwiki hosting internals -->
</div>

</div>

</body>
</html>