├── .gitignore
├── LICENSE
├── README.md
├── capybara.svg
├── capybara_transparent.svg
├── config
├── config.example.yml
└── database.example.yml
├── controllers
├── about_controller.go
├── account_controller.go
├── login_controller.go
├── logout_controller.go
├── otp_controller.go
├── public_controller.go
└── registration_controller.go
├── go.mod
├── go.sum
├── gulpfile.js
├── main.go
├── middleware
├── sessions_middleware.go
└── settings_middleware.go
├── migrations
├── 20180406044110_create_accounts.down.fizz
├── 20180406044110_create_accounts.up.fizz
├── 20180407080009_create_users.down.fizz
├── 20180407080009_create_users.up.fizz
├── 20180409041516_create_statuses.down.fizz
└── 20180409041516_create_statuses.up.fizz
├── models
├── account.go
├── account_test.go
├── status.go
├── status_test.go
├── user.go
└── user_test.go
├── package-lock.json
├── package.json
├── public
├── css
│ └── styles.css
└── img
│ ├── avatar
│ └── missing.png
│ ├── capybara.svg
│ ├── favicon.png
│ └── header
│ └── missing.png
├── scss
└── styles.scss
├── serializers
└── serializer.go
├── util
└── time.go
└── views
├── 404.pug
├── about.pug
├── index.pug
├── layout.pug
├── login.pug
├── otp.pug
├── otp_login.pug
└── public_user.pug
/.gitignore:
--------------------------------------------------------------------------------
1 | config/database.yml
2 | config/config.yml
3 | vendor/
4 | migrations/schema.sql
5 | bin/
6 | .idea/
7 | keys/
8 | node_modules/
9 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU AFFERO GENERAL PUBLIC LICENSE
2 | Version 3, 19 November 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU Affero General Public License is a free, copyleft license for
11 | software and other kinds of works, specifically designed to ensure
12 | cooperation with the community in the case of network server software.
13 |
14 | The licenses for most software and other practical works are designed
15 | to take away your freedom to share and change the works. By contrast,
16 | our General Public Licenses are intended to guarantee your freedom to
17 | share and change all versions of a program--to make sure it remains free
18 | software for all its users.
19 |
20 | When we speak of free software, we are referring to freedom, not
21 | price. Our General Public Licenses are designed to make sure that you
22 | have the freedom to distribute copies of free software (and charge for
23 | them if you wish), that you receive source code or can get it if you
24 | want it, that you can change the software or use pieces of it in new
25 | free programs, and that you know you can do these things.
26 |
27 | Developers that use our General Public Licenses protect your rights
28 | with two steps: (1) assert copyright on the software, and (2) offer
29 | you this License which gives you legal permission to copy, distribute
30 | and/or modify the software.
31 |
32 | A secondary benefit of defending all users' freedom is that
33 | improvements made in alternate versions of the program, if they
34 | receive widespread use, become available for other developers to
35 | incorporate. Many developers of free software are heartened and
36 | encouraged by the resulting cooperation. However, in the case of
37 | software used on network servers, this result may fail to come about.
38 | The GNU General Public License permits making a modified version and
39 | letting the public access it on a server without ever releasing its
40 | source code to the public.
41 |
42 | The GNU Affero General Public License is designed specifically to
43 | ensure that, in such cases, the modified source code becomes available
44 | to the community. It requires the operator of a network server to
45 | provide the source code of the modified version running there to the
46 | users of that server. Therefore, public use of a modified version, on
47 | a publicly accessible server, gives the public access to the source
48 | code of the modified version.
49 |
50 | An older license, called the Affero General Public License and
51 | published by Affero, was designed to accomplish similar goals. This is
52 | a different license, not a version of the Affero GPL, but Affero has
53 | released a new version of the Affero GPL which permits relicensing under
54 | this license.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | TERMS AND CONDITIONS
60 |
61 | 0. Definitions.
62 |
63 | "This License" refers to version 3 of the GNU Affero General Public License.
64 |
65 | "Copyright" also means copyright-like laws that apply to other kinds of
66 | works, such as semiconductor masks.
67 |
68 | "The Program" refers to any copyrightable work licensed under this
69 | License. Each licensee is addressed as "you". "Licensees" and
70 | "recipients" may be individuals or organizations.
71 |
72 | To "modify" a work means to copy from or adapt all or part of the work
73 | in a fashion requiring copyright permission, other than the making of an
74 | exact copy. The resulting work is called a "modified version" of the
75 | earlier work or a work "based on" the earlier work.
76 |
77 | A "covered work" means either the unmodified Program or a work based
78 | on the Program.
79 |
80 | To "propagate" a work means to do anything with it that, without
81 | permission, would make you directly or secondarily liable for
82 | infringement under applicable copyright law, except executing it on a
83 | computer or modifying a private copy. Propagation includes copying,
84 | distribution (with or without modification), making available to the
85 | public, and in some countries other activities as well.
86 |
87 | To "convey" a work means any kind of propagation that enables other
88 | parties to make or receive copies. Mere interaction with a user through
89 | a computer network, with no transfer of a copy, is not conveying.
90 |
91 | An interactive user interface displays "Appropriate Legal Notices"
92 | to the extent that it includes a convenient and prominently visible
93 | feature that (1) displays an appropriate copyright notice, and (2)
94 | tells the user that there is no warranty for the work (except to the
95 | extent that warranties are provided), that licensees may convey the
96 | work under this License, and how to view a copy of this License. If
97 | the interface presents a list of user commands or options, such as a
98 | menu, a prominent item in the list meets this criterion.
99 |
100 | 1. Source Code.
101 |
102 | The "source code" for a work means the preferred form of the work
103 | for making modifications to it. "Object code" means any non-source
104 | form of a work.
105 |
106 | A "Standard Interface" means an interface that either is an official
107 | standard defined by a recognized standards body, or, in the case of
108 | interfaces specified for a particular programming language, one that
109 | is widely used among developers working in that language.
110 |
111 | The "System Libraries" of an executable work include anything, other
112 | than the work as a whole, that (a) is included in the normal form of
113 | packaging a Major Component, but which is not part of that Major
114 | Component, and (b) serves only to enable use of the work with that
115 | Major Component, or to implement a Standard Interface for which an
116 | implementation is available to the public in source code form. A
117 | "Major Component", in this context, means a major essential component
118 | (kernel, window system, and so on) of the specific operating system
119 | (if any) on which the executable work runs, or a compiler used to
120 | produce the work, or an object code interpreter used to run it.
121 |
122 | The "Corresponding Source" for a work in object code form means all
123 | the source code needed to generate, install, and (for an executable
124 | work) run the object code and to modify the work, including scripts to
125 | control those activities. However, it does not include the work's
126 | System Libraries, or general-purpose tools or generally available free
127 | programs which are used unmodified in performing those activities but
128 | which are not part of the work. For example, Corresponding Source
129 | includes interface definition files associated with source files for
130 | the work, and the source code for shared libraries and dynamically
131 | linked subprograms that the work is specifically designed to require,
132 | such as by intimate data communication or control flow between those
133 | subprograms and other parts of the work.
134 |
135 | The Corresponding Source need not include anything that users
136 | can regenerate automatically from other parts of the Corresponding
137 | Source.
138 |
139 | The Corresponding Source for a work in source code form is that
140 | same work.
141 |
142 | 2. Basic Permissions.
143 |
144 | All rights granted under this License are granted for the term of
145 | copyright on the Program, and are irrevocable provided the stated
146 | conditions are met. This License explicitly affirms your unlimited
147 | permission to run the unmodified Program. The output from running a
148 | covered work is covered by this License only if the output, given its
149 | content, constitutes a covered work. This License acknowledges your
150 | rights of fair use or other equivalent, as provided by copyright law.
151 |
152 | You may make, run and propagate covered works that you do not
153 | convey, without conditions so long as your license otherwise remains
154 | in force. You may convey covered works to others for the sole purpose
155 | of having them make modifications exclusively for you, or provide you
156 | with facilities for running those works, provided that you comply with
157 | the terms of this License in conveying all material for which you do
158 | not control copyright. Those thus making or running the covered works
159 | for you must do so exclusively on your behalf, under your direction
160 | and control, on terms that prohibit them from making any copies of
161 | your copyrighted material outside their relationship with you.
162 |
163 | Conveying under any other circumstances is permitted solely under
164 | the conditions stated below. Sublicensing is not allowed; section 10
165 | makes it unnecessary.
166 |
167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
168 |
169 | No covered work shall be deemed part of an effective technological
170 | measure under any applicable law fulfilling obligations under article
171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
172 | similar laws prohibiting or restricting circumvention of such
173 | measures.
174 |
175 | When you convey a covered work, you waive any legal power to forbid
176 | circumvention of technological measures to the extent such circumvention
177 | is effected by exercising rights under this License with respect to
178 | the covered work, and you disclaim any intention to limit operation or
179 | modification of the work as a means of enforcing, against the work's
180 | users, your or third parties' legal rights to forbid circumvention of
181 | technological measures.
182 |
183 | 4. Conveying Verbatim Copies.
184 |
185 | You may convey verbatim copies of the Program's source code as you
186 | receive it, in any medium, provided that you conspicuously and
187 | appropriately publish on each copy an appropriate copyright notice;
188 | keep intact all notices stating that this License and any
189 | non-permissive terms added in accord with section 7 apply to the code;
190 | keep intact all notices of the absence of any warranty; and give all
191 | recipients a copy of this License along with the Program.
192 |
193 | You may charge any price or no price for each copy that you convey,
194 | and you may offer support or warranty protection for a fee.
195 |
196 | 5. Conveying Modified Source Versions.
197 |
198 | You may convey a work based on the Program, or the modifications to
199 | produce it from the Program, in the form of source code under the
200 | terms of section 4, provided that you also meet all of these conditions:
201 |
202 | a) The work must carry prominent notices stating that you modified
203 | it, and giving a relevant date.
204 |
205 | b) The work must carry prominent notices stating that it is
206 | released under this License and any conditions added under section
207 | 7. This requirement modifies the requirement in section 4 to
208 | "keep intact all notices".
209 |
210 | c) You must license the entire work, as a whole, under this
211 | License to anyone who comes into possession of a copy. This
212 | License will therefore apply, along with any applicable section 7
213 | additional terms, to the whole of the work, and all its parts,
214 | regardless of how they are packaged. This License gives no
215 | permission to license the work in any other way, but it does not
216 | invalidate such permission if you have separately received it.
217 |
218 | d) If the work has interactive user interfaces, each must display
219 | Appropriate Legal Notices; however, if the Program has interactive
220 | interfaces that do not display Appropriate Legal Notices, your
221 | work need not make them do so.
222 |
223 | A compilation of a covered work with other separate and independent
224 | works, which are not by their nature extensions of the covered work,
225 | and which are not combined with it such as to form a larger program,
226 | in or on a volume of a storage or distribution medium, is called an
227 | "aggregate" if the compilation and its resulting copyright are not
228 | used to limit the access or legal rights of the compilation's users
229 | beyond what the individual works permit. Inclusion of a covered work
230 | in an aggregate does not cause this License to apply to the other
231 | parts of the aggregate.
232 |
233 | 6. Conveying Non-Source Forms.
234 |
235 | You may convey a covered work in object code form under the terms
236 | of sections 4 and 5, provided that you also convey the
237 | machine-readable Corresponding Source under the terms of this License,
238 | in one of these ways:
239 |
240 | a) Convey the object code in, or embodied in, a physical product
241 | (including a physical distribution medium), accompanied by the
242 | Corresponding Source fixed on a durable physical medium
243 | customarily used for software interchange.
244 |
245 | b) Convey the object code in, or embodied in, a physical product
246 | (including a physical distribution medium), accompanied by a
247 | written offer, valid for at least three years and valid for as
248 | long as you offer spare parts or customer support for that product
249 | model, to give anyone who possesses the object code either (1) a
250 | copy of the Corresponding Source for all the software in the
251 | product that is covered by this License, on a durable physical
252 | medium customarily used for software interchange, for a price no
253 | more than your reasonable cost of physically performing this
254 | conveying of source, or (2) access to copy the
255 | Corresponding Source from a network server at no charge.
256 |
257 | c) Convey individual copies of the object code with a copy of the
258 | written offer to provide the Corresponding Source. This
259 | alternative is allowed only occasionally and noncommercially, and
260 | only if you received the object code with such an offer, in accord
261 | with subsection 6b.
262 |
263 | d) Convey the object code by offering access from a designated
264 | place (gratis or for a charge), and offer equivalent access to the
265 | Corresponding Source in the same way through the same place at no
266 | further charge. You need not require recipients to copy the
267 | Corresponding Source along with the object code. If the place to
268 | copy the object code is a network server, the Corresponding Source
269 | may be on a different server (operated by you or a third party)
270 | that supports equivalent copying facilities, provided you maintain
271 | clear directions next to the object code saying where to find the
272 | Corresponding Source. Regardless of what server hosts the
273 | Corresponding Source, you remain obligated to ensure that it is
274 | available for as long as needed to satisfy these requirements.
275 |
276 | e) Convey the object code using peer-to-peer transmission, provided
277 | you inform other peers where the object code and Corresponding
278 | Source of the work are being offered to the general public at no
279 | charge under subsection 6d.
280 |
281 | A separable portion of the object code, whose source code is excluded
282 | from the Corresponding Source as a System Library, need not be
283 | included in conveying the object code work.
284 |
285 | A "User Product" is either (1) a "consumer product", which means any
286 | tangible personal property which is normally used for personal, family,
287 | or household purposes, or (2) anything designed or sold for incorporation
288 | into a dwelling. In determining whether a product is a consumer product,
289 | doubtful cases shall be resolved in favor of coverage. For a particular
290 | product received by a particular user, "normally used" refers to a
291 | typical or common use of that class of product, regardless of the status
292 | of the particular user or of the way in which the particular user
293 | actually uses, or expects or is expected to use, the product. A product
294 | is a consumer product regardless of whether the product has substantial
295 | commercial, industrial or non-consumer uses, unless such uses represent
296 | the only significant mode of use of the product.
297 |
298 | "Installation Information" for a User Product means any methods,
299 | procedures, authorization keys, or other information required to install
300 | and execute modified versions of a covered work in that User Product from
301 | a modified version of its Corresponding Source. The information must
302 | suffice to ensure that the continued functioning of the modified object
303 | code is in no case prevented or interfered with solely because
304 | modification has been made.
305 |
306 | If you convey an object code work under this section in, or with, or
307 | specifically for use in, a User Product, and the conveying occurs as
308 | part of a transaction in which the right of possession and use of the
309 | User Product is transferred to the recipient in perpetuity or for a
310 | fixed term (regardless of how the transaction is characterized), the
311 | Corresponding Source conveyed under this section must be accompanied
312 | by the Installation Information. But this requirement does not apply
313 | if neither you nor any third party retains the ability to install
314 | modified object code on the User Product (for example, the work has
315 | been installed in ROM).
316 |
317 | The requirement to provide Installation Information does not include a
318 | requirement to continue to provide support service, warranty, or updates
319 | for a work that has been modified or installed by the recipient, or for
320 | the User Product in which it has been modified or installed. Access to a
321 | network may be denied when the modification itself materially and
322 | adversely affects the operation of the network or violates the rules and
323 | protocols for communication across the network.
324 |
325 | Corresponding Source conveyed, and Installation Information provided,
326 | in accord with this section must be in a format that is publicly
327 | documented (and with an implementation available to the public in
328 | source code form), and must require no special password or key for
329 | unpacking, reading or copying.
330 |
331 | 7. Additional Terms.
332 |
333 | "Additional permissions" are terms that supplement the terms of this
334 | License by making exceptions from one or more of its conditions.
335 | Additional permissions that are applicable to the entire Program shall
336 | be treated as though they were included in this License, to the extent
337 | that they are valid under applicable law. If additional permissions
338 | apply only to part of the Program, that part may be used separately
339 | under those permissions, but the entire Program remains governed by
340 | this License without regard to the additional permissions.
341 |
342 | When you convey a copy of a covered work, you may at your option
343 | remove any additional permissions from that copy, or from any part of
344 | it. (Additional permissions may be written to require their own
345 | removal in certain cases when you modify the work.) You may place
346 | additional permissions on material, added by you to a covered work,
347 | for which you have or can give appropriate copyright permission.
348 |
349 | Notwithstanding any other provision of this License, for material you
350 | add to a covered work, you may (if authorized by the copyright holders of
351 | that material) supplement the terms of this License with terms:
352 |
353 | a) Disclaiming warranty or limiting liability differently from the
354 | terms of sections 15 and 16 of this License; or
355 |
356 | b) Requiring preservation of specified reasonable legal notices or
357 | author attributions in that material or in the Appropriate Legal
358 | Notices displayed by works containing it; or
359 |
360 | c) Prohibiting misrepresentation of the origin of that material, or
361 | requiring that modified versions of such material be marked in
362 | reasonable ways as different from the original version; or
363 |
364 | d) Limiting the use for publicity purposes of names of licensors or
365 | authors of the material; or
366 |
367 | e) Declining to grant rights under trademark law for use of some
368 | trade names, trademarks, or service marks; or
369 |
370 | f) Requiring indemnification of licensors and authors of that
371 | material by anyone who conveys the material (or modified versions of
372 | it) with contractual assumptions of liability to the recipient, for
373 | any liability that these contractual assumptions directly impose on
374 | those licensors and authors.
375 |
376 | All other non-permissive additional terms are considered "further
377 | restrictions" within the meaning of section 10. If the Program as you
378 | received it, or any part of it, contains a notice stating that it is
379 | governed by this License along with a term that is a further
380 | restriction, you may remove that term. If a license document contains
381 | a further restriction but permits relicensing or conveying under this
382 | License, you may add to a covered work material governed by the terms
383 | of that license document, provided that the further restriction does
384 | not survive such relicensing or conveying.
385 |
386 | If you add terms to a covered work in accord with this section, you
387 | must place, in the relevant source files, a statement of the
388 | additional terms that apply to those files, or a notice indicating
389 | where to find the applicable terms.
390 |
391 | Additional terms, permissive or non-permissive, may be stated in the
392 | form of a separately written license, or stated as exceptions;
393 | the above requirements apply either way.
394 |
395 | 8. Termination.
396 |
397 | You may not propagate or modify a covered work except as expressly
398 | provided under this License. Any attempt otherwise to propagate or
399 | modify it is void, and will automatically terminate your rights under
400 | this License (including any patent licenses granted under the third
401 | paragraph of section 11).
402 |
403 | However, if you cease all violation of this License, then your
404 | license from a particular copyright holder is reinstated (a)
405 | provisionally, unless and until the copyright holder explicitly and
406 | finally terminates your license, and (b) permanently, if the copyright
407 | holder fails to notify you of the violation by some reasonable means
408 | prior to 60 days after the cessation.
409 |
410 | Moreover, your license from a particular copyright holder is
411 | reinstated permanently if the copyright holder notifies you of the
412 | violation by some reasonable means, this is the first time you have
413 | received notice of violation of this License (for any work) from that
414 | copyright holder, and you cure the violation prior to 30 days after
415 | your receipt of the notice.
416 |
417 | Termination of your rights under this section does not terminate the
418 | licenses of parties who have received copies or rights from you under
419 | this License. If your rights have been terminated and not permanently
420 | reinstated, you do not qualify to receive new licenses for the same
421 | material under section 10.
422 |
423 | 9. Acceptance Not Required for Having Copies.
424 |
425 | You are not required to accept this License in order to receive or
426 | run a copy of the Program. Ancillary propagation of a covered work
427 | occurring solely as a consequence of using peer-to-peer transmission
428 | to receive a copy likewise does not require acceptance. However,
429 | nothing other than this License grants you permission to propagate or
430 | modify any covered work. These actions infringe copyright if you do
431 | not accept this License. Therefore, by modifying or propagating a
432 | covered work, you indicate your acceptance of this License to do so.
433 |
434 | 10. Automatic Licensing of Downstream Recipients.
435 |
436 | Each time you convey a covered work, the recipient automatically
437 | receives a license from the original licensors, to run, modify and
438 | propagate that work, subject to this License. You are not responsible
439 | for enforcing compliance by third parties with this License.
440 |
441 | An "entity transaction" is a transaction transferring control of an
442 | organization, or substantially all assets of one, or subdividing an
443 | organization, or merging organizations. If propagation of a covered
444 | work results from an entity transaction, each party to that
445 | transaction who receives a copy of the work also receives whatever
446 | licenses to the work the party's predecessor in interest had or could
447 | give under the previous paragraph, plus a right to possession of the
448 | Corresponding Source of the work from the predecessor in interest, if
449 | the predecessor has it or can get it with reasonable efforts.
450 |
451 | You may not impose any further restrictions on the exercise of the
452 | rights granted or affirmed under this License. For example, you may
453 | not impose a license fee, royalty, or other charge for exercise of
454 | rights granted under this License, and you may not initiate litigation
455 | (including a cross-claim or counterclaim in a lawsuit) alleging that
456 | any patent claim is infringed by making, using, selling, offering for
457 | sale, or importing the Program or any portion of it.
458 |
459 | 11. Patents.
460 |
461 | A "contributor" is a copyright holder who authorizes use under this
462 | License of the Program or a work on which the Program is based. The
463 | work thus licensed is called the contributor's "contributor version".
464 |
465 | A contributor's "essential patent claims" are all patent claims
466 | owned or controlled by the contributor, whether already acquired or
467 | hereafter acquired, that would be infringed by some manner, permitted
468 | by this License, of making, using, or selling its contributor version,
469 | but do not include claims that would be infringed only as a
470 | consequence of further modification of the contributor version. For
471 | purposes of this definition, "control" includes the right to grant
472 | patent sublicenses in a manner consistent with the requirements of
473 | this License.
474 |
475 | Each contributor grants you a non-exclusive, worldwide, royalty-free
476 | patent license under the contributor's essential patent claims, to
477 | make, use, sell, offer for sale, import and otherwise run, modify and
478 | propagate the contents of its contributor version.
479 |
480 | In the following three paragraphs, a "patent license" is any express
481 | agreement or commitment, however denominated, not to enforce a patent
482 | (such as an express permission to practice a patent or covenant not to
483 | sue for patent infringement). To "grant" such a patent license to a
484 | party means to make such an agreement or commitment not to enforce a
485 | patent against the party.
486 |
487 | If you convey a covered work, knowingly relying on a patent license,
488 | and the Corresponding Source of the work is not available for anyone
489 | to copy, free of charge and under the terms of this License, through a
490 | publicly available network server or other readily accessible means,
491 | then you must either (1) cause the Corresponding Source to be so
492 | available, or (2) arrange to deprive yourself of the benefit of the
493 | patent license for this particular work, or (3) arrange, in a manner
494 | consistent with the requirements of this License, to extend the patent
495 | license to downstream recipients. "Knowingly relying" means you have
496 | actual knowledge that, but for the patent license, your conveying the
497 | covered work in a country, or your recipient's use of the covered work
498 | in a country, would infringe one or more identifiable patents in that
499 | country that you have reason to believe are valid.
500 |
501 | If, pursuant to or in connection with a single transaction or
502 | arrangement, you convey, or propagate by procuring conveyance of, a
503 | covered work, and grant a patent license to some of the parties
504 | receiving the covered work authorizing them to use, propagate, modify
505 | or convey a specific copy of the covered work, then the patent license
506 | you grant is automatically extended to all recipients of the covered
507 | work and works based on it.
508 |
509 | A patent license is "discriminatory" if it does not include within
510 | the scope of its coverage, prohibits the exercise of, or is
511 | conditioned on the non-exercise of one or more of the rights that are
512 | specifically granted under this License. You may not convey a covered
513 | work if you are a party to an arrangement with a third party that is
514 | in the business of distributing software, under which you make payment
515 | to the third party based on the extent of your activity of conveying
516 | the work, and under which the third party grants, to any of the
517 | parties who would receive the covered work from you, a discriminatory
518 | patent license (a) in connection with copies of the covered work
519 | conveyed by you (or copies made from those copies), or (b) primarily
520 | for and in connection with specific products or compilations that
521 | contain the covered work, unless you entered into that arrangement,
522 | or that patent license was granted, prior to 28 March 2007.
523 |
524 | Nothing in this License shall be construed as excluding or limiting
525 | any implied license or other defenses to infringement that may
526 | otherwise be available to you under applicable patent law.
527 |
528 | 12. No Surrender of Others' Freedom.
529 |
530 | If conditions are imposed on you (whether by court order, agreement or
531 | otherwise) that contradict the conditions of this License, they do not
532 | excuse you from the conditions of this License. If you cannot convey a
533 | covered work so as to satisfy simultaneously your obligations under this
534 | License and any other pertinent obligations, then as a consequence you may
535 | not convey it at all. For example, if you agree to terms that obligate you
536 | to collect a royalty for further conveying from those to whom you convey
537 | the Program, the only way you could satisfy both those terms and this
538 | License would be to refrain entirely from conveying the Program.
539 |
540 | 13. Remote Network Interaction; Use with the GNU General Public License.
541 |
542 | Notwithstanding any other provision of this License, if you modify the
543 | Program, your modified version must prominently offer all users
544 | interacting with it remotely through a computer network (if your version
545 | supports such interaction) an opportunity to receive the Corresponding
546 | Source of your version by providing access to the Corresponding Source
547 | from a network server at no charge, through some standard or customary
548 | means of facilitating copying of software. This Corresponding Source
549 | shall include the Corresponding Source for any work covered by version 3
550 | of the GNU General Public License that is incorporated pursuant to the
551 | following paragraph.
552 |
553 | Notwithstanding any other provision of this License, you have
554 | permission to link or combine any covered work with a work licensed
555 | under version 3 of the GNU General Public License into a single
556 | combined work, and to convey the resulting work. The terms of this
557 | License will continue to apply to the part which is the covered work,
558 | but the work with which it is combined will remain governed by version
559 | 3 of the GNU General Public License.
560 |
561 | 14. Revised Versions of this License.
562 |
563 | The Free Software Foundation may publish revised and/or new versions of
564 | the GNU Affero General Public License from time to time. Such new versions
565 | will be similar in spirit to the present version, but may differ in detail to
566 | address new problems or concerns.
567 |
568 | Each version is given a distinguishing version number. If the
569 | Program specifies that a certain numbered version of the GNU Affero General
570 | Public License "or any later version" applies to it, you have the
571 | option of following the terms and conditions either of that numbered
572 | version or of any later version published by the Free Software
573 | Foundation. If the Program does not specify a version number of the
574 | GNU Affero General Public License, you may choose any version ever published
575 | by the Free Software Foundation.
576 |
577 | If the Program specifies that a proxy can decide which future
578 | versions of the GNU Affero General Public License can be used, that proxy's
579 | public statement of acceptance of a version permanently authorizes you
580 | to choose that version for the Program.
581 |
582 | Later license versions may give you additional or different
583 | permissions. However, no additional obligations are imposed on any
584 | author or copyright holder as a result of your choosing to follow a
585 | later version.
586 |
587 | 15. Disclaimer of Warranty.
588 |
589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
597 |
598 | 16. Limitation of Liability.
599 |
600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
608 | SUCH DAMAGES.
609 |
610 | 17. Interpretation of Sections 15 and 16.
611 |
612 | If the disclaimer of warranty and limitation of liability provided
613 | above cannot be given local legal effect according to their terms,
614 | reviewing courts shall apply local law that most closely approximates
615 | an absolute waiver of all civil liability in connection with the
616 | Program, unless a warranty or assumption of liability accompanies a
617 | copy of the Program in return for a fee.
618 |
619 | END OF TERMS AND CONDITIONS
620 |
621 | How to Apply These Terms to Your New Programs
622 |
623 | If you develop a new program, and you want it to be of the greatest
624 | possible use to the public, the best way to achieve this is to make it
625 | free software which everyone can redistribute and change under these terms.
626 |
627 | To do so, attach the following notices to the program. It is safest
628 | to attach them to the start of each source file to most effectively
629 | state the exclusion of warranty; and each file should have at least
630 | the "copyright" line and a pointer to where the full notice is found.
631 |
632 |
633 | Copyright (C)
634 |
635 | This program is free software: you can redistribute it and/or modify
636 | it under the terms of the GNU Affero General Public License as published by
637 | the Free Software Foundation, either version 3 of the License, or
638 | (at your option) any later version.
639 |
640 | This program is distributed in the hope that it will be useful,
641 | but WITHOUT ANY WARRANTY; without even the implied warranty of
642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
643 | GNU Affero General Public License for more details.
644 |
645 | You should have received a copy of the GNU Affero General Public License
646 | along with this program. If not, see .
647 |
648 | Also add information on how to contact you by electronic and paper mail.
649 |
650 | If your software can interact with users remotely through a computer
651 | network, you should also make sure that it provides a way for users to
652 | get its source. For example, if your program is a web application, its
653 | interface could display a "Source" link that leads users to an archive
654 | of the code. There are many ways you could offer source, and different
655 | solutions will be better for different programs; see section 13 for the
656 | specific requirements.
657 |
658 | You should also get your employer (if you work as a programmer) or school,
659 | if any, to sign a "copyright disclaimer" for the program, if necessary.
660 | For more information on this, and how to apply and follow the GNU AGPL, see
661 | .
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | # Capybara
4 | Capybara is a [Mastodon](https://github.com/tootsuite/mastodon) clone - it will function practically identically to
5 | Mastodon, both under the hood and through its exposed APIs.
6 |
7 | ## Why?
8 | For fun, and because although I love Eugen's work, I'm wondering if putting the backend in Go might make things
9 | go faster.
10 |
11 | ## How?
12 | All of the code will be designed independently of Mastodon, but the underlying schema and interface (including the
13 | database layout and API route) will be, for compatibility and cleanliness purposes, identical to the best of my ability.
14 |
15 | ## Development/Deployment
16 | Currently, this project is just barely getting started, so
17 | I have no advice or recommendations aside from "this isn't
18 | even close to working."
19 |
20 | ## License
21 | Since Capybara is derivative, this will include two license notices - one for Capybara's side of the code (the
22 | application itself) and one for the API/database design (from Mastodon). Most of the credit should go to Eugen and
23 | the beautiful people working on Mastodon - this is just a tribute.
24 |
25 | ---
26 | ### Capybara
27 | Copyight (C) 2018 CalmBit.
28 |
29 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General
30 | Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
31 | any later version.
32 |
33 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
34 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
35 | details.
36 |
37 | You should have received a copy of the GNU Affero General Public License along with this program. If not,
38 | see https://www.gnu.org/licenses/.
39 |
40 | ---
41 | ### Mastodon
42 |
43 |
44 | Copyright (C) 2016-2018 Eugen Rochko & other Mastodon contributors (see AUTHORS.md)
45 |
46 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
47 |
48 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
49 |
50 | You should have received a copy of the GNU Affero General Public License along with this program. If not, see https://www.gnu.org/licenses/.
51 |
52 | ---
53 |
--------------------------------------------------------------------------------
/capybara.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/capybara_transparent.svg:
--------------------------------------------------------------------------------
1 |
2 |
102 |
--------------------------------------------------------------------------------
/config/config.example.yml:
--------------------------------------------------------------------------------
1 | registrationsOpen: true
2 | url: capybara.dev
3 | useTLS: false
4 | tlsCert: /etc/letsencrypt/...
5 | tlsKey: /etc/letsencrypt/...
--------------------------------------------------------------------------------
/config/database.example.yml:
--------------------------------------------------------------------------------
1 | development:
2 | dialect: "postgres"
3 | database: "your_db_development"
4 | host: "localhost"
5 | port: "5432"
6 | user: "postgres"
7 | password: "postgres"
8 |
9 | test:
10 | dialect: "mysql"
11 | database: "your_db_test"
12 | host: "localhost"
13 | port: "3306"
14 | user: "root"
15 | password: "root"
16 |
17 | staging:
18 | dialect: "sqlite3"
19 | database: "./staging.sqlite"
20 |
21 | production:
22 | dialect: "postgres"
23 | url: {{ env "DATABASE_URL" }}
--------------------------------------------------------------------------------
/controllers/about_controller.go:
--------------------------------------------------------------------------------
1 | package controllers
2 |
3 | import (
4 | "github.com/CalmBit/capybara/middleware"
5 | "github.com/kataras/iris"
6 | "github.com/kataras/iris/mvc"
7 | )
8 |
9 | type AboutController struct{}
10 |
11 | func (a *AboutController) BeforeActivation(b mvc.BeforeActivation) {
12 | }
13 |
14 | func (a *AboutController) BeginRequest(ctx iris.Context) {
15 | }
16 |
17 | func (a *AboutController) EndRequest(ctx iris.Context) {
18 | }
19 |
20 | func (a *AboutController) Get(ctx iris.Context) {
21 | s := middleware.GetSession(ctx)
22 | if s.Get("username") != nil {
23 | ctx.ViewData("username", s.Get("username"))
24 | }
25 | ctx.View("about.pug")
26 | }
27 |
--------------------------------------------------------------------------------
/controllers/account_controller.go:
--------------------------------------------------------------------------------
1 | package controllers
2 |
3 | import (
4 | "fmt"
5 | "github.com/CalmBit/capybara/models"
6 | "github.com/CalmBit/capybara/serializers"
7 | "github.com/gobuffalo/pop"
8 | "github.com/kataras/iris"
9 | "github.com/kataras/iris/mvc"
10 | "reflect"
11 | _ "time"
12 | )
13 |
14 | // temporary
15 | var typeName = "Account"
16 |
17 | var APIAccountSerializer = serializers.ConstructSerializer(func(v interface{}) error {
18 | if reflect.TypeOf(v).Name() == typeName {
19 | return nil
20 | } else {
21 | return fmt.Errorf("bad serialize on type %s expecting type %s", reflect.TypeOf(v).Name(), typeName)
22 | }
23 | }).AddFieldAsString("ID").AddField("Username").AddMethod("Acct", "acct").AddField("DisplayName").AddField("Locked").AddField("CreatedAt").AddField("Note").AddField("URL").AddMethod("Avatar", "avatar").AddMethod("AvatarStatic", "avatar_static").AddMethod("Header", "header").AddMethod("HeaderStatic", "header_static").AddField("FollowersCount").AddField("FollowingCount").AddField("StatusesCount")
24 |
25 | type AccountController struct{}
26 |
27 | func (a *AccountController) BeforeActivation(b mvc.BeforeActivation) {
28 | }
29 |
30 | func (a *AccountController) BeginRequest(ctx iris.Context) {
31 | }
32 |
33 | func (a *AccountController) EndRequest(ctx iris.Context) {
34 | }
35 |
36 | func (a *AccountController) GetBy(id int64) mvc.Result {
37 | tx, err := pop.Connect("development")
38 | if err != nil {
39 | return mvc.Response{
40 | ContentType: "application/json",
41 | Content: []byte(fmt.Sprintf("{\"error\": \"%s\"}", err.Error())),
42 | }
43 | }
44 | var account models.Account
45 | err = tx.Find(&account, id)
46 | if err != nil {
47 | return mvc.Response{
48 | ContentType: "application/json",
49 | Content: []byte(fmt.Sprintf("{\"error\": \"%s\"}", err.Error())),
50 | }
51 | }
52 | buf, err := APIAccountSerializer.SerializeToJSON(account)
53 | if err != nil {
54 | return mvc.Response{
55 | ContentType: "application/json",
56 | Content: []byte(fmt.Sprintf("{\"error\": \"%s\"}", err.Error())),
57 | }
58 | }
59 | return mvc.Response{
60 | ContentType: "application/json",
61 | Content: buf,
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/controllers/login_controller.go:
--------------------------------------------------------------------------------
1 | package controllers
2 |
3 | import (
4 | "encoding/base64"
5 | "fmt"
6 | "github.com/CalmBit/capybara/middleware"
7 | "github.com/CalmBit/capybara/models"
8 | "github.com/gobuffalo/pop"
9 | "github.com/kataras/iris"
10 | "github.com/kataras/iris/mvc"
11 | "github.com/sec51/twofactor"
12 | "golang.org/x/crypto/bcrypt"
13 | "html"
14 | )
15 |
16 | type LoginController struct{}
17 |
18 | func (l *LoginController) BeforeActivation(b mvc.BeforeActivation) {
19 | }
20 |
21 | func (l *LoginController) BeginRequest(ctx iris.Context) {
22 | }
23 |
24 | func (l *LoginController) EndRequest(ctx iris.Context) {
25 | }
26 |
27 | func (l *LoginController) Get(ctx iris.Context) mvc.Result {
28 | s := middleware.GetSession(ctx)
29 | if s.Get("authenticated") != nil {
30 | return mvc.Response{
31 | Path: "/",
32 | }
33 | }
34 | return mvc.View{
35 | Name: "login.pug",
36 | }
37 | }
38 |
39 | func (l *LoginController) Post(ctx iris.Context) mvc.Result {
40 | s := middleware.GetSession(ctx)
41 | email := html.EscapeString(ctx.FormValue("email"))
42 |
43 | tx, err := pop.Connect("development")
44 | if err != nil {
45 | s.SetFlash("error", err.Error())
46 | return mvc.Response{
47 | Path: "/login",
48 | }
49 | }
50 |
51 | var user models.User
52 | query := tx.Where(fmt.Sprintf("email = '%s'", email))
53 | err = query.First(&user)
54 | if err != nil {
55 | s.SetFlash("error", "Invalid username or password!")
56 | return mvc.Response{
57 | Path: "/login",
58 | }
59 | }
60 | err = bcrypt.CompareHashAndPassword([]byte(user.EncryptedPassword), []byte(ctx.FormValue("password")))
61 | if err != nil {
62 | s.SetFlash("error", "Invalid username or password!")
63 | return mvc.Response{
64 | Path: "/login",
65 | }
66 | } else {
67 | s.Set("user_id", user.ID)
68 | s.Set("pass_confirmed", true)
69 | if user.OtpRequiredForLogin {
70 | return mvc.Response{
71 | Path: "/otp/login",
72 | }
73 | }
74 | var acct models.Account
75 | err = tx.Find(&acct, user.AccountID)
76 | if err != nil {
77 | s.SetFlash("error", err.Error())
78 | s.Delete("user_id")
79 | s.Delete("pass_confirmed")
80 | return mvc.Response{
81 | Path: "/login",
82 | }
83 | }
84 | s.Set("account_id", acct.ID)
85 | s.Set("username", acct.Username)
86 | s.Set("email", user.Email)
87 | s.Set("display_name", acct.DisplayName)
88 | s.Set("authenticated", true)
89 | return mvc.Response{
90 | Path: "/",
91 | }
92 | }
93 | }
94 |
95 | func (l *LoginController) PostConfirm(ctx iris.Context) mvc.Result {
96 | s := middleware.GetSession(ctx)
97 |
98 | if !s.GetBooleanDefault("pass_confirmed", false) {
99 | s.SetFlash("error", "An error occurred. Please try again.")
100 | return mvc.Response{
101 | Path: "/login",
102 | }
103 | }
104 | id, err := s.GetInt64("user_id")
105 | if err != nil {
106 | s.SetFlash("error", err.Error())
107 | s.Delete("pass_confirmed")
108 | return mvc.Response{
109 | Path: "/login",
110 | }
111 | }
112 | tx, err := pop.Connect("development")
113 | if err != nil {
114 | s.SetFlash("error", err.Error())
115 | s.Delete("pass_confirmed")
116 | s.Delete("user_id")
117 | return mvc.Response{
118 | Path: "/login",
119 | }
120 | }
121 | var user models.User
122 | tx.Find(&user, id)
123 | unmarshalSecret := make([]byte, 256)
124 | n, err := base64.StdEncoding.Decode(unmarshalSecret, []byte(user.EncryptedOtpSecret))
125 | unmarshalSecret = unmarshalSecret[:n]
126 | otp, err := twofactor.TOTPFromBytes(unmarshalSecret, "capybara")
127 | if err != nil {
128 | s.SetFlash("error", err.Error())
129 | s.Delete("pass_confirmed")
130 | s.Delete("user_id")
131 | return mvc.Response{
132 | Path: "/login",
133 | }
134 | }
135 | err = otp.Validate(ctx.FormValue("code_confirm"))
136 | if err != nil {
137 | s.SetFlash("error", err.Error())
138 | return mvc.Response{
139 | Path: "/otp/login",
140 | }
141 | }
142 | var acct models.Account
143 | err = tx.Find(&acct, user.AccountID)
144 | if err != nil {
145 | s.SetFlash("error", err.Error())
146 | s.Delete("pass_confirmed")
147 | s.Delete("user_id")
148 | return mvc.Response{
149 | Path: "/login",
150 | }
151 | }
152 | s.Set("user_id", user.ID)
153 | s.Set("account_id", acct.ID)
154 | s.Set("username", acct.Username)
155 | s.Set("email", user.Email)
156 | s.Set("display_name", acct.DisplayName)
157 | s.Set("authenticated", true)
158 | return mvc.Response{
159 | Path: "/",
160 | }
161 | }
162 |
--------------------------------------------------------------------------------
/controllers/logout_controller.go:
--------------------------------------------------------------------------------
1 | package controllers
2 |
3 | import (
4 | "github.com/CalmBit/capybara/middleware"
5 | "github.com/kataras/iris"
6 | "github.com/kataras/iris/mvc"
7 | )
8 |
9 | type LogoutController struct{}
10 |
11 | func (l *LogoutController) BeforeActivation(b mvc.BeforeActivation) {
12 | }
13 |
14 | func (l *LogoutController) BeginRequest(ctx iris.Context) {
15 | }
16 |
17 | func (l *LogoutController) EndRequest(ctx iris.Context) {
18 | }
19 |
20 | func (l *LogoutController) Post(ctx iris.Context) mvc.Result {
21 | s := middleware.GetSession(ctx)
22 |
23 | if s.Get("authenticated") == nil {
24 | s.SetFlash("error", "You need to be logged in to log out!")
25 | return mvc.Response{
26 | Path: "/login",
27 | }
28 | }
29 |
30 | middleware.KillSession(ctx)
31 |
32 | s = middleware.NewSession(ctx)
33 |
34 | s.SetFlash("success", "You have been logged out.")
35 |
36 | return mvc.Response{
37 | Path: "/about",
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/controllers/otp_controller.go:
--------------------------------------------------------------------------------
1 | package controllers
2 |
3 | import (
4 | "crypto"
5 | "encoding/base64"
6 | "fmt"
7 | "github.com/CalmBit/capybara/middleware"
8 | "github.com/CalmBit/capybara/models"
9 | "github.com/gobuffalo/pop"
10 | "github.com/kataras/iris"
11 | "github.com/kataras/iris/mvc"
12 | "github.com/sec51/twofactor"
13 | )
14 |
15 | type OTPController struct{}
16 |
17 | func (o *OTPController) BeforeActivation(b mvc.BeforeActivation) {
18 | }
19 |
20 | func (o *OTPController) BeginRequest(ctx iris.Context) {
21 | }
22 |
23 | func (o *OTPController) EndRequest(ctx iris.Context) {
24 | }
25 |
26 | func (o *OTPController) GetSettings(ctx iris.Context) {
27 | s := middleware.GetSession(ctx)
28 | if s.Get("authenticated") == nil {
29 | s.SetFlash("error", "You need to be logged in to do that.")
30 | ctx.Redirect("/login")
31 | } else {
32 | otp, err := twofactor.NewTOTP(s.GetString("email"), "capybara", crypto.SHA1, 6)
33 | if err != nil {
34 | s.SetFlash("error", "There was a problem processing your request.")
35 | ctx.Redirect("/about")
36 | } else {
37 | qrpng, err := otp.QR()
38 | if err != nil {
39 | s.SetFlash("error", "There was a problem processing the QR code.")
40 | ctx.Redirect("/about")
41 | } else {
42 | var qrbuffer = make([]byte, ((len(qrpng)+2)/3)*4)
43 | base64.StdEncoding.Encode(qrbuffer, qrpng)
44 | s.SetFlash("otp", otp)
45 | ctx.ViewData("qr_code", fmt.Sprintf("data:image/png;base64, %s", string(qrbuffer)))
46 | ctx.View("otp.pug")
47 | }
48 | }
49 |
50 | }
51 | }
52 |
53 | func (o *OTPController) GetLogin(ctx iris.Context) mvc.Result {
54 | s := middleware.GetSession(ctx)
55 | if s.Get("authenticated") != nil {
56 | return mvc.Response{
57 | Path: "/",
58 | }
59 | }
60 | if !s.GetBooleanDefault("pass_confirmed", false) {
61 | s.SetFlash("error", "An error occurred. Please try again.")
62 | return mvc.Response{
63 | Path: "/login",
64 | }
65 | }
66 | return mvc.View{
67 | Name: "otp_login.pug",
68 | }
69 |
70 | }
71 |
72 | func (o *OTPController) Post(ctx iris.Context) mvc.Result {
73 | s := middleware.GetSession(ctx)
74 | otp := s.GetFlash("otp").(*twofactor.Totp)
75 | err := otp.Validate(ctx.FormValue("code_confirm"))
76 | if err != nil {
77 | s.SetFlash("error", "There was a problem processing the confirmation code")
78 | return mvc.Response{
79 | Path: "/otp/settings",
80 | }
81 | }
82 | tx, err := pop.Connect("development")
83 | if err != nil {
84 | s.SetFlash("error", "The code was confirmed, but we had trouble storing it. Please try again.")
85 | return mvc.Response{
86 | Path: "/otp/settings",
87 | }
88 | }
89 | var user models.User
90 | id, err := s.GetInt64("user_id")
91 | if err != nil {
92 | s.SetFlash("error", "You need to be logged in to do that.")
93 | return mvc.Response{
94 | Path: "/login",
95 | }
96 | }
97 | tx.Find(&user, id)
98 | buf, err := otp.ToBytes()
99 | if err != nil {
100 | s.SetFlash("error", "Unable to serialize secret? (this is bad)")
101 | return mvc.Response{
102 | Path: "/otp/settings",
103 | }
104 | }
105 | bufencode := make([]byte, ((len(buf)+2)/3)*4)
106 | base64.StdEncoding.Encode(bufencode, buf)
107 | user.EncryptedOtpSecret = string(bufencode)
108 | user.OtpRequiredForLogin = true
109 | valid, err := tx.ValidateAndSave(&user)
110 | if valid.HasAny() {
111 | s.SetFlash("error", valid.Error())
112 | return mvc.Response{
113 | Path: "/otp/settings",
114 | }
115 | } else if err != nil {
116 | s.SetFlash("error", err.Error())
117 | return mvc.Response{
118 | Path: "/otp/settings",
119 | }
120 | }
121 | s.SetFlash("error", "Success!")
122 | return mvc.Response{
123 | Path: "/about",
124 | }
125 | }
126 |
--------------------------------------------------------------------------------
/controllers/public_controller.go:
--------------------------------------------------------------------------------
1 | package controllers
2 |
3 | import (
4 | "fmt"
5 | "github.com/CalmBit/capybara/models"
6 | "github.com/kataras/iris/mvc"
7 | "github.com/gobuffalo/pop"
8 | "github.com/gobuffalo/uuid"
9 | "github.com/kataras/iris"
10 | "github.com/CalmBit/capybara/middleware"
11 | )
12 |
13 | type PublicController struct{}
14 |
15 | func (a *PublicController) BeforeActivation(b mvc.BeforeActivation) {
16 | }
17 |
18 | func (a *PublicController) BeginRequest(ctx iris.Context) {
19 | }
20 |
21 | func (a *PublicController) EndRequest(ctx iris.Context) {
22 | }
23 |
24 | func (a *PublicController) Get(ctx iris.Context) mvc.Result {
25 | s := middleware.GetSession(ctx)
26 | if s.Get("authenticated") == nil {
27 | return mvc.Response{
28 | Path: "/about",
29 | }
30 | }
31 | return mvc.View{
32 | Name: "index.pug",
33 | }
34 | }
35 |
36 | func (a *PublicController) GetBy(ctx iris.Context, param string) mvc.Result {
37 | tx, err := pop.Connect("development")
38 | if err != nil {
39 | return mvc.Response{
40 | Code: 500,
41 | }
42 | }
43 | id, err := uuid.FromString(param)
44 | if err != nil {
45 | return mvc.Response{
46 | Code: 404,
47 | }
48 | }
49 | var account models.Account
50 | err = tx.Where(fmt.Sprintf("uuid = '%s'", id.String())).First(&account)
51 | if err != nil {
52 | return mvc.Response{
53 | Code: 404,
54 | }
55 | }
56 |
57 | if !account.Local() {
58 | return mvc.Response{
59 | Code: 404,
60 | }
61 | }
62 |
63 | ctx.ViewData("account", account)
64 |
65 | var statuses []models.Status
66 | err = tx.Where(fmt.Sprintf("account_id = %d ORDER BY created_at DESC", account.ID)).All(&statuses)
67 | if err != nil {
68 | return mvc.Response{
69 | Code: 500,
70 | Content: []byte(err.Error()),
71 | }
72 | }
73 |
74 | for i, status := range statuses {
75 | err = tx.Where(fmt.Sprintf("id = '%d'", status.AccountID)).First(&statuses[i].StatusAccount)
76 | if err != nil {
77 | fmt.Printf("%s", err.Error())
78 | } else {
79 | fmt.Printf("%s\n", status.StatusAccount.Username)
80 | }
81 | }
82 |
83 | fmt.Printf("%s\n", statuses[0].StatusAccount.Username)
84 |
85 | ctx.ViewData("statuses", statuses)
86 |
87 |
88 |
89 |
90 | return mvc.View{
91 | Name: "public_user.pug",
92 | }
93 | }
94 |
95 |
--------------------------------------------------------------------------------
/controllers/registration_controller.go:
--------------------------------------------------------------------------------
1 | package controllers
2 |
3 | import (
4 | "github.com/CalmBit/capybara/middleware"
5 | "github.com/CalmBit/capybara/models"
6 | "github.com/gobuffalo/pop"
7 | "github.com/kataras/iris"
8 | "github.com/kataras/iris/mvc"
9 | "golang.org/x/crypto/bcrypt"
10 | "fmt"
11 | )
12 |
13 | type RegistrationController struct{}
14 |
15 | func (a *RegistrationController) BeforeActivation(b mvc.BeforeActivation) {
16 | }
17 |
18 | func (a *RegistrationController) BeginRequest(ctx iris.Context) {
19 | }
20 |
21 | func (a *RegistrationController) EndRequest(ctx iris.Context) {
22 | }
23 |
24 | func (a *RegistrationController) Post(ctx iris.Context) mvc.Result {
25 | s := middleware.GetSession(ctx)
26 | if ctx.FormValue("password") == ctx.FormValue("password_confirm") {
27 | passhash, err := bcrypt.GenerateFromPassword([]byte(ctx.FormValue("password")), 14)
28 | if err != nil {
29 | s.SetFlash("error", err.Error())
30 | return mvc.Response{
31 | Path: "/about",
32 | }
33 | }
34 | newUser := models.NewUser()
35 | newUser.Email = ctx.FormValue("email")
36 | newUser.EncryptedPassword = string(passhash)
37 | tx, err := pop.Connect("development")
38 | if err != nil {
39 | s.SetFlash("error", err.Error())
40 | return mvc.Response{
41 | Path: "/about",
42 | }
43 | }
44 | acct, err := newUser.CreateAccount(tx, ctx.FormValue("username"))
45 | if err != nil {
46 | s.SetFlash("error", err.Error())
47 | return mvc.Response{
48 | Path: "/about",
49 | }
50 | }
51 | validate, err := tx.ValidateAndCreate(&newUser)
52 | if validate.HasAny() {
53 | s.SetFlash("error", validate.Error())
54 | return mvc.Response{
55 | Path: "/about",
56 | }
57 | } else if err != nil {
58 | s.SetFlash("error", err.Error())
59 | return mvc.Response{
60 | Path: "/about",
61 | }
62 | }
63 |
64 | return mvc.Response{
65 | Path: fmt.Sprintf("/%s", acct.UUID.String()),
66 | }
67 | }
68 |
69 | s.SetFlash("error", "Passwords did not match!")
70 | return mvc.Response{
71 | Path: "/about",
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/go.mod:
--------------------------------------------------------------------------------
1 | module github.com/CalmBit/capybara
2 |
3 | go 1.12
4 |
5 | require (
6 | github.com/Joker/jade v1.0.0 // indirect
7 | github.com/Shopify/goreferrer v0.0.0-20181106222321-ec9c9a553398 // indirect
8 | github.com/aymerick/raymond v2.0.2+incompatible // indirect
9 | github.com/cockroachdb/cockroach-go v0.0.0-20181001143604-e0a95dfd547c // indirect
10 | github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385 // indirect
11 | github.com/fatih/color v1.7.0 // indirect
12 | github.com/flosch/pongo2 v0.0.0-20190707114632-bbf5a6c351f4 // indirect
13 | github.com/gobuffalo/fizz v1.9.2 // indirect
14 | github.com/gobuffalo/makr v1.2.0 // indirect
15 | github.com/gobuffalo/nulls v0.1.0 // indirect
16 | github.com/gobuffalo/pop v4.11.2+incompatible
17 | github.com/gobuffalo/uuid v2.0.5+incompatible
18 | github.com/gobuffalo/validate v2.0.3+incompatible
19 | github.com/gomodule/redigo v2.0.0+incompatible // indirect
20 | github.com/iris-contrib/blackfriday v2.0.0+incompatible // indirect
21 | github.com/iris-contrib/formBinder v0.0.0-20190104093907-fbd5963f41e1 // indirect
22 | github.com/iris-contrib/go.uuid v2.0.0+incompatible // indirect
23 | github.com/jackc/pgx v3.5.0+incompatible // indirect
24 | github.com/json-iterator/go v1.1.6 // indirect
25 | github.com/kataras/golog v0.0.0-20190624001437-99c81de45f40 // indirect
26 | github.com/kataras/iris v11.1.1+incompatible
27 | github.com/kataras/pio v0.0.0-20190103105442-ea782b38602d // indirect
28 | github.com/klauspost/compress v1.7.2 // indirect
29 | github.com/klauspost/cpuid v1.2.1 // indirect
30 | github.com/lib/pq v1.1.1 // indirect
31 | github.com/mattn/go-colorable v0.1.2 // indirect
32 | github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect
33 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
34 | github.com/modern-go/reflect2 v1.0.1 // indirect
35 | github.com/ryanuber/columnize v2.1.0+incompatible // indirect
36 | github.com/sec51/convert v0.0.0-20190309075348-ebe586d87951 // indirect
37 | github.com/sec51/cryptoengine v0.0.0-20180911112225-2306d105a49e // indirect
38 | github.com/sec51/gf256 v0.0.0-20160126143050-2454accbeb9e // indirect
39 | github.com/sec51/qrcode v0.0.0-20160126144534-b7779abbcaf1 // indirect
40 | github.com/sec51/twofactor v1.0.0
41 | github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
42 | github.com/sirupsen/logrus v1.4.2
43 | github.com/x-cray/logrus-prefixed-formatter v0.5.2
44 | golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4
45 | gopkg.in/yaml.v2 v2.2.2
46 | )
47 |
--------------------------------------------------------------------------------
/go.sum:
--------------------------------------------------------------------------------
1 | github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
2 | github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
3 | github.com/Joker/hpp v0.0.0-20180418125244-6893e659854a/go.mod h1:MzD2WMdSxvbHw5fM/OXOFily/lipJWRc9C1px0Mt0ZE=
4 | github.com/Joker/jade v1.0.0 h1:lOCEPvTAtWfLpSZYMOv/g44MGQFAolbKh2khHHGu0Kc=
5 | github.com/Joker/jade v1.0.0/go.mod h1:efZIdO0py/LtcJRSa/j2WEklMSAw84WV0zZVMxNToB8=
6 | github.com/Shopify/goreferrer v0.0.0-20181106222321-ec9c9a553398 h1:WDC6ySpJzbxGWFh4aMxFFC28wwGp5pEuoTtvA4q/qQ4=
7 | github.com/Shopify/goreferrer v0.0.0-20181106222321-ec9c9a553398/go.mod h1:a1uqRtAwp2Xwc6WNPJEufxJ7fx3npB4UV/JOLmbu5I0=
8 | github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
9 | github.com/aymerick/raymond v2.0.2+incompatible h1:VEp3GpgdAnv9B2GFyTvqgcKvY+mfKMjPOA3SbKLtnU0=
10 | github.com/aymerick/raymond v2.0.2+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g=
11 | github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdnnjpJbkM4JQ=
12 | github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
13 | github.com/cockroachdb/cockroach-go v0.0.0-20181001143604-e0a95dfd547c h1:2zRrJWIt/f9c9HhNHAgrRgq0San5gRRUJTBXLkchal0=
14 | github.com/cockroachdb/cockroach-go v0.0.0-20181001143604-e0a95dfd547c/go.mod h1:XGLbWH/ujMcbPbhZq52Nv6UrCghb1yGn//133kEsvDk=
15 | github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
16 | github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
17 | github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
18 | github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
19 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
20 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
21 | github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385 h1:clC1lXBpe2kTj2VHdaIu9ajZQe4kcEY9j0NsnDDBZ3o=
22 | github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385/go.mod h1:0vRUJqYpeSZifjYj7uP3BG/gKcuzL9xWVV/Y+cK33KM=
23 | github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys=
24 | github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
25 | github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo=
26 | github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
27 | github.com/flosch/pongo2 v0.0.0-20190707114632-bbf5a6c351f4 h1:GY1+t5Dr9OKADM64SYnQjw/w99HMYvQ0A8/JoUkxVmc=
28 | github.com/flosch/pongo2 v0.0.0-20190707114632-bbf5a6c351f4/go.mod h1:T9YF2M40nIgbVgp3rreNmTged+9HrbNTIQf1PsaIiTA=
29 | github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
30 | github.com/go-check/check v0.0.0-20180628173108-788fd7840127/go.mod h1:9ES+weclKsC9YodN5RgxqK/VD9HM9JsCSh7rNhMZE98=
31 | github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
32 | github.com/go-sql-driver/mysql v1.4.1 h1:g24URVg0OFbNUTx9qqY1IRZ9D9z3iPyi5zKhQZpNwpA=
33 | github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
34 | github.com/gobuffalo/attrs v0.1.0/go.mod h1:fmNpaWyHM0tRm8gCZWKx8yY9fvaNLo2PyzBNSrBZ5Hw=
35 | github.com/gobuffalo/envy v1.6.5/go.mod h1:N+GkhhZ/93bGZc6ZKhJLP6+m+tCNPKwgSpH9kaifseQ=
36 | github.com/gobuffalo/envy v1.7.0 h1:GlXgaiBkmrYMHco6t4j7SacKO4XUjvh5pwXh0f4uxXU=
37 | github.com/gobuffalo/envy v1.7.0/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI=
38 | github.com/gobuffalo/fizz v1.9.2 h1:fms1l6NSJED8EhrhU6EPb0U5fcti7juIlrGCqU/Cspg=
39 | github.com/gobuffalo/fizz v1.9.2/go.mod h1:XJb7Do1keOPkaJnJ48OCjV+7ABQ7mbOqui2WfDobXTQ=
40 | github.com/gobuffalo/flect v0.1.5 h1:xpKq9ap8MbYfhuPCF0dBH854Gp9CxZjr/IocxELFflo=
41 | github.com/gobuffalo/flect v0.1.5/go.mod h1:W3K3X9ksuZfir8f/LrfVtWmCDQFfayuylOJ7sz/Fj80=
42 | github.com/gobuffalo/genny v0.2.0/go.mod h1:rWs4Z12d1Zbf19rlsn0nurr75KqhYp52EAGGxTbBhNk=
43 | github.com/gobuffalo/genny v0.3.0/go.mod h1:ywJ2CoXrTZj7rbS8HTbzv7uybnLKlsNSBhEQ+yFI3E8=
44 | github.com/gobuffalo/github_flavored_markdown v1.0.7/go.mod h1:w93Pd9Lz6LvyQXEG6DktTPHkOtCbr+arAD5mkwMzXLI=
45 | github.com/gobuffalo/github_flavored_markdown v1.1.0 h1:8Zzj4fTRl/OP2R7sGerzSf6g2nEJnaBEJe7UAOiEvbQ=
46 | github.com/gobuffalo/github_flavored_markdown v1.1.0/go.mod h1:TSpTKWcRTI0+v7W3x8dkSKMLJSUpuVitlptCkpeY8ic=
47 | github.com/gobuffalo/gogen v0.2.0/go.mod h1:V9QVDIxsgKNZs6L2IYiGR8datgMhB577vzTDqypH360=
48 | github.com/gobuffalo/helpers v0.2.2/go.mod h1:xYbzUdCUpVzLwLnqV8HIjT6hmG0Cs7YIBCJkNM597jw=
49 | github.com/gobuffalo/helpers v0.2.4 h1:K5pXrMiSn8qJpMuv/q853i+WI2o47wS8ehD6NGF0hkE=
50 | github.com/gobuffalo/helpers v0.2.4/go.mod h1:NX7v27yxPDOPTgUFYmJ5ow37EbxdoLraucOGvMNawyk=
51 | github.com/gobuffalo/logger v0.0.0-20190315122211-86e12af44bc2/go.mod h1:QdxcLw541hSGtBnhUc4gaNIXRjiDppFGaDqzbrBd3v8=
52 | github.com/gobuffalo/logger v1.0.0/go.mod h1:2zbswyIUa45I+c+FLXuWl9zSWEiVuthsk8ze5s8JvPs=
53 | github.com/gobuffalo/makr v1.2.0 h1:TA6ThoZEcq0F9FCrc/7xS1ycdCIL0K6Ux+5wmwYV7BY=
54 | github.com/gobuffalo/makr v1.2.0/go.mod h1:SFQUrDtwDpmQ6BxKJqxg0emc4KkNzzvUtAtnHiVK/QQ=
55 | github.com/gobuffalo/mapi v1.0.2/go.mod h1:4VAGh89y6rVOvm5A8fKFxYG+wIW6LO1FMTG9hnKStFc=
56 | github.com/gobuffalo/mapi v1.1.0/go.mod h1:pqQ1XAqvpy/JYtRwoieNps2yU8MFiMxBUpAm2FBtQ50=
57 | github.com/gobuffalo/nulls v0.1.0 h1:pR3SDzXyFcQrzyPreZj+OzNHSxI4DphSOFaQuidxrfw=
58 | github.com/gobuffalo/nulls v0.1.0/go.mod h1:/HRtuDRoVoN5fABk3J6jzZaGEdcIZEMs0qczj71eKZY=
59 | github.com/gobuffalo/packd v0.1.0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWeG2RIxq4=
60 | github.com/gobuffalo/packd v0.2.0/go.mod h1:k2CkHP3bjbqL2GwxwhxUy1DgnlbW644hkLC9iIUvZwY=
61 | github.com/gobuffalo/packd v0.3.0 h1:eMwymTkA1uXsqxS0Tpoop3Lc0u3kTfiMBE6nKtQU4g4=
62 | github.com/gobuffalo/packd v0.3.0/go.mod h1:zC7QkmNkYVGKPw4tHpBQ+ml7W/3tIebgeo1b36chA3Q=
63 | github.com/gobuffalo/packr/v2 v2.4.0/go.mod h1:ra341gygw9/61nSjAbfwcwh8IrYL4WmR4IsPkPBhQiY=
64 | github.com/gobuffalo/packr/v2 v2.5.2/go.mod h1:sgEE1xNZ6G0FNN5xn9pevVu4nywaxHvgup67xisti08=
65 | github.com/gobuffalo/plush v3.8.2+incompatible h1:EXtDf5L7TTwX8tEddtdHT+PT2lFerIKQm8Ye/M7O+54=
66 | github.com/gobuffalo/plush v3.8.2+incompatible/go.mod h1:rQ4zdtUUyZNqULlc6bqd5scsPfLKfT0+TGMChgduDvI=
67 | github.com/gobuffalo/plushgen v0.1.2/go.mod h1:3U71v6HWZpVER1nInTXeAwdoRNsRd4W8aeIa1Lyp+Bk=
68 | github.com/gobuffalo/pop v4.11.2+incompatible h1:yohroCWPJDiarrFtB79XrCiCK0MAu2dpzbXFFv3bnuM=
69 | github.com/gobuffalo/pop v4.11.2+incompatible/go.mod h1:DwBz3SD5SsHpTZiTubcsFWcVDpJWGsxjVjMPnkiThWg=
70 | github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754/go.mod h1:HhnNqWY95UYwwW3uSASeV7vtgYkT2t16hJgV3AEPUpw=
71 | github.com/gobuffalo/tags v2.1.0+incompatible h1:qQjj3n2RtHxfooqXQ4/A9SsEfZ7/7guv8cp/GdAPa+Y=
72 | github.com/gobuffalo/tags v2.1.0+incompatible/go.mod h1:9XmhOkyaB7UzvuY4UoZO4s67q8/xRMVJEaakauVQYeY=
73 | github.com/gobuffalo/uuid v2.0.5+incompatible h1:c5uWRuEnYggYCrT9AJm0U2v1QTG7OVDAvxhj8tIV5Gc=
74 | github.com/gobuffalo/uuid v2.0.5+incompatible/go.mod h1:ErhIzkRhm0FtRuiE/PeORqcw4cVi1RtSpnwYrxuvkfE=
75 | github.com/gobuffalo/validate v2.0.3+incompatible h1:6f4JCEz11Zi6iIlexMv7Jz10RBPvgI795AOaubtCwTE=
76 | github.com/gobuffalo/validate v2.0.3+incompatible/go.mod h1:N+EtDe0J8252BgfzQUChBgfd6L93m9weay53EWFVsMM=
77 | github.com/gofrs/uuid v3.2.0+incompatible h1:y12jRkkFxsd7GpqdSZ+/KCs/fJbqpEXSGd4+jfEaewE=
78 | github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
79 | github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
80 | github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
81 | github.com/gomodule/redigo v2.0.0+incompatible h1:K/R+8tc58AaqLkqG2Ol3Qk+DR/TlNuhuh457pBFPtt0=
82 | github.com/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4=
83 | github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
84 | github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
85 | github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
86 | github.com/iris-contrib/blackfriday v2.0.0+incompatible h1:o5sHQHHm0ToHUlAJSTjW9UWicjJSDDauOOQ2AHuIVp4=
87 | github.com/iris-contrib/blackfriday v2.0.0+incompatible/go.mod h1:UzZ2bDEoaSGPbkg6SAB4att1aAwTmVIx/5gCVqeyUdI=
88 | github.com/iris-contrib/formBinder v0.0.0-20190104093907-fbd5963f41e1 h1:7GsNnSLoVceNylMpwcfy5aFNz/S5/TV25crb34I5PEo=
89 | github.com/iris-contrib/formBinder v0.0.0-20190104093907-fbd5963f41e1/go.mod h1:i8kTYUOEstd/S8TG0ChTXQdf4ermA/e8vJX0+QruD9w=
90 | github.com/iris-contrib/go.uuid v2.0.0+incompatible h1:XZubAYg61/JwnJNbZilGjf3b3pB80+OQg2qf6c8BfWE=
91 | github.com/iris-contrib/go.uuid v2.0.0+incompatible/go.mod h1:iz2lgM/1UnEf1kP0L/+fafWORmlnuysV2EMP8MW+qe0=
92 | github.com/jackc/pgx v3.5.0+incompatible h1:BRJ4G3UPtvml5R1ey0biqqGuYUGayMYekm3woO75orY=
93 | github.com/jackc/pgx v3.5.0+incompatible/go.mod h1:0ZGrqGqkRlliWnWB4zKnWtjbSWbGkVEFm4TeybAXq+I=
94 | github.com/jmoiron/sqlx v1.2.0 h1:41Ip0zITnmWNR/vHV+S4m+VoUivnWY5E4OJfLZjCJMA=
95 | github.com/jmoiron/sqlx v1.2.0/go.mod h1:1FEQNm3xlJgrMD+FBdI9+xvCksHtbpVBBw5dYhBSsks=
96 | github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
97 | github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
98 | github.com/json-iterator/go v1.1.6 h1:MrUvLMLTMxbqFJ9kzlvat/rYZqZnW3u4wkLzWTaFwKs=
99 | github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
100 | github.com/juju/errors v0.0.0-20181118221551-089d3ea4e4d5 h1:rhqTjzJlm7EbkELJDKMTU7udov+Se0xZkWmugr6zGok=
101 | github.com/juju/errors v0.0.0-20181118221551-089d3ea4e4d5/go.mod h1:W54LbzXuIE0boCoNJfwqpmkKJ1O4TCTZMetAt6jGk7Q=
102 | github.com/juju/loggo v0.0.0-20180524022052-584905176618/go.mod h1:vgyd7OREkbtVEN/8IXZe5Ooef3LQePvuBm9UWj6ZL8U=
103 | github.com/juju/testing v0.0.0-20180920084828-472a3e8b2073/go.mod h1:63prj8cnj0tU0S9OHjGJn+b1h0ZghCndfnbQolrYTwA=
104 | github.com/karrick/godirwalk v1.10.3/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA=
105 | github.com/karrick/godirwalk v1.10.12/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA=
106 | github.com/kataras/golog v0.0.0-20190624001437-99c81de45f40 h1:Q/QxpyNBtfkhXE68tnEA4yyqm77eh/3YOjOw875VbBY=
107 | github.com/kataras/golog v0.0.0-20190624001437-99c81de45f40/go.mod h1:PcaEvfvhGsqwXZ6S3CgCbmjcp+4UDUh2MIfF2ZEul8M=
108 | github.com/kataras/iris v11.1.1+incompatible h1:c2iRKvKLpTYMXKdVB8YP/+A67NtZFt9kFFy+ZwBhWD0=
109 | github.com/kataras/iris v11.1.1+incompatible/go.mod h1:ki9XPua5SyAJbIxDdsssxevgGrbpBmmvoQmo/A0IodY=
110 | github.com/kataras/pio v0.0.0-20190103105442-ea782b38602d h1:V5Rs9ztEWdp58oayPq/ulmlqJJZeJP6pP79uP3qjcao=
111 | github.com/kataras/pio v0.0.0-20190103105442-ea782b38602d/go.mod h1:NV88laa9UiiDuX9AhMbDPkGYSPugBOV6yTZB1l2K9Z0=
112 | github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
113 | github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
114 | github.com/klauspost/compress v1.7.2 h1:liMOoeIvFpr9kEvalrZ7VVBA4wGf7zfOgwBjzz/5g2Y=
115 | github.com/klauspost/compress v1.7.2/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
116 | github.com/klauspost/cpuid v1.2.1 h1:vJi+O/nMdFt0vqm8NZBI6wzALWdA2X+egi0ogNyrC/w=
117 | github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
118 | github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
119 | github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
120 | github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
121 | github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
122 | github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
123 | github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
124 | github.com/lib/pq v1.1.1 h1:sJZmqHoEaY7f+NPP8pgLB/WxulyR3fewgCM2qaSlBb4=
125 | github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
126 | github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
127 | github.com/markbates/inflect v1.0.4 h1:5fh1gzTFhfae06u3hzHYO9xe3l3v3nW5Pwt3naLTP5g=
128 | github.com/markbates/inflect v1.0.4/go.mod h1:1fR9+pO2KHEO9ZRtto13gDwwZaAKstQzferVeWqbgNs=
129 | github.com/markbates/oncer v0.0.0-20181203154359-bf2de49a0be2/go.mod h1:Ld9puTsIW75CHf65OeIOkyKbteujpZVXDpWK6YGZbxE=
130 | github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0=
131 | github.com/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx8mU=
132 | github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
133 | github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE=
134 | github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
135 | github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
136 | github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
137 | github.com/mattn/goveralls v0.0.2/go.mod h1:8d1ZMHsd7fW6IRPKQh46F2WRpyib5/X4FOpevwGNQEw=
138 | github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b h1:j7+1HpAFS1zy5+Q4qx1fWh90gTKwiN4QCGoY9TWyyO4=
139 | github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
140 | github.com/microcosm-cc/bluemonday v1.0.1/go.mod h1:hsXNsILzKxV+sX77C5b8FSuKF00vh2OMYv+xgHpAMF4=
141 | github.com/microcosm-cc/bluemonday v1.0.2 h1:5lPfLTTAvAbtS0VqT+94yOtFnGfUWYyx0+iToC3Os3s=
142 | github.com/microcosm-cc/bluemonday v1.0.2/go.mod h1:iVP4YcDBq+n/5fb23BhYFvIMq/leAFZyRl6bYmGDlGc=
143 | github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
144 | github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
145 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
146 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
147 | github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
148 | github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
149 | github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
150 | github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
151 | github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
152 | github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
153 | github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
154 | github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
155 | github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
156 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
157 | github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
158 | github.com/rogpeppe/go-internal v1.3.0 h1:RR9dF3JtopPvtkroDZuVD7qquD0bnHlKSqaQhgwt8yk=
159 | github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
160 | github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
161 | github.com/ryanuber/columnize v2.1.0+incompatible h1:j1Wcmh8OrK4Q7GXY+V7SVSY8nUWQxHW5TkBe7YUl+2s=
162 | github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
163 | github.com/sec51/convert v0.0.0-20190309075348-ebe586d87951 h1:taE4tHnTci7boZpw+Xozd6KYy8AJ5WZoIuaJhQ8FvqQ=
164 | github.com/sec51/convert v0.0.0-20190309075348-ebe586d87951/go.mod h1:SRX4rc9r9AHj56zHfvY1XBPwhLU0vFZdIX7HaD1C3z8=
165 | github.com/sec51/cryptoengine v0.0.0-20180911112225-2306d105a49e h1:HsNjVWYeVdO/zoSfNBwJOs1PuSQCSCkwqW6Lp1TtZGs=
166 | github.com/sec51/cryptoengine v0.0.0-20180911112225-2306d105a49e/go.mod h1:g7izN9sUffTPdvcrt39y/ZephG5oJ9XizhJxxBOYDL0=
167 | github.com/sec51/gf256 v0.0.0-20160126143050-2454accbeb9e h1:wKXba8dfsFjbxkMpzZBKt8gkJAMSm1fIf1OSWQFQrVA=
168 | github.com/sec51/gf256 v0.0.0-20160126143050-2454accbeb9e/go.mod h1:hCjOqSOB9PBw5MdJ+0uSLCBV7FbLy0xwOR+c193HkcE=
169 | github.com/sec51/qrcode v0.0.0-20160126144534-b7779abbcaf1 h1:CI9zS8HvMiibvXM/F3IthY797GW77fNYgioJl/8Xzzk=
170 | github.com/sec51/qrcode v0.0.0-20160126144534-b7779abbcaf1/go.mod h1:uPm44Rj3uXSSOvmKmoeRuAUNUgwH2JHW5KIzqFFS/j4=
171 | github.com/sec51/twofactor v1.0.0 h1:1BTbzPhyMyB0YvcWxgNxEkI7WDNsBLvR+z699YWGMC8=
172 | github.com/sec51/twofactor v1.0.0/go.mod h1:CjtKwpvQSs9SYzLUsRH7gML+TgKeIofT8uxoy7RTLQI=
173 | github.com/serenize/snaker v0.0.0-20171204205717-a683aaf2d516 h1:ofR1ZdrNSkiWcMsRrubK9tb2/SlZVWttAfqUjJi6QYc=
174 | github.com/serenize/snaker v0.0.0-20171204205717-a683aaf2d516/go.mod h1:Yow6lPLSAXx2ifx470yD/nUe22Dv5vBvxK/UK9UUTVs=
175 | github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
176 | github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
177 | github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
178 | github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
179 | github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
180 | github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
181 | github.com/sourcegraph/annotate v0.0.0-20160123013949-f4cad6c6324d h1:yKm7XZV6j9Ev6lojP2XaIshpT4ymkqhMeSghO5Ps00E=
182 | github.com/sourcegraph/annotate v0.0.0-20160123013949-f4cad6c6324d/go.mod h1:UdhH50NIW0fCiwBSr0co2m7BnFLdv4fQTgdqdJTHFeE=
183 | github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e h1:qpG93cPwA5f7s/ZPBJnGOYQNK/vKsaDaseuKT5Asee8=
184 | github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e/go.mod h1:HuIsMU8RRBOtsCgI77wP899iHVBQpCmg4ErYMZB+2IA=
185 | github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
186 | github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
187 | github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU=
188 | github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
189 | github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
190 | github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
191 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
192 | github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
193 | github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
194 | github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
195 | github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
196 | github.com/x-cray/logrus-prefixed-formatter v0.5.2 h1:00txxvfBM9muc0jiLIEAkAcIMJzfthRT6usrui8uGmg=
197 | github.com/x-cray/logrus-prefixed-formatter v0.5.2/go.mod h1:2duySbKsL6M18s5GU7VPsoEPHyzalCE06qoARUCeBBE=
198 | github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
199 | golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
200 | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
201 | golang.org/x/crypto v0.0.0-20190422162423-af44ce270edf/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=
202 | golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
203 | golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
204 | golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 h1:HuIa8hRrWRSrqYzx1qI49NNxhdi2PrY7gxVSq1JjLDc=
205 | golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
206 | golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
207 | golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
208 | golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
209 | golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
210 | golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
211 | golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
212 | golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
213 | golang.org/x/net v0.0.0-20190613194153-d28f0bde5980 h1:dfGZHvZk057jK2MCeWus/TowKpJ8y4AmooUzdBSR9GU=
214 | golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
215 | golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
216 | golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU=
217 | golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
218 | golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
219 | golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
220 | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
221 | golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
222 | golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
223 | golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
224 | golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
225 | golang.org/x/sys v0.0.0-20190515120540-06a5c4944438/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
226 | golang.org/x/sys v0.0.0-20190606165138-5da285871e9c h1:+EXw7AwNOKzPFXMZ1yNjO40aWCh3PIquJB2fYlv9wcs=
227 | golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
228 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
229 | golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
230 | golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
231 | golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
232 | golang.org/x/tools v0.0.0-20181221001348-537d06c36207/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
233 | golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
234 | golang.org/x/tools v0.0.0-20190613204242-ed0dc450797f/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
235 | golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
236 | golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
237 | google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
238 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
239 | gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
240 | gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
241 | gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
242 | gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA=
243 | gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
244 | gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
245 | gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
246 | gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
247 |
--------------------------------------------------------------------------------
/gulpfile.js:
--------------------------------------------------------------------------------
1 | var gulp = require('gulp');
2 | var sass = require('gulp-sass');
3 |
4 | gulp.task('sass', function() {
5 | return gulp.src("scss/styles.scss")
6 | .pipe(sass().on('error', sass.logError))
7 | .pipe(gulp.dest("public/css"));
8 | });
9 |
10 | gulp.task('default', gulp.series('sass'));
11 |
12 |
--------------------------------------------------------------------------------
/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "os"
5 |
6 | log "github.com/sirupsen/logrus"
7 | prefixed "github.com/x-cray/logrus-prefixed-formatter"
8 |
9 | "github.com/CalmBit/capybara/controllers"
10 | "github.com/CalmBit/capybara/middleware"
11 | "github.com/gobuffalo/pop"
12 | "github.com/kataras/iris"
13 | "github.com/kataras/iris/mvc"
14 | "github.com/kataras/iris/sessions/sessiondb/redis"
15 | "github.com/kataras/iris/sessions/sessiondb/redis/service"
16 | )
17 |
18 | const capybaraVersionString = "v0.1.0"
19 |
20 | func main() {
21 | log.SetOutput(os.Stderr)
22 | textFormatter := new(prefixed.TextFormatter)
23 | textFormatter.FullTimestamp = true
24 | textFormatter.TimestampFormat = "Jan 01 2006 15:04:05"
25 | log.SetFormatter(textFormatter)
26 | log.SetLevel(log.DebugLevel)
27 | middleware.LoadSettings()
28 | log.Infof("Capybara %s is starting up...", capybaraVersionString)
29 | log.Debugf("Establishing connection to database...")
30 | tx, err := pop.Connect("development")
31 | if err != nil {
32 | log.Fatalf("Unable to establish database connection: %s", err.Error())
33 | return
34 | }
35 | log.Debugf("Got database connection %s", tx.ID)
36 | log.Debugf("Establishing connection to redis...")
37 | cache := redis.New(service.Config{
38 | Network: service.DefaultRedisNetwork,
39 | Addr: service.DefaultRedisAddr,
40 | Password: "",
41 | Database: "",
42 | MaxIdle: 0,
43 | MaxActive: 0,
44 | IdleTimeout: service.DefaultRedisIdleTimeout,
45 | Prefix: "",
46 | })
47 | if cache == nil {
48 | log.Fatalf("Unable to establish redis connection!")
49 | return
50 | }
51 | iris.RegisterOnInterrupt(func() {
52 | cache.Close()
53 | tx.Close()
54 | })
55 |
56 | log.Debugf("Starting up Iris....")
57 | app := iris.New()
58 | middleware.SetupSessionBackend(cache)
59 | app.Use(middleware.InitializeSession)
60 | app.Use(middleware.InitializeSettings)
61 | app.StaticWeb("/public/", "./public")
62 | app.OnErrorCode(404, func(ctx iris.Context) {
63 | ctx.View("404.pug")
64 | })
65 | pugEngine := iris.Pug("./views", ".pug").Layout("layout.pug")
66 | pugEngine.Reload(true)
67 | app.RegisterView(pugEngine)
68 | mvc.Configure(app.Party("/"), public)
69 | mvc.Configure(app.Party("/api/v1/accounts"), accounts)
70 | mvc.Configure(app.Party("/register"), registrations)
71 | mvc.Configure(app.Party("/login"), logins)
72 | mvc.Configure(app.Party("/logout"), logouts)
73 | mvc.Configure(app.Party("/about"), about)
74 | mvc.Configure(app.Party("/otp"), otp)
75 | log.Infof("Listening on 8080...")
76 |
77 | var run iris.Runner
78 | if middleware.GlobalSettings.UseTLS {
79 | run = iris.TLS(":8080", middleware.GlobalSettings.TLSCert, middleware.GlobalSettings.TLSKey)
80 | } else {
81 | run = iris.Addr(":8080")
82 | }
83 | app.Run(run, iris.WithoutStartupLog, iris.WithoutServerError(iris.ErrServerClosed))
84 | log.Infof("Goodbye! :)")
85 | }
86 |
87 | func public(app *mvc.Application) {
88 | app.Handle(new(controllers.PublicController))
89 | }
90 |
91 | func accounts(app *mvc.Application) {
92 | app.Handle(new(controllers.AccountController))
93 | }
94 |
95 | func registrations(app *mvc.Application) {
96 | app.Handle(new(controllers.RegistrationController))
97 | }
98 |
99 | func logins(app *mvc.Application) {
100 | app.Handle(new(controllers.LoginController))
101 | }
102 |
103 | func logouts(app *mvc.Application) {
104 | app.Handle(new(controllers.LogoutController))
105 | }
106 |
107 | func about(app *mvc.Application) {
108 | app.Handle(new(controllers.AboutController))
109 | }
110 |
111 | func otp(app *mvc.Application) {
112 | app.Handle(new(controllers.OTPController))
113 | }
114 |
--------------------------------------------------------------------------------
/middleware/sessions_middleware.go:
--------------------------------------------------------------------------------
1 | package middleware
2 |
3 | import (
4 | "github.com/kataras/iris"
5 | "github.com/kataras/iris/sessions"
6 | )
7 |
8 | var session = sessions.New(sessions.Config{Cookie: "capybara_session"})
9 |
10 | func SetupSessionBackend(db sessions.Database) {
11 | session.UseDatabase(db)
12 | }
13 | func InitializeSession(ctx iris.Context) {
14 | NewSession(ctx)
15 | ctx.Next()
16 | }
17 |
18 | func NewSession(ctx iris.Context) *sessions.Session {
19 | s := session.Start(ctx)
20 | ctx.Values().Set("currentSession", s)
21 | ctx.ViewData("error", s.GetFlashString("error"))
22 | ctx.ViewData("success", s.GetFlashString("success"))
23 | return s
24 | }
25 |
26 | func GetSession(ctx iris.Context) *sessions.Session {
27 | return ctx.Values().Get("currentSession").(*sessions.Session)
28 | }
29 |
30 | func KillSession(ctx iris.Context) {
31 | s := GetSession(ctx)
32 | s.Delete("authenticated")
33 | s.Delete("user_id")
34 | s.Delete("pass_confirmed")
35 | s.Delete("account_id")
36 | s.Delete("username")
37 | s.Delete("email")
38 | s.Delete("display_name")
39 | s.Delete("authenticated")
40 | }
41 |
--------------------------------------------------------------------------------
/middleware/settings_middleware.go:
--------------------------------------------------------------------------------
1 | package middleware
2 |
3 | import (
4 | "github.com/kataras/iris"
5 | "gopkg.in/yaml.v2"
6 | "io/ioutil"
7 | "log"
8 | )
9 |
10 | type Settings struct {
11 | RegistrationsOpen bool `yaml:"registrationsOpen"`
12 | URL string `yaml:"url"`
13 | UseTLS bool `yaml:"useTLS"`
14 | TLSCert string `yaml:"tlsCert"`
15 | TLSKey string `yaml:"tlsKey"`
16 | }
17 |
18 | var GlobalSettings Settings
19 |
20 | func LoadSettings() {
21 | setbuff, err := ioutil.ReadFile("config/config.yml")
22 | if err != nil {
23 | log.Fatalf("unable to read config file - %s", err.Error())
24 | return
25 | }
26 | err = yaml.Unmarshal(setbuff, &GlobalSettings)
27 | if err != nil {
28 | log.Fatalf("unable to unmarshal config file - %s", err.Error())
29 | return
30 | }
31 | }
32 |
33 | func InitializeSettings(ctx iris.Context) {
34 | ctx.ViewData("settings", GlobalSettings)
35 | ctx.Next()
36 | }
--------------------------------------------------------------------------------
/migrations/20180406044110_create_accounts.down.fizz:
--------------------------------------------------------------------------------
1 | drop_foreign_key("accounts", "accounts_accounts_id_fk", {})
2 |
3 | drop_index("accounts", "index_accounts_on_uri")
4 | drop_index("accounts", "index_accounts_on_url")
5 | drop_index("accounts", "index_accounts_on_username_and_domain")
6 |
7 | drop_table("accounts")
8 |
--------------------------------------------------------------------------------
/migrations/20180406044110_create_accounts.up.fizz:
--------------------------------------------------------------------------------
1 | create_table("accounts", func(t) {
2 | t.Column("id", "bigint", {"primary": true})
3 | t.Column("uuid", "uuid", {})
4 | t.Column("username", "string", {"default": "", "null": false})
5 | t.Column("domain", "string", {})
6 | t.Column("secret", "string", {"default": "", "null": false})
7 | t.Column("private_key", "text", {})
8 | t.Column("public_key", "text", {"default": "", "null": false})
9 | t.Column("remote_url", "string", {"default": "", "null": false})
10 | t.Column("salmon_url", "string", {"default": "", "null": false})
11 | t.Column("hub_url", "string", {"default": "", "null": false})
12 | t.Column("note", "text", {"default": "", "null": false})
13 | t.Column("display_name", "string", {"default": "", "null": false})
14 | t.Column("uri", "string", {"default": "", "null": false})
15 | t.Column("url", "string", {})
16 | t.Column("avatar_file_name", "string", {})
17 | t.Column("avatar_content_type", "string", {})
18 | t.Column("avatar_file_size", "integer", {})
19 | t.Column("avatar_updated_at", "timestamp", {"null": true})
20 | t.Column("header_file_name", "string", {})
21 | t.Column("header_content_type", "string", {})
22 | t.Column("header_file_size", "integer", {})
23 | t.Column("header_updated_at", "timestamp", {"null": true})
24 | t.Column("avatar_remote_url", "string", {})
25 | t.Column("subscription_expires_at", "timestamp", {"null": true})
26 | t.Column("silenced", "bool", {"default": false, "null": false})
27 | t.Column("suspended", "bool", {"default": false, "null": false})
28 | t.Column("locked", "bool", {"default": false, "null": false})
29 | t.Column("header_remote_url", "string", {"default": "", "null": false})
30 | t.Column("statuses_count", "integer", {"default": 0, "null": false})
31 | t.Column("followers_count", "integer", {"default": 0, "null": false})
32 | t.Column("following_count", "integer", {"default": 0, "null": false})
33 | t.Column("last_webfingered_at", "timestamp", {"null": true})
34 | t.Column("inbox_url", "string", {"default": "", "null": false})
35 | t.Column("outbox_url", "string", {"default": "", "null": false})
36 | t.Column("shared_inbox_url", "string", {"default": "", "null": false})
37 | t.Column("followers_url", "string", {"default": "", "null": false})
38 | t.Column("protocol", "integer", {"default": 0, "null": false})
39 | t.Column("memorial", "bool", {"default": false, "null": false})
40 | t.Column("moved_to_account_id", "bigint", {"null": true})
41 | t.Column("featured_collection_url", "string", {})
42 | })
43 |
44 | add_index("accounts", "uuid", {"name": "index_accounts_on_uuid"})
45 | add_index("accounts", "uri", {"name": "index_accounts_on_uri"})
46 | add_index("accounts", "url", {"name": "index_accounts_on_url"})
47 | add_index("accounts", ["username", "domain"], {"name": "index_accounts_on_username_and_domain", "unique": true})
48 |
49 | add_foreign_key("accounts", "moved_to_account_id", {"accounts": ["id"]}, {
50 | "on_delete": "SET NULL"
51 | })
--------------------------------------------------------------------------------
/migrations/20180407080009_create_users.down.fizz:
--------------------------------------------------------------------------------
1 | drop_table("users")
--------------------------------------------------------------------------------
/migrations/20180407080009_create_users.up.fizz:
--------------------------------------------------------------------------------
1 | create_table("users", func(t) {
2 | t.Column("id", "integer", {"primary": true})
3 | t.Column("email", "string", {"default": "", "null": "false"})
4 | t.Column("encrypted_password", "string", {"default": "", "null": false})
5 | t.Column("reset_password_token", "string", {})
6 | t.Column("reset_password_sent_at", "timestamp", {"null": true})
7 | t.Column("remember_created_at", "timestamp", {"null": true})
8 | t.Column("sign_in_count", "integer", {"default": 0, "null": false})
9 | t.Column("current_sign_in_at", "timestamp", {"null": true})
10 | t.Column("last_sign_in_at", "timestamp", {"null": true})
11 | t.Column("current_sign_in_ip", "inet", {"null": true})
12 | t.Column("last_sign_in_ip", "inet", {"null": true})
13 | t.Column("admin", "boolean", {"default": false, "null": false})
14 | t.Column("confirmation_token", "string", {})
15 | t.Column("confirmed_at", "timestamp", {"null": true})
16 | t.Column("confirmation_sent_at", "timestamp", {"null": true})
17 | t.Column("unconfirmed_email", "string", {"null": "true"})
18 | t.Column("locale", "string", {})
19 | t.Column("encrypted_otp_secret", "string", {})
20 | t.Column("encrypted_otp_secret_iv", "string", {})
21 | t.Column("encrypted_otp_secret_salt", "string", {})
22 | t.Column("consumed_timestep", "integer", {})
23 | t.Column("otp_required_for_login", "boolean", {"default": false, "null": false})
24 | t.Column("last_emailed_at", "timestamp", {"null": true})
25 | t.Column("otp_backup_codes", "string", {})
26 | t.Column("filtered_languages", "string", {"default": "", "null": false})
27 | t.Column("account_id", "bigint", {"null": false})
28 | t.Column("disabled", "boolean", {"default": false, "null": false})
29 | t.Column("moderator", "boolean", {"default": false, "null": false})
30 | t.Column("invite_id", "integer", {})
31 | t.Column("remember_token", "string", {})
32 | })
33 |
34 | add_index("users", "account_id", {"name": "index_users_on_account_id"})
35 | add_index("users", "confirmation_token", {"name": "index_users_on_confirmation_token", "unique": "true"})
36 | add_index("users", "email", {"name": "index_users_on_email", "unique": true})
37 | add_index("users", "filtered_languages", {"name": "index_users_on_filtered_languages"})
38 | add_index("users", "reset_password_token", {"name": "index_users_on_reset_password_token", "unique": "true"})
39 |
40 |
41 | add_foreign_key("users", "account_id", {"accounts": ["id"]}, {
42 | "on_delete": "CASCADE"
43 | })
--------------------------------------------------------------------------------
/migrations/20180409041516_create_statuses.down.fizz:
--------------------------------------------------------------------------------
1 | drop_table("statuses")
--------------------------------------------------------------------------------
/migrations/20180409041516_create_statuses.up.fizz:
--------------------------------------------------------------------------------
1 | create_table("statuses", func(t) {
2 | t.Column("id", "bigint", {"primary": true})
3 | t.Column("uri", "string", {})
4 | t.Column("text", "text", {"default": "", "null": false})
5 | t.Column("in_reply_to_id", "integer", {"null": true})
6 | t.Column("reblog_of_id", "integer", {"null": true})
7 | t.Column("url", "string", {})
8 | t.Column("sensitive", "boolean", {"default": false, "null": false})
9 | t.Column("visibility", "integer", {"default": 0, "null": false})
10 | t.Column("spoiler_text", "text", {"default": "", "null": false})
11 | t.Column("reply", "boolean", {"default": false, "null": false})
12 | t.Column("favourites_count", "integer", {"default": 0, "null": false})
13 | t.Column("reblogs_count", "integer", {"default": 0, "null": false})
14 | t.Column("language", "string", {})
15 | t.Column("conversation_id", "integer", {})
16 | t.Column("local", "boolean", {})
17 | t.Column("account_id", "integer", {"null": false})
18 | t.Column("application_id", "integer", {})
19 | t.Column("in_reply_to_account_id", "integer", {"null": true})
20 | })
--------------------------------------------------------------------------------
/models/account.go:
--------------------------------------------------------------------------------
1 | package models
2 |
3 | import (
4 | "encoding/json"
5 | "time"
6 |
7 | "database/sql/driver"
8 | "fmt"
9 | "github.com/gobuffalo/pop"
10 | "github.com/gobuffalo/validate"
11 | "github.com/gobuffalo/validate/validators"
12 | "github.com/gobuffalo/uuid"
13 | "crypto/rsa"
14 | "crypto/rand"
15 | "encoding/pem"
16 | "crypto/x509"
17 | log "github.com/sirupsen/logrus"
18 | "github.com/CalmBit/capybara/middleware"
19 | )
20 |
21 | type AccountId struct {
22 | id int64
23 | }
24 |
25 | type Account struct {
26 | ID int64 `json:"id" db:"id"`
27 | UUID uuid.UUID `json:"uuid" db:"uuid"`
28 | CreatedAt time.Time `json:"created_at" db:"created_at"`
29 | UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
30 | Username string `json:"username" db:"username"`
31 | Domain string `json:"domain" db:"domain"`
32 | Secret string `json:"secret" db:"secret"`
33 | PrivateKey string `json:"private_key" db:"private_key"`
34 | PublicKey string `json:"public_key" db:"public_key"`
35 | RemoteURL string `json:"remote_url" db:"remote_url"`
36 | SalmonURL string `json:"salmon_url" db:"salmon_url"`
37 | HubURL string `json:"hub_url" db:"hub_url"`
38 | Note string `json:"note" db:"note"`
39 | DisplayName string `json:"display_name" db:"display_name"`
40 | URI string `json:"uri" db:"uri"`
41 | URL string `json:"url" db:"url"`
42 | AvatarFileName string `json:"avatar_file_name" db:"avatar_file_name"`
43 | AvatarContentType string `json:"avatar_content_type" db:"avatar_content_type"`
44 | AvatarFileSize int `json:"avatar_file_size" db:"avatar_file_size"`
45 | AvatarUpdatedAt time.Time `json:"avatar_updated_at" db:"avatar_updated_at"`
46 | HeaderFileName string `json:"header_file_name" db:"header_file_name"`
47 | HeaderContentType string `json:"header_content_type" db:"header_content_type"`
48 | HeaderFileSize int `json:"header_file_size" db:"header_file_size"`
49 | HeaderUpdatedAt time.Time `json:"header_updated_at" db:"header_updated_at"`
50 | AvatarRemoteURL string `json:"avatar_remote_url" db:"avatar_remote_url"`
51 | SubscriptionExpiresAt time.Time `json:"subscription_expires_at" db:"subscription_expires_at"`
52 | Silenced bool `json:"silenced" db:"silenced"`
53 | Suspended bool `json:"suspended" db:"suspended"`
54 | Locked bool `json:"locked" db:"locked"`
55 | HeaderRemoteURL string `json:"header_remote_url" db:"header_remote_url"`
56 | StatusesCount int `json:"statuses_count" db:"statuses_count"`
57 | FollowersCount int `json:"followers_count" db:"followers_count"`
58 | FollowingCount int `json:"following_count" db:"following_count"`
59 | LastWebfingeredAt time.Time `json:"last_webfingered_at" db:"last_webfingered_at"`
60 | InboxURL string `json:"inbox_url" db:"inbox_url"`
61 | OutboxURL string `json:"outbox_url" db:"outbox_url"`
62 | SharedInboxURL string `json:"shared_inbox_url" db:"shared_inbox_url"`
63 | FollowersURL string `json:"followers_url" db:"followers_url"`
64 | Protocol int `json:"protocol" db:"protocol"`
65 | Memorial bool `json:"memorial" db:"memorial"`
66 | MovedToAccountID AccountId `json:"moved_to_account_id" db:"moved_to_account_id"`
67 | FeaturedCollectionURL string `json:"featured_collection_url" db:"featured_collection_url"`
68 | }
69 |
70 | // String is not required by pop and may be deleted
71 | func (a Account) String() string {
72 | ja, _ := json.Marshal(a)
73 | return string(ja)
74 | }
75 |
76 | // Accounts is not required by pop and may be deleted
77 | type Accounts []Account
78 |
79 | // String is not required by pop and may be deleted
80 | func (a Accounts) String() string {
81 | ja, _ := json.Marshal(a)
82 | return string(ja)
83 | }
84 |
85 | // Validate gets run every time you call a "pop.Validate*" (pop.ValidateAndSave, pop.ValidateAndCreate, pop.ValidateAndUpdate) method.
86 | // This method is not required and may be deleted.
87 | func (a *Account) Validate(tx *pop.Connection) (*validate.Errors, error) {
88 | return validate.Validate(
89 | &validators.StringIsPresent{Field: a.Username, Name: "Username"},
90 | /*&validators.StringIsPresent{Field: a.Domain, Name: "Domain"},
91 | &validators.StringIsPresent{Field: a.Secret, Name: "Secret"},
92 | &validators.StringIsPresent{Field: a.PrivateKey, Name: "PrivateKey"},
93 | &validators.StringIsPresent{Field: a.PublicKey, Name: "PublicKey"},
94 | &validators.StringIsPresent{Field: a.RemoteURL, Name: "RemoteURL"},
95 | &validators.StringIsPresent{Field: a.SalmonURL, Name: "SalmonURL"},
96 | &validators.StringIsPresent{Field: a.HubURL, Name: "HubURL"},
97 | &validators.TimeIsPresent{Field: a.CreatedAt, Name: "CreatedAt"},
98 | &validators.TimeIsPresent{Field: a.UpdatedAt, Name: "UpdatedAt"},
99 | &validators.StringIsPresent{Field: a.Note, Name: "Note"},
100 | &validators.StringIsPresent{Field: a.DisplayName, Name: "DisplayName"},
101 | &validators.StringIsPresent{Field: a.URI, Name: "URI"},
102 | &validators.StringIsPresent{Field: a.URL, Name: "URL"},
103 | &validators.StringIsPresent{Field: a.AvatarFileName, Name: "AvatarFileName"},
104 | &validators.StringIsPresent{Field: a.AvatarContentType, Name: "AvatarContentType"},
105 | &validators.StringIsPresent{Field: a.HeaderFileName, Name: "HeaderFileName"},
106 | &validators.StringIsPresent{Field: a.HeaderContentType, Name: "HeaderContentType"},
107 | &validators.StringIsPresent{Field: a.AvatarRemoteURL, Name: "AvatarRemoteURL"},
108 | &validators.StringIsPresent{Field: a.HeaderRemoteURL, Name: "HeaderRemoteURL"},
109 | &validators.StringIsPresent{Field: a.InboxURL, Name: "InboxURL"},
110 | &validators.StringIsPresent{Field: a.OutboxURL, Name: "OutboxURL"},
111 | &validators.StringIsPresent{Field: a.SharedInboxURL, Name: "SharedInboxURL"},
112 | &validators.StringIsPresent{Field: a.FollowersURL, Name: "FollowersURL"},
113 | &validators.StringIsPresent{Field: a.FeaturedCollectionURL, Name: "FeaturedCollectionURL"},*/
114 | ), nil
115 | }
116 |
117 | func (a *Account) GenerateCryptoKeys() {
118 | key, err := rsa.GenerateKey(rand.Reader, 2048)
119 | if err != nil {
120 | log.Errorf("SEVERE - Trouble generating crypot keys - %s", err.Error())
121 | return
122 | }
123 | a.PrivateKey = string(pem.EncodeToMemory(&pem.Block{Type: "RSA PRIVATE KEY", Bytes: x509.MarshalPKCS1PrivateKey(key)}))
124 | a.PublicKey = string(pem.EncodeToMemory(&pem.Block{Type:"RSA PUBLIC KEY", Bytes: x509.MarshalPKCS1PublicKey(&key.PublicKey)}))
125 | }
126 |
127 | // ValidateCreate gets run every time you call "pop.ValidateAndCreate" method.
128 | // This method is not required and may be deleted.
129 | func (a *Account) ValidateCreate(tx *pop.Connection) (*validate.Errors, error) {
130 | return validate.NewErrors(), nil
131 | }
132 |
133 | // ValidateUpdate gets run every time you call "pop.ValidateAndUpdate" method.
134 | // This method is not required and may be deleted.
135 | func (a *Account) ValidateUpdate(tx *pop.Connection) (*validate.Errors, error) {
136 | return validate.NewErrors(), nil
137 | }
138 |
139 | func (a Account) Local() bool {
140 | return a.Domain == middleware.GlobalSettings.URL
141 | }
142 |
143 | func (a Account) Acct() string {
144 | if a.Local() {
145 | return a.Username
146 | } else {
147 | return a.FullyQualifiedAcct()
148 | }
149 | }
150 |
151 | func (a Account) FullyQualifiedAcct() string {
152 | return fmt.Sprintf("%s@%s", a.Username, a.Domain)
153 | }
154 |
155 | func (a Account) Avatar() string {
156 | return "avatar_placeholder"
157 | }
158 |
159 | func (a Account) AvatarStatic() string {
160 | return "static_avatar_placeholder"
161 | }
162 |
163 | func (a Account) Header() string {
164 | return "header_placeholder"
165 | }
166 |
167 | func (a Account) HeaderStatic() string {
168 | return "header_avatar_placeholder"
169 | }
170 |
171 | func (id AccountId) Value() (driver.Value, error) {
172 | if id.id == 0 {
173 | return nil, nil
174 | }
175 | return driver.Value(id), nil
176 | }
177 |
178 | func (id AccountId) Scan(src interface{}) error {
179 | if src == nil {
180 | id.id = 0
181 | } else {
182 | id.id = src.(int64)
183 | }
184 |
185 | return nil
186 | }
187 |
--------------------------------------------------------------------------------
/models/account_test.go:
--------------------------------------------------------------------------------
1 | package models
2 |
3 | import "testing"
4 |
5 | func Test_Account(t *testing.T) {
6 | t.Fatal("This test needs to be implemented!")
7 | }
8 |
--------------------------------------------------------------------------------
/models/status.go:
--------------------------------------------------------------------------------
1 | package models
2 |
3 | import (
4 | "encoding/json"
5 | "github.com/gobuffalo/pop"
6 | "github.com/gobuffalo/validate"
7 | "github.com/gobuffalo/validate/validators"
8 | "time"
9 | "fmt"
10 | "html/template"
11 | "github.com/CalmBit/capybara/util"
12 | )
13 |
14 | type Status struct {
15 | ID int64 `json:"id" db:"id"`
16 | URI string `json:"uri" db:"uri"`
17 | Text string `json:"text" db:"text"`
18 | CreatedAt time.Time `json:"created_at" db:"created_at"`
19 | UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
20 | InReplyToID int `json:"in_reply_to_id" db:"in_reply_to_id"`
21 | ReblogOfID int `json:"reblog_of_id" db:"reblog_of_id"`
22 | URL string `json:"url" db:"url"`
23 | Sensitive bool `json:"sensitive" db:"sensitive"`
24 | Visibility int `json:"visibility" db:"visibility"`
25 | SpoilerText string `json:"spoiler_text" db:"spoiler_text"`
26 | Reply bool `json:"reply" db:"reply"`
27 | FavouritesCount int `json:"favourites_count" db:"favourites_count"`
28 | ReblogsCount int `json:"reblogs_count" db:"reblogs_count"`
29 | Language string `json:"language" db:"language"`
30 | ConversationID int `json:"conversation_id" db:"conversation_id"`
31 | Local bool `json:"local" db:"local"`
32 | AccountID int `json:"account_id" db:"account_id"`
33 | ApplicationID int `json:"application_id" db:"application_id"`
34 | InReplyToAccountID int `json:"in_reply_to_account_id" db:"in_reply_to_account_id"`
35 | StatusAccount Account `db:"-"`
36 |
37 | }
38 |
39 | // String is not required by pop and may be deleted
40 | func (s Status) String() string {
41 | js, _ := json.Marshal(s)
42 | return string(js)
43 | }
44 |
45 | // Statuses is not required by pop and may be deleted
46 | type Statuses []Status
47 |
48 | // String is not required by pop and may be deleted
49 | func (s Statuses) String() string {
50 | js, _ := json.Marshal(s)
51 | return string(js)
52 | }
53 |
54 | // Validate gets run every time you call a "pop.Validate*" (pop.ValidateAndSave, pop.ValidateAndCreate, pop.ValidateAndUpdate) method.
55 | // This method is not required and may be deleted.
56 | func (s *Status) Validate(tx *pop.Connection) (*validate.Errors, error) {
57 | return validate.Validate(
58 | &validators.StringIsPresent{Field: s.URI, Name: "URI"},
59 | &validators.StringIsPresent{Field: s.Text, Name: "Text"},
60 | &validators.TimeIsPresent{Field: s.CreatedAt, Name: "CreatedAt"},
61 | &validators.TimeIsPresent{Field: s.UpdatedAt, Name: "UpdatedAt"},
62 | &validators.StringIsPresent{Field: s.URL, Name: "URL"},
63 | &validators.StringIsPresent{Field: s.SpoilerText, Name: "SpoilerText"},
64 | &validators.StringIsPresent{Field: s.Language, Name: "Language"},
65 | ), nil
66 | }
67 |
68 | // ValidateCreate gets run every time you call "pop.ValidateAndCreate" method.
69 | // This method is not required and may be deleted.
70 | func (s *Status) ValidateCreate(tx *pop.Connection) (*validate.Errors, error) {
71 | return validate.NewErrors(), nil
72 | }
73 |
74 | // ValidateUpdate gets run every time you call "pop.ValidateAndUpdate" method.
75 | // This method is not required and may be deleted.
76 | func (s *Status) ValidateUpdate(tx *pop.Connection) (*validate.Errors, error) {
77 | return validate.NewErrors(), nil
78 | }
79 |
80 | func (s *Status) TimeAgo() string {
81 | return util.Ago(s.CreatedAt)
82 | }
83 |
84 | func (s *Status) Avatar() template.HTML {
85 | tx, err := pop.Connect("development")
86 | if err != nil {
87 | return "(error - couldn't connect to database)"
88 | }
89 | var account Account
90 | err = tx.Where(fmt.Sprintf("id = '%d'", s.AccountID)).First(&account)
91 | if err != nil {
92 | return "(error - couldn't find user)"
93 | }
94 |
95 | if account.AvatarFileName == "" {
96 | return template.HTML(fmt.Sprintf("", "public/img/avatar/missing.png"))
97 |
98 | }
99 | return template.HTML(fmt.Sprintf("", account.AvatarFileName))
100 | }
--------------------------------------------------------------------------------
/models/status_test.go:
--------------------------------------------------------------------------------
1 | package models
2 |
3 | import "testing"
4 |
5 | func Test_Status(t *testing.T) {
6 | t.Fatal("This test needs to be implemented!")
7 | }
8 |
--------------------------------------------------------------------------------
/models/user.go:
--------------------------------------------------------------------------------
1 | package models
2 |
3 | import (
4 | "database/sql/driver"
5 | "encoding/json"
6 | "fmt"
7 | "github.com/gobuffalo/pop"
8 | "github.com/gobuffalo/validate"
9 | "github.com/gobuffalo/validate/validators"
10 | log "github.com/sirupsen/logrus"
11 | "net"
12 | "time"
13 | "github.com/gobuffalo/uuid"
14 | "github.com/CalmBit/capybara/middleware"
15 | )
16 |
17 | var namespace uuid.UUID = uuid.NewV5(uuid.Nil, middleware.GlobalSettings.URL)
18 |
19 | type UserIP net.IPAddr
20 |
21 | type User struct {
22 | ID int64 `json:"id" db:"id"`
23 | Email string `json:"email" db:"email"`
24 | CreatedAt time.Time `json:"created_at" db:"created_at"`
25 | UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
26 | EncryptedPassword string `json:"encrypted_password" db:"encrypted_password"`
27 | ResetPasswordToken string `json:"reset_password_token" db:"reset_password_token"`
28 | ResetPasswordSentAt time.Time `json:"reset_password_sent_at" db:"reset_password_sent_at"`
29 | RememberCreatedAt time.Time `json:"remember_created_at" db:"remember_created_at"`
30 | SignInCount int `json:"sign_in_count" db:"sign_in_count"`
31 | CurrentSignInAt time.Time `json:"current_sign_in_at" db:"current_sign_in_at"`
32 | LastSignInAt time.Time `json:"last_sign_in_at" db:"last_sign_in_at"`
33 | CurrentSignInIp UserIP `json:"current_sign_in_ip" db:"current_sign_in_ip"`
34 | LastSignInIp UserIP `json:"last_sign_in_ip" db:"last_sign_in_ip"`
35 | Admin bool `json:"admin" db:"admin"`
36 | ConfirmationToken string `json:"confirmation_token" db:"confirmation_token"`
37 | ConfirmedAt time.Time `json:"confirmed_at" db:"confirmed_at"`
38 | ConfirmationSentAt time.Time `json:"confirmation_sent_at" db:"confirmation_sent_at"`
39 | UnconfirmedEmail string `json:"unconfirmed_email" db:"unconfirmed_email"`
40 | Locale string `json:"locale" db:"locale"`
41 | EncryptedOtpSecret string `json:"encrypted_otp_secret" db:"encrypted_otp_secret"`
42 | EncryptedOtpSecretIv string `json:"encrypted_otp_secret_iv" db:"encrypted_otp_secret_iv"`
43 | EncryptedOtpSecretSalt string `json:"encrypted_otp_secret_salt" db:"encrypted_otp_secret_salt"`
44 | ConsumedTimestep int `json:"consumed_timestep" db:"consumed_timestep"`
45 | OtpRequiredForLogin bool `json:"otp_required_for_login" db:"otp_required_for_login"`
46 | LastEmailedAt time.Time `json:"last_emailed_at" db:"last_emailed_at"`
47 | OtpBackupCodes string `json:"otp_backup_codes" db:"otp_backup_codes"`
48 | FilteredLanguages string `json:"filtered_languages" db:"filtered_languages"`
49 | AccountID int64 `json:"account_id" db:"account_id" belongs_to:"account"`
50 | Disabled bool `json:"disabled" db:"disabled"`
51 | Moderator bool `json:"moderator" db:"moderator"`
52 | InviteID int `json:"invite_id" db:"invite_id"`
53 | RememberToken string `json:"remember_token" db:"remember_token"`
54 | }
55 |
56 | func NewUser() User {
57 | return User{
58 | ID: 0,
59 | Email: "",
60 | CreatedAt: time.Now(),
61 | UpdatedAt: time.Now(),
62 | EncryptedPassword: "",
63 | ResetPasswordToken: "",
64 | ResetPasswordSentAt: time.Time{},
65 | RememberCreatedAt: time.Time{},
66 | SignInCount: 0,
67 | CurrentSignInAt: time.Time{},
68 | LastSignInAt: time.Time{},
69 | CurrentSignInIp: UserIP{IP: net.ParseIP("127.0.0.1")},
70 | LastSignInIp: UserIP{IP: net.ParseIP("127.0.0.1")},
71 | Admin: false,
72 | ConfirmationToken: "",
73 | ConfirmedAt: time.Time{},
74 | ConfirmationSentAt: time.Time{},
75 | UnconfirmedEmail: "",
76 | Locale: "",
77 | EncryptedOtpSecret: "",
78 | EncryptedOtpSecretIv: "",
79 | EncryptedOtpSecretSalt: "",
80 | ConsumedTimestep: 0,
81 | OtpRequiredForLogin: false,
82 | LastEmailedAt: time.Time{},
83 | OtpBackupCodes: "",
84 | FilteredLanguages: "",
85 | AccountID: 0,
86 | Disabled: false,
87 | Moderator: false,
88 | InviteID: 0,
89 | RememberToken: "",
90 | }
91 | }
92 |
93 | // String is not required by pop and may be deleted
94 | func (u User) String() string {
95 | ju, _ := json.Marshal(u)
96 | return string(ju)
97 | }
98 |
99 | // Users is not required by pop and may be deleted
100 | type Users []User
101 |
102 | // String is not required by pop and may be deleted
103 | func (u Users) String() string {
104 | ju, _ := json.Marshal(u)
105 | return string(ju)
106 | }
107 |
108 | // Validate gets run every time you call a "pop.Validate*" (pop.ValidateAndSave, pop.ValidateAndCreate, pop.ValidateAndUpdate) method.
109 | // This method is not required and may be deleted.
110 | func (u *User) Validate(tx *pop.Connection) (*validate.Errors, error) {
111 | return validate.Validate(
112 | &validators.StringIsPresent{Field: u.Email, Name: "Email"},
113 | &validators.TimeIsPresent{Field: u.CreatedAt, Name: "CreatedAt"},
114 | &validators.TimeIsPresent{Field: u.UpdatedAt, Name: "UpdatedAt"},
115 | &validators.StringIsPresent{Field: u.EncryptedPassword, Name: "EncryptedPassword"},
116 | ), nil
117 | }
118 |
119 | // ValidateCreate gets run every time you call "pop.ValidateAndCreate" method.
120 | // This method is not required and may be deleted.
121 | func (u *User) ValidateCreate(tx *pop.Connection) (*validate.Errors, error) {
122 | return validate.NewErrors(), nil
123 | }
124 |
125 | // ValidateUpdate gets run every time you call "pop.ValidateAndUpdate" method.
126 | // This method is not required and may be deleted.
127 | func (u *User) ValidateUpdate(tx *pop.Connection) (*validate.Errors, error) {
128 | return validate.NewErrors(), nil
129 | }
130 |
131 | func (u *User) CreateAccount(tx *pop.Connection, username string) (*Account, error) {
132 | var account = Account{
133 | ID: 0,
134 | UUID: uuid.NewV3(namespace, username),
135 | CreatedAt: time.Time{},
136 | UpdatedAt: time.Time{},
137 | Username: "",
138 | Domain: "",
139 | Secret: "",
140 | PrivateKey: "",
141 | PublicKey: "",
142 | RemoteURL: "",
143 | SalmonURL: "",
144 | HubURL: "",
145 | Note: "",
146 | DisplayName: "",
147 | URI: "",
148 | URL: "",
149 | AvatarFileName: "",
150 | AvatarContentType: "",
151 | AvatarFileSize: 0,
152 | AvatarUpdatedAt: time.Time{},
153 | HeaderFileName: "",
154 | HeaderContentType: "",
155 | HeaderFileSize: 0,
156 | HeaderUpdatedAt: time.Time{},
157 | AvatarRemoteURL: "",
158 | SubscriptionExpiresAt: time.Time{},
159 | Silenced: false,
160 | Suspended: false,
161 | Locked: false,
162 | HeaderRemoteURL: "",
163 | StatusesCount: 0,
164 | FollowersCount: 0,
165 | FollowingCount: 0,
166 | LastWebfingeredAt: time.Time{},
167 | InboxURL: "",
168 | OutboxURL: "",
169 | SharedInboxURL: "",
170 | FollowersURL: "",
171 | Protocol: 0,
172 | Memorial: false,
173 | MovedToAccountID: AccountId{},
174 | FeaturedCollectionURL: "",
175 | }
176 | account.Username = username
177 | account.GenerateCryptoKeys()
178 | account.DisplayName = username
179 | account.Domain = middleware.GlobalSettings.URL
180 | account.URL = middleware.GlobalSettings.URL + "/" + account.UUID.String()
181 |
182 | valid, err := tx.ValidateAndCreate(&account)
183 | if valid.HasAny() {
184 | return nil, fmt.Errorf("%s", valid.Error())
185 | }
186 | if err != nil {
187 | return nil, err
188 | }
189 | u.AccountID = account.ID
190 | return &account, nil
191 | }
192 |
193 | func (ip UserIP) Value() (driver.Value, error) {
194 | if len(ip.IP) == 0 {
195 | log.Warningf("clobbered nil ip value on user object - LOOK INTO THIS")
196 | return driver.Value("0.0.0.0"), nil
197 | }
198 | return driver.Value(ip.IP.String()), nil
199 | }
200 |
201 | func (ip UserIP) Scan(src interface{}) error {
202 | var source []uint8
203 | source = []byte(src.([]uint8))
204 |
205 | ip.IP = net.ParseIP(string(source))
206 |
207 | return nil
208 | }
209 |
--------------------------------------------------------------------------------
/models/user_test.go:
--------------------------------------------------------------------------------
1 | package models
2 |
3 | import "testing"
4 |
5 | func Test_User(t *testing.T) {
6 | t.Fatal("This test needs to be implemented!")
7 | }
8 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "scripts": {
3 | "gulp": "gulp"
4 | },
5 | "private": true,
6 | "license": "AGPL-3.0-or-later",
7 | "devDependencies": {
8 | "gulp": "^4.0.0",
9 | "gulp-sass": "^4.0.2"
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/public/css/styles.css:
--------------------------------------------------------------------------------
1 | * {
2 | font-family: "Roboto", "sans-serif";
3 | color: white; }
4 |
5 | html {
6 | background: #222;
7 | margin: 1em 1em 1em 1em; }
8 |
9 | #logo {
10 | width: 10em;
11 | height: 10em; }
12 |
13 | #app {
14 | display: grid;
15 | grid-row-gap: 1em;
16 | grid-column-gap: 1em;
17 | grid-template-columns: 50vw; }
18 |
19 | header {
20 | grid-row: 1;
21 | grid-column: 1 / span 2;
22 | text-align: center;
23 | background-color: #0001;
24 | padding: 0.5em;
25 | border-radius: 1em; }
26 |
27 | section {
28 | background-color: #0001;
29 | padding: 0.5em;
30 | border-radius: 1em; }
31 |
32 | #overview {
33 | grid-row: 2;
34 | grid-column: 1; }
35 |
36 | #register_about {
37 | grid-row: 2;
38 | grid-column: 2;
39 | text-align: center; }
40 |
41 | #error_box {
42 | grid-row: -2;
43 | grid-column: 1 / span 2;
44 | text-align: center;
45 | border-radius: 0.25em;
46 | background-color: #F004;
47 | border: 4px solid #4004; }
48 |
49 | #success_box {
50 | grid-row: -2;
51 | grid-column: 1 / span 2;
52 | text-align: center;
53 | border-radius: 0.25em;
54 | background-color: #0F04;
55 | border: 4px solid #0F04; }
56 |
57 | #login {
58 | grid-column: 1 / span 2;
59 | grid-row: 1;
60 | text-align: center;
61 | margin-left: 25vw;
62 | margin-right: 25vw; }
63 |
64 | input {
65 | display: block;
66 | width: 32em;
67 | height: 2em;
68 | margin-top: 0.5em;
69 | margin-bottom: 0.5em;
70 | margin-right: auto;
71 | margin-left: auto;
72 | background-color: #0002;
73 | color: #FFF;
74 | font-weight: bold; }
75 |
76 | button {
77 | border: none;
78 | border-radius: 0.25em;
79 | font-size: 1.05em;
80 | text-decoration: none;
81 | padding: 0.5em;
82 | background-color: #144bb8; }
83 |
84 | a#login_button {
85 | border: none;
86 | border-radius: 0.25em;
87 | font-size: 1.05em;
88 | text-decoration: none;
89 | padding: 0.5em;
90 | background-color: #14b814; }
91 |
--------------------------------------------------------------------------------
/public/img/avatar/missing.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CalmBit/capybara/c901fe9c4d108e024636d2165c29f023ce69dfee/public/img/avatar/missing.png
--------------------------------------------------------------------------------
/public/img/capybara.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/public/img/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CalmBit/capybara/c901fe9c4d108e024636d2165c29f023ce69dfee/public/img/favicon.png
--------------------------------------------------------------------------------
/public/img/header/missing.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CalmBit/capybara/c901fe9c4d108e024636d2165c29f023ce69dfee/public/img/header/missing.png
--------------------------------------------------------------------------------
/scss/styles.scss:
--------------------------------------------------------------------------------
1 | //colors
2 | $primary_text_color: hsla(0, 0%, 100%, 1);
3 | $header_bg_color: hsla(0, 0%, 0%, 0.45);
4 | $section_bg_color: hsla(0, 0%, 0%, 0.25);
5 | $page_pg_color: hsla(250, 50%, 20%, 1);
6 | $untouched_input_bg_color: hsla(0, 0%, 0%, 0.5);
7 | $invalid_input_bottom_color: hsla(0, 80%, 40%, 1);
8 | $selected_input_bg_color: hsla(0, 0%, 10%, 0.5);
9 | $valid_input_bottom_color: hsla(140, 80%, 40%, 1);
10 | $untouched_input_bottom_color: hsla(250, 80%, 60%, 0.4);
11 | $submit_button_color: hsla(220, 80%, 40%, 1);
12 | $login_button_color: hsla(120, 80%, 40%, 1);
13 | $error_box_bg_color: hsla(0, 70%, 62%, 1);
14 | $error_box_border_color: hsla(0, 66%, 53%, 1);
15 | $success_box_bg_color: hsla(135, 70%, 62%, 1);
16 | $success_box_border_color: hsla(125, 66%, 53%, 1);
17 | $profile_info_bg_color: hsla(0, 0%, 0%, 0.75);
18 | $status_bg_color: hsla(0, 100%, 100%, 1);
19 |
20 | //fonts
21 | $primary_font: "Roboto";
22 | $fallback_font: "sans-serif";
23 |
24 | //urls
25 | $header_img_url: url("/public/img/header/missing.png");
26 |
27 | $section-padding: 0.5em;
28 |
29 | * {
30 | font-family: $primary_font, $fallback_font;
31 | color: $primary_text_color;
32 | }
33 |
34 | html {
35 | background: #222;
36 | margin: 1em 1em 1em 1em;
37 | }
38 |
39 | #logo {
40 | width: 10em;
41 | height: 10em;
42 | }
43 |
44 | #app {
45 | display: grid;
46 | grid-row-gap: 1em;
47 | grid-column-gap: 1em;
48 | grid-template-columns: 50vw;
49 | }
50 |
51 | header {
52 | grid-row: 1;
53 | grid-column: 1 / span 2;
54 | text-align: center;
55 | background-color: #0001;
56 | padding: $section-padding;
57 | border-radius: 1em;
58 | }
59 |
60 | section {
61 | background-color: #0001;
62 | padding: $section-padding;
63 | border-radius: 1em;
64 | }
65 |
66 | #overview {
67 | grid-row: 2;
68 | grid-column: 1;
69 | }
70 |
71 | #register_about {
72 | grid-row: 2;
73 | grid-column: 2;
74 | text-align: center;
75 | }
76 |
77 | @mixin flash {
78 | grid-row: -2;
79 | grid-column: 1 / span 2;
80 | text-align: center;
81 | border-radius: 0.25em;
82 | }
83 |
84 | #error_box {
85 | @include flash();
86 | background-color: #F004;
87 | border: 4px solid #4004;
88 | }
89 |
90 | #success_box {
91 | @include flash();
92 | background-color: #0F04;
93 | border: 4px solid #0F04;
94 | }
95 |
96 | #login {
97 | grid-column: 1 / span 2;
98 | grid-row: 1;
99 | text-align: center;
100 | margin-left: 25vw;
101 | margin-right: 25vw;
102 | }
103 |
104 | input {
105 | display: block;
106 | width: 32em;
107 | height: 2em;
108 | margin-top: 0.5em;
109 | margin-bottom: 0.5em;
110 | margin-right: auto;
111 | margin-left: auto;
112 | background-color: #0002;
113 | color: #FFF;
114 | font-weight: bold;
115 | }
116 |
117 | @mixin button {
118 | border: none;
119 | border-radius: 0.25em;
120 | font-size: 1.05em;
121 | text-decoration: none;
122 | padding: 0.5em;
123 | }
124 |
125 | button {
126 | @include button();
127 | background-color: $submit_button_color;
128 | }
129 |
130 | a#login_button {
131 | @include button();
132 | background-color: $login_button_color;
133 | }
--------------------------------------------------------------------------------
/serializers/serializer.go:
--------------------------------------------------------------------------------
1 | package serializers
2 |
3 | import (
4 | "bytes"
5 | "fmt"
6 | "reflect"
7 | "strings"
8 | "time"
9 | )
10 |
11 | const (
12 | SerializerField = iota
13 | SerializerMethod
14 | )
15 |
16 | type serializerField struct {
17 | Name string
18 | Type int
19 | JSONKey string
20 | AsString bool
21 | }
22 |
23 | type Serializer struct {
24 | fields []serializerField
25 | validator ValidatorPredicate
26 | }
27 |
28 | type ValidatorPredicate func(interface{}) error
29 |
30 | // Stub function - other logic at some point
31 | func ConstructSerializer(validator ValidatorPredicate) Serializer {
32 | return Serializer{fields: []serializerField{}, validator: validator}
33 | }
34 |
35 | func (s Serializer) AddField(name string) Serializer {
36 | s.fields = append(s.fields, serializerField{name, SerializerField, "", false})
37 | return s
38 | }
39 | func (s Serializer) AddFieldAsString(name string) Serializer {
40 | s.fields = append(s.fields, serializerField{name, SerializerField, "", true})
41 | return s
42 | }
43 |
44 | func (s Serializer) AddMethod(name string, jsonKey string) Serializer {
45 | s.fields = append(s.fields, serializerField{name, SerializerMethod, jsonKey, false})
46 | return s
47 | }
48 |
49 | func stringifyValue(value reflect.Value, asString bool) string {
50 | // Check our value's type, and serialize it if we can.
51 | // If it's not in this list, produce its type name so we
52 | // can debug it later.
53 | switch value.Type().Name() {
54 | case "string":
55 | return fmt.Sprintf("\"%s\"", strings.Replace(value.String(), "\"", "\\\"", -1))
56 | case "int":
57 | fallthrough
58 | case "int64":
59 | if asString {
60 | return fmt.Sprintf("\"%d\"", value.Int())
61 | } else {
62 | return fmt.Sprintf("%d", value.Int())
63 | }
64 | case "bool":
65 | if asString {
66 | return fmt.Sprintf("\"%t\"", value.Bool())
67 | } else {
68 | return fmt.Sprintf("%t", value.Bool())
69 | }
70 | case "Time":
71 | return fmt.Sprintf("\"%s\"", stringifyTime(value))
72 | default:
73 | return fmt.Sprintf("\"%s\"", value.String())
74 | }
75 |
76 | }
77 |
78 | func stringifyTime(v reflect.Value) string {
79 | if v.Type().Name() != "Time" {
80 | return ""
81 | }
82 |
83 | // Time is a little weird - since it's a struct, we have to do this nasty, nasty extra method
84 | // call on our value. On the bright side, it's fairly easy to set up and execute.
85 | return v.MethodByName("Format").Call([]reflect.Value{reflect.ValueOf(time.RFC3339)})[0].String()
86 | }
87 |
88 | func (s Serializer) SerializeToJSON(v interface{}) ([]byte, error) {
89 | err := s.validator(v)
90 | if err != nil {
91 | return nil, fmt.Errorf("serialization validation failed - %s", err.Error())
92 | }
93 |
94 | var buffer bytes.Buffer
95 | interfaceType := reflect.TypeOf(v)
96 | interfaceValue := reflect.ValueOf(v)
97 |
98 | buffer.WriteByte('{')
99 | for i, f := range s.fields {
100 | if f.Type == SerializerField {
101 | // Retrieve our field from the interface, and validate that we could find it.
102 | field, ok := interfaceType.FieldByName(f.Name)
103 | if !ok {
104 | return nil, fmt.Errorf("serialization failed on value %+v - field %s doesn't exist", v, f.Name)
105 | }
106 |
107 | // Write out our key to the buffer.
108 | buffer.WriteString(fmt.Sprintf("\"%s\":", field.Tag.Get("json")))
109 |
110 | // Retrieve the field's value from our current interface.
111 | value := interfaceValue.FieldByName(f.Name)
112 |
113 | buffer.WriteString(stringifyValue(value, f.AsString))
114 |
115 | } else if f.Type == SerializerMethod {
116 | // If the JSONKey is empty, we can't serialize the method - a method requires an alternative key, as
117 | // it has no JSON tagging.
118 | if f.JSONKey == "" {
119 | return nil, fmt.Errorf("serialization failed on value %+v - method %s has no JSONKey", v, f.Name)
120 | }
121 |
122 | // Retrieve the method from the interface, and validate that we could find it.
123 | method, ok := interfaceType.MethodByName(f.Name)
124 | if !ok {
125 | return nil, fmt.Errorf("serialization failed on value %+v - method %s doesn't exist", v, f.Name)
126 | }
127 |
128 | // Write out our key to the buffer.
129 | buffer.WriteString(fmt.Sprintf("\"%s\":", f.JSONKey))
130 |
131 | // Call our method (must not have any parameters).
132 | value := method.Func.Call([]reflect.Value{interfaceValue})[0]
133 |
134 | buffer.WriteString(stringifyValue(value, f.AsString))
135 |
136 | }
137 | // If we haven't hit the last field yet, add a comma.
138 | if i < len(s.fields)-1 {
139 | buffer.WriteString(", ")
140 | }
141 | }
142 | // End our JSON.
143 | buffer.WriteByte('}')
144 |
145 | return buffer.Bytes(), nil
146 | }
147 |
148 | func DeserializeFromJSON(buf []byte, v interface{}) {
149 |
150 | }
151 |
152 | func IsValidContainer(v interface{}) error {
153 | return nil
154 | }
155 |
--------------------------------------------------------------------------------
/util/time.go:
--------------------------------------------------------------------------------
1 | package util
2 |
3 | import (
4 | "time"
5 | "strconv"
6 | "fmt"
7 | )
8 |
9 | func Ago(date time.Time) string {
10 | duration := time.Now().UTC().Sub(date.UTC())
11 | fmt.Printf("Now: %s - Before: %s\n", time.Now().UTC(), date.UTC())
12 | if duration.Hours() > 48 {
13 | return date.Format("Mon, 02 Jan 2006")
14 | } else if duration.Hours() >= 24 {
15 | return "1d"
16 | } else if duration.Hours() >= 1 {
17 | return strconv.Itoa(int(duration.Hours()))+"h"
18 | } else if duration.Minutes() >= 1 {
19 | return strconv.Itoa(int(duration.Minutes()))+"m"
20 | } else if duration.Seconds() >= 1 {
21 | return strconv.Itoa(int(duration.Seconds()))+"s"
22 | } else {
23 | return "now"
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/views/404.pug:
--------------------------------------------------------------------------------
1 | section#error_container
2 | h1 You seem to be lost.
3 | p The page you tried to access doesn't seem to exist.
4 |
--------------------------------------------------------------------------------
/views/about.pug:
--------------------------------------------------------------------------------
1 | header
2 | img#logo(src="../public/img/capybara.svg")
3 | h1 Capybara
4 | section#overview
5 | h2 What is Capybara?
6 | p
7 | | Capybara is an #[a(href="https://github.com/CalmBit/capybara") open source],
8 | | decentralized, federated microblogging platform - like Twitter, but with no one company
9 | | controlling it.
10 | h2
11 | | Why would I want this?
12 | p
13 | | Microblogging is a great way to connect with people all over the world - unfortunately,
14 | | the modern microblogging landscape is controlled by one company, with very few people's
15 | | interests at heart. Software like Capybara allows users to take back their data and
16 | | find communities that interest and benefit them, rather than a corporation.
17 | h2
18 | | This sounds like #[a(href="https://mastodon.social/about") Mastodon]...
19 | p
20 | | You're correct in making that comparison! Capybara is a clone of Mastodon, written in Go rather
21 | | than Ruby, and with Vue.JS rather than React.
22 | section#register_about
23 | if .username
24 | h1 You're logged in as #{.username}
25 | form(action="/logout" method="post")
26 | button(type="submit") Log Out
27 | else
28 | if .settings.RegistrationsOpen
29 | h2 Sign Up
30 | form(action="/register" method="post")
31 | input(type="text" name="username" placeholder="Username")
32 | input(type="email" name="email" placeholder="Email address")
33 | input(type="password" name="password" placeholder="Password")
34 | input(type="password" name="password_confirm" placeholder="Confirm password")
35 | button(type="submit") Sign Up
36 | p or
37 | a#login_button(href="/login") Log In
38 | else
39 | h2 Sorry!
40 | p
41 | | Unfortunately, the administrators of this instance aren't accepting new users right now.
42 | p
43 | | Try looking around for an open instance!
44 |
--------------------------------------------------------------------------------
/views/index.pug:
--------------------------------------------------------------------------------
1 | section#error_container
2 | h1 You need to enable JavaScript.
3 | p
4 | | Unfortunately, Capybara's web client only works with Vue.JS making everything
5 | | neat and tidy. However, since Capybara is #[em also] Mastodon-compatible, try
6 | | one of these #[a(href="https://github.com/tootsuite/documentation/blob/master/Using-Mastodon/Apps.md") native apps]
7 | | instead!
8 |
--------------------------------------------------------------------------------
/views/layout.pug:
--------------------------------------------------------------------------------
1 | doctype html
2 | html(lang="en")
3 | head
4 | meta(charset="utf-8")
5 | title Capybara
6 | link(rel='icon', sizes='16x16 32x32 48x48 64x64', href='public/img/favicon.png')
7 | body
8 | script(src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js")
9 | link(rel="stylesheet" type="text/css" href="/public/css/styles.css")
10 | link(href="https://fonts.googleapis.com/css?family=Roboto|Roboto+Slab" rel="stylesheet")
11 | main#app
12 | if .error
13 | div#error_box
14 | p #{.error}
15 | if .success
16 | div#success_box
17 | p #{.success}
18 | | {{ yield }}
--------------------------------------------------------------------------------
/views/login.pug:
--------------------------------------------------------------------------------
1 | section#login
2 | h2 Log In
3 | form(action="/login" method="post")
4 | input(type="email" name="email" placeholder="Email address")
5 | input(type="password" name="password" placeholder="Password")
6 | button(type="submit") Log In
7 |
--------------------------------------------------------------------------------
/views/otp.pug:
--------------------------------------------------------------------------------
1 |
2 | section#login
3 | h2 Log In
4 | form(action="/otp" method="post")
5 | img(id="qr_code" width="256" height="256")
6 | input(type="text" name="code_confirm" placeholder="Confirmation Code")
7 | button(type="submit") Confirm
8 |
9 | script.
10 | document.getElementById("qr_code").src=#{.qr_code}
11 |
--------------------------------------------------------------------------------
/views/otp_login.pug:
--------------------------------------------------------------------------------
1 | section#login
2 | h2 Type in your 2FA code
3 | form(action="/login/confirm" method="post")
4 | input(type="text" name="code_confirm" placeholder="Confirmation Code")
5 | button(type="submit") Confirm
--------------------------------------------------------------------------------
/views/public_user.pug:
--------------------------------------------------------------------------------
1 | section#profile
2 | section#profile_head
3 | section#profile_header_and_avatar
4 | img#profile_avatar(src="/public/img/avatar/missing.png" height="128" style="border-radius:1em;")
5 | section#profile_info
6 | p#profile_display_name #{.account.DisplayName}
7 | p #{.account.FullyQualifiedAcct}
8 | p#profile_uuid (#{.account.UUID.String})
9 | p#profile_note #{.account.Note}
10 | section#profile_statuses
11 | | {{range .statuses}}
12 | div.status
13 | | {{.Avatar}}
14 | div#status_text
15 | p
16 | span(style="font-weight:bold;color:black;margin-right:0.5em;") #{.StatusAccount.DisplayName}
17 | span(style="color:grey;margin-right:1em;") @#{.StatusAccount.Username}
18 | span(style="color:grey;float:right;") #{.TimeAgo}
19 | p #{.Text}
20 | | {{end}}
--------------------------------------------------------------------------------