Show More
@@ -1,30 +1,29 b'' | |||||
1 | include .coveragerc |
|
1 | include .coveragerc | |
2 | include Apache-License-2.0.txt |
|
2 | include Apache-License-2.0.txt | |
3 | include CONTRIBUTORS |
|
3 | include CONTRIBUTORS | |
4 | include COPYING |
|
4 | include COPYING | |
5 | include Jenkinsfile |
|
5 | include Jenkinsfile | |
6 | include LICENSE-MERGELY.html |
|
6 | include LICENSE-MERGELY.html | |
7 | include LICENSE.md |
|
7 | include LICENSE.md | |
8 | include MIT-Permissive-License.txt |
|
8 | include MIT-Permissive-License.txt | |
9 | include README.rst |
|
9 | include README.rst | |
10 | include dev_requirements.txt |
|
10 | include dev_requirements.txt | |
11 | include development.ini |
|
11 | include development.ini | |
12 | include pytest.ini |
|
12 | include pytest.ini | |
13 | include requirements.txt |
|
13 | include requirements.txt | |
14 | include tox.ini |
|
14 | include tox.ini | |
15 | recursive-include docs * |
|
15 | recursive-include docs * | |
16 | recursive-include init.d * |
|
16 | recursive-include init.d * | |
17 | recursive-include kallithea/alembic * |
|
17 | recursive-include kallithea/alembic * | |
18 | include kallithea/bin/ldap_sync.conf |
|
18 | include kallithea/bin/ldap_sync.conf | |
19 | include kallithea/lib/paster_commands/template.ini.mako |
|
19 | include kallithea/lib/paster_commands/template.ini.mako | |
20 | recursive-include kallithea/i18n * |
|
20 | recursive-include kallithea/i18n * | |
21 | recursive-include kallithea/public * |
|
21 | recursive-include kallithea/public * | |
22 | prune kallithea/public/less/node_modules |
|
22 | recursive-include node_modules/bootstrap * | |
23 | recursive-include kallithea/public/less/node_modules/bootstrap * |
|
|||
24 | recursive-include kallithea/templates * |
|
23 | recursive-include kallithea/templates * | |
25 | recursive-include kallithea/tests/fixtures * |
|
24 | recursive-include kallithea/tests/fixtures * | |
26 | recursive-include kallithea/tests/scripts * |
|
25 | recursive-include kallithea/tests/scripts * | |
27 | include kallithea/tests/models/test_dump_html_mails.ref.html |
|
26 | include kallithea/tests/models/test_dump_html_mails.ref.html | |
28 | include kallithea/tests/performance/test_vcs.py |
|
27 | include kallithea/tests/performance/test_vcs.py | |
29 | include kallithea/tests/vcs/aconfig |
|
28 | include kallithea/tests/vcs/aconfig | |
30 | recursive-include scripts * |
|
29 | recursive-include scripts * |
@@ -1,316 +1,316 b'' | |||||
1 | .. _contributing: |
|
1 | .. _contributing: | |
2 |
|
2 | |||
3 | ========================= |
|
3 | ========================= | |
4 | Contributing to Kallithea |
|
4 | Contributing to Kallithea | |
5 | ========================= |
|
5 | ========================= | |
6 |
|
6 | |||
7 | Kallithea is developed and maintained by its users. Please join us and scratch |
|
7 | Kallithea is developed and maintained by its users. Please join us and scratch | |
8 | your own itch. |
|
8 | your own itch. | |
9 |
|
9 | |||
10 |
|
10 | |||
11 | Infrastructure |
|
11 | Infrastructure | |
12 | -------------- |
|
12 | -------------- | |
13 |
|
13 | |||
14 | The main repository is hosted on Our Own Kallithea (aka OOK) at |
|
14 | The main repository is hosted on Our Own Kallithea (aka OOK) at | |
15 | https://kallithea-scm.org/repos/kallithea/, our self-hosted instance |
|
15 | https://kallithea-scm.org/repos/kallithea/, our self-hosted instance | |
16 | of Kallithea. |
|
16 | of Kallithea. | |
17 |
|
17 | |||
18 | For now, we use Bitbucket_ for `pull requests`_ and `issue tracking`_. The |
|
18 | For now, we use Bitbucket_ for `pull requests`_ and `issue tracking`_. The | |
19 | issue tracker is for tracking bugs, not for support, discussion, or ideas -- |
|
19 | issue tracker is for tracking bugs, not for support, discussion, or ideas -- | |
20 | please use the `mailing list`_ or :ref:`IRC <readme>` to reach the community. |
|
20 | please use the `mailing list`_ or :ref:`IRC <readme>` to reach the community. | |
21 |
|
21 | |||
22 | We use Weblate_ to translate the user interface messages into languages other |
|
22 | We use Weblate_ to translate the user interface messages into languages other | |
23 | than English. Join our project on `Hosted Weblate`_ to help us. |
|
23 | than English. Join our project on `Hosted Weblate`_ to help us. | |
24 | To register, you can use your Bitbucket or GitHub account. See :ref:`translations` |
|
24 | To register, you can use your Bitbucket or GitHub account. See :ref:`translations` | |
25 | for more details. |
|
25 | for more details. | |
26 |
|
26 | |||
27 |
|
27 | |||
28 | Getting started |
|
28 | Getting started | |
29 | --------------- |
|
29 | --------------- | |
30 |
|
30 | |||
31 | To get started with Kallithea development:: |
|
31 | To get started with Kallithea development:: | |
32 |
|
32 | |||
33 | hg clone https://kallithea-scm.org/repos/kallithea |
|
33 | hg clone https://kallithea-scm.org/repos/kallithea | |
34 | cd kallithea |
|
34 | cd kallithea | |
35 | virtualenv ../kallithea-venv |
|
35 | virtualenv ../kallithea-venv | |
36 | source ../kallithea-venv/bin/activate |
|
36 | source ../kallithea-venv/bin/activate | |
37 | pip install --upgrade pip setuptools |
|
37 | pip install --upgrade pip setuptools | |
38 | pip install --upgrade -e . |
|
38 | pip install --upgrade -e . | |
39 | pip install --upgrade -r dev_requirements.txt |
|
39 | pip install --upgrade -r dev_requirements.txt | |
40 |
npm |
|
40 | npm install # install dependencies - both tools and data | |
41 |
npm |
|
41 | npm run less # for generating css from less | |
42 | gearbox make-config my.ini |
|
42 | gearbox make-config my.ini | |
43 | gearbox setup-db -c my.ini --user=user --email=user@example.com --password=password --repos=/tmp |
|
43 | gearbox setup-db -c my.ini --user=user --email=user@example.com --password=password --repos=/tmp | |
44 | gearbox serve -c my.ini --reload & |
|
44 | gearbox serve -c my.ini --reload & | |
45 | firefox http://127.0.0.1:5000/ |
|
45 | firefox http://127.0.0.1:5000/ | |
46 |
|
46 | |||
47 | If you plan to use Bitbucket_ for sending contributions, you can also fork |
|
47 | If you plan to use Bitbucket_ for sending contributions, you can also fork | |
48 | Kallithea on Bitbucket_ first (https://bitbucket.org/conservancy/kallithea) and |
|
48 | Kallithea on Bitbucket_ first (https://bitbucket.org/conservancy/kallithea) and | |
49 | then replace the clone step above by a clone of your fork. In this case, please |
|
49 | then replace the clone step above by a clone of your fork. In this case, please | |
50 | see :ref:`contributing-guidelines` below for configuring your fork correctly. |
|
50 | see :ref:`contributing-guidelines` below for configuring your fork correctly. | |
51 |
|
51 | |||
52 |
|
52 | |||
53 | Contribution flow |
|
53 | Contribution flow | |
54 | ----------------- |
|
54 | ----------------- | |
55 |
|
55 | |||
56 | Starting from an existing Kallithea clone, make sure it is up to date with the |
|
56 | Starting from an existing Kallithea clone, make sure it is up to date with the | |
57 | latest upstream changes:: |
|
57 | latest upstream changes:: | |
58 |
|
58 | |||
59 | hg pull |
|
59 | hg pull | |
60 | hg update |
|
60 | hg update | |
61 |
|
61 | |||
62 | Review the :ref:`contributing-guidelines` and :ref:`coding-guidelines`. |
|
62 | Review the :ref:`contributing-guidelines` and :ref:`coding-guidelines`. | |
63 |
|
63 | |||
64 | If you are new to Mercurial, refer to Mercurial `Quick Start`_ and `Beginners |
|
64 | If you are new to Mercurial, refer to Mercurial `Quick Start`_ and `Beginners | |
65 | Guide`_ on the Mercurial wiki. |
|
65 | Guide`_ on the Mercurial wiki. | |
66 |
|
66 | |||
67 | Now, make some changes and test them (see :ref:`contributing-tests`). Don't |
|
67 | Now, make some changes and test them (see :ref:`contributing-tests`). Don't | |
68 | forget to add new tests to cover new functionality or bug fixes. |
|
68 | forget to add new tests to cover new functionality or bug fixes. | |
69 |
|
69 | |||
70 | For documentation changes, run ``make html`` from the ``docs`` directory to |
|
70 | For documentation changes, run ``make html`` from the ``docs`` directory to | |
71 | generate the HTML result, then review them in your browser. |
|
71 | generate the HTML result, then review them in your browser. | |
72 |
|
72 | |||
73 | Before submitting any changes, run the cleanup script:: |
|
73 | Before submitting any changes, run the cleanup script:: | |
74 |
|
74 | |||
75 | ./scripts/run-all-cleanup |
|
75 | ./scripts/run-all-cleanup | |
76 |
|
76 | |||
77 | When you are completely ready, you can send your changes to the community for |
|
77 | When you are completely ready, you can send your changes to the community for | |
78 | review and inclusion. Most commonly used methods are sending patches to the |
|
78 | review and inclusion. Most commonly used methods are sending patches to the | |
79 | mailing list (via ``hg email``) or by creating a pull request on Bitbucket_. |
|
79 | mailing list (via ``hg email``) or by creating a pull request on Bitbucket_. | |
80 |
|
80 | |||
81 | .. _contributing-tests: |
|
81 | .. _contributing-tests: | |
82 |
|
82 | |||
83 |
|
83 | |||
84 | Running tests |
|
84 | Running tests | |
85 | ------------- |
|
85 | ------------- | |
86 |
|
86 | |||
87 | After finishing your changes make sure all tests pass cleanly. Run the testsuite |
|
87 | After finishing your changes make sure all tests pass cleanly. Run the testsuite | |
88 | by invoking ``py.test`` from the project root:: |
|
88 | by invoking ``py.test`` from the project root:: | |
89 |
|
89 | |||
90 | py.test |
|
90 | py.test | |
91 |
|
91 | |||
92 | Note that testing on Python 2.6 also requires ``unittest2``. |
|
92 | Note that testing on Python 2.6 also requires ``unittest2``. | |
93 |
|
93 | |||
94 | Note that on unix systems, the temporary directory (``/tmp`` or where |
|
94 | Note that on unix systems, the temporary directory (``/tmp`` or where | |
95 | ``$TMPDIR`` points) must allow executable files; Git hooks must be executable, |
|
95 | ``$TMPDIR`` points) must allow executable files; Git hooks must be executable, | |
96 | and the test suite creates repositories in the temporary directory. Linux |
|
96 | and the test suite creates repositories in the temporary directory. Linux | |
97 | systems with /tmp mounted noexec will thus fail. |
|
97 | systems with /tmp mounted noexec will thus fail. | |
98 |
|
98 | |||
99 | You can also use ``tox`` to run the tests with all supported Python versions |
|
99 | You can also use ``tox`` to run the tests with all supported Python versions | |
100 | (currently Python 2.6--2.7). |
|
100 | (currently Python 2.6--2.7). | |
101 |
|
101 | |||
102 | When running tests, Kallithea uses `kallithea/tests/test.ini` and populates the |
|
102 | When running tests, Kallithea uses `kallithea/tests/test.ini` and populates the | |
103 | SQLite database specified there. |
|
103 | SQLite database specified there. | |
104 |
|
104 | |||
105 | It is possible to avoid recreating the full test database on each invocation of |
|
105 | It is possible to avoid recreating the full test database on each invocation of | |
106 | the tests, thus eliminating the initial delay. To achieve this, run the tests as:: |
|
106 | the tests, thus eliminating the initial delay. To achieve this, run the tests as:: | |
107 |
|
107 | |||
108 | gearbox serve -c kallithea/tests/test.ini --pid-file=test.pid --daemon |
|
108 | gearbox serve -c kallithea/tests/test.ini --pid-file=test.pid --daemon | |
109 | KALLITHEA_WHOOSH_TEST_DISABLE=1 KALLITHEA_NO_TMP_PATH=1 py.test |
|
109 | KALLITHEA_WHOOSH_TEST_DISABLE=1 KALLITHEA_NO_TMP_PATH=1 py.test | |
110 | kill -9 $(cat test.pid) |
|
110 | kill -9 $(cat test.pid) | |
111 |
|
111 | |||
112 | In these commands, the following variables are used:: |
|
112 | In these commands, the following variables are used:: | |
113 |
|
113 | |||
114 | KALLITHEA_WHOOSH_TEST_DISABLE=1 - skip whoosh index building and tests |
|
114 | KALLITHEA_WHOOSH_TEST_DISABLE=1 - skip whoosh index building and tests | |
115 | KALLITHEA_NO_TMP_PATH=1 - disable new temp path for tests, used mostly for testing_vcs_operations |
|
115 | KALLITHEA_NO_TMP_PATH=1 - disable new temp path for tests, used mostly for testing_vcs_operations | |
116 |
|
116 | |||
117 | You can run individual tests by specifying their path as argument to py.test. |
|
117 | You can run individual tests by specifying their path as argument to py.test. | |
118 | py.test also has many more options, see `py.test -h`. Some useful options |
|
118 | py.test also has many more options, see `py.test -h`. Some useful options | |
119 | are:: |
|
119 | are:: | |
120 |
|
120 | |||
121 | -k EXPRESSION only run tests which match the given substring |
|
121 | -k EXPRESSION only run tests which match the given substring | |
122 | expression. An expression is a python evaluable |
|
122 | expression. An expression is a python evaluable | |
123 | expression where all names are substring-matched |
|
123 | expression where all names are substring-matched | |
124 | against test names and their parent classes. Example: |
|
124 | against test names and their parent classes. Example: | |
125 | -x, --exitfirst exit instantly on first error or failed test. |
|
125 | -x, --exitfirst exit instantly on first error or failed test. | |
126 | --lf rerun only the tests that failed at the last run (or |
|
126 | --lf rerun only the tests that failed at the last run (or | |
127 | all if none failed) |
|
127 | all if none failed) | |
128 | --ff run all tests but run the last failures first. This |
|
128 | --ff run all tests but run the last failures first. This | |
129 | may re-order tests and thus lead to repeated fixture |
|
129 | may re-order tests and thus lead to repeated fixture | |
130 | setup/teardown |
|
130 | setup/teardown | |
131 | --pdb start the interactive Python debugger on errors. |
|
131 | --pdb start the interactive Python debugger on errors. | |
132 | -s, --capture=no don't capture stdout (any stdout output will be |
|
132 | -s, --capture=no don't capture stdout (any stdout output will be | |
133 | printed immediately) |
|
133 | printed immediately) | |
134 |
|
134 | |||
135 | Performance tests |
|
135 | Performance tests | |
136 | ^^^^^^^^^^^^^^^^^ |
|
136 | ^^^^^^^^^^^^^^^^^ | |
137 |
|
137 | |||
138 | A number of performance tests are present in the test suite, but they are |
|
138 | A number of performance tests are present in the test suite, but they are | |
139 | not run in a standard test run. These tests are useful to |
|
139 | not run in a standard test run. These tests are useful to | |
140 | evaluate the impact of certain code changes with respect to performance. |
|
140 | evaluate the impact of certain code changes with respect to performance. | |
141 |
|
141 | |||
142 | To run these tests:: |
|
142 | To run these tests:: | |
143 |
|
143 | |||
144 | env TEST_PERFORMANCE=1 py.test kallithea/tests/performance |
|
144 | env TEST_PERFORMANCE=1 py.test kallithea/tests/performance | |
145 |
|
145 | |||
146 | To analyze performance, you could install pytest-profiling_, which enables the |
|
146 | To analyze performance, you could install pytest-profiling_, which enables the | |
147 | --profile and --profile-svg options to py.test. |
|
147 | --profile and --profile-svg options to py.test. | |
148 |
|
148 | |||
149 | .. _pytest-profiling: https://github.com/manahl/pytest-plugins/tree/master/pytest-profiling |
|
149 | .. _pytest-profiling: https://github.com/manahl/pytest-plugins/tree/master/pytest-profiling | |
150 |
|
150 | |||
151 | .. _contributing-guidelines: |
|
151 | .. _contributing-guidelines: | |
152 |
|
152 | |||
153 |
|
153 | |||
154 | Contribution guidelines |
|
154 | Contribution guidelines | |
155 | ----------------------- |
|
155 | ----------------------- | |
156 |
|
156 | |||
157 | Kallithea is GPLv3 and we assume all contributions are made by the |
|
157 | Kallithea is GPLv3 and we assume all contributions are made by the | |
158 | committer/contributor and under GPLv3 unless explicitly stated. We do care a |
|
158 | committer/contributor and under GPLv3 unless explicitly stated. We do care a | |
159 | lot about preservation of copyright and license information for existing code |
|
159 | lot about preservation of copyright and license information for existing code | |
160 | that is brought into the project. |
|
160 | that is brought into the project. | |
161 |
|
161 | |||
162 | Contributions will be accepted in most formats -- such as pull requests on |
|
162 | Contributions will be accepted in most formats -- such as pull requests on | |
163 | Bitbucket, something hosted on your own Kallithea instance, or patches sent by |
|
163 | Bitbucket, something hosted on your own Kallithea instance, or patches sent by | |
164 | email to the `kallithea-general`_ mailing list. |
|
164 | email to the `kallithea-general`_ mailing list. | |
165 |
|
165 | |||
166 | When contributing via Bitbucket, please make your fork of |
|
166 | When contributing via Bitbucket, please make your fork of | |
167 | https://bitbucket.org/conservancy/kallithea/ `non-publishing`_ -- it is one of |
|
167 | https://bitbucket.org/conservancy/kallithea/ `non-publishing`_ -- it is one of | |
168 | the settings on "Repository details" page. This ensures your commits are in |
|
168 | the settings on "Repository details" page. This ensures your commits are in | |
169 | "draft" phase and makes it easier for you to address feedback and for project |
|
169 | "draft" phase and makes it easier for you to address feedback and for project | |
170 | maintainers to integrate your changes. |
|
170 | maintainers to integrate your changes. | |
171 |
|
171 | |||
172 | .. _non-publishing: https://www.mercurial-scm.org/wiki/Phases#Publishing_Repository |
|
172 | .. _non-publishing: https://www.mercurial-scm.org/wiki/Phases#Publishing_Repository | |
173 |
|
173 | |||
174 | Make sure to test your changes both manually and with the automatic tests |
|
174 | Make sure to test your changes both manually and with the automatic tests | |
175 | before posting. |
|
175 | before posting. | |
176 |
|
176 | |||
177 | We care about quality and review and keeping a clean repository history. We |
|
177 | We care about quality and review and keeping a clean repository history. We | |
178 | might give feedback that requests polishing contributions until they are |
|
178 | might give feedback that requests polishing contributions until they are | |
179 | "perfect". We might also rebase and collapse and make minor adjustments to your |
|
179 | "perfect". We might also rebase and collapse and make minor adjustments to your | |
180 | changes when we apply them. |
|
180 | changes when we apply them. | |
181 |
|
181 | |||
182 | We try to make sure we have consensus on the direction the project is taking. |
|
182 | We try to make sure we have consensus on the direction the project is taking. | |
183 | Everything non-sensitive should be discussed in public -- preferably on the |
|
183 | Everything non-sensitive should be discussed in public -- preferably on the | |
184 | mailing list. We aim at having all non-trivial changes reviewed by at least |
|
184 | mailing list. We aim at having all non-trivial changes reviewed by at least | |
185 | one other core developer before pushing. Obvious non-controversial changes will |
|
185 | one other core developer before pushing. Obvious non-controversial changes will | |
186 | be handled more casually. |
|
186 | be handled more casually. | |
187 |
|
187 | |||
188 | There is a main development branch ("default") which is generally stable so that |
|
188 | There is a main development branch ("default") which is generally stable so that | |
189 | it can be (and is) used in production. There is also a "stable" branch that is |
|
189 | it can be (and is) used in production. There is also a "stable" branch that is | |
190 | almost exclusively reserved for bug fixes or trivial changes. Experimental |
|
190 | almost exclusively reserved for bug fixes or trivial changes. Experimental | |
191 | changes should live elsewhere (for example in a pull request) until they are |
|
191 | changes should live elsewhere (for example in a pull request) until they are | |
192 | ready. |
|
192 | ready. | |
193 |
|
193 | |||
194 | .. _coding-guidelines: |
|
194 | .. _coding-guidelines: | |
195 |
|
195 | |||
196 |
|
196 | |||
197 | Coding guidelines |
|
197 | Coding guidelines | |
198 | ----------------- |
|
198 | ----------------- | |
199 |
|
199 | |||
200 | We don't have a formal coding/formatting standard. We are currently using a mix |
|
200 | We don't have a formal coding/formatting standard. We are currently using a mix | |
201 | of Mercurial's (https://www.mercurial-scm.org/wiki/CodingStyle), pep8, and |
|
201 | of Mercurial's (https://www.mercurial-scm.org/wiki/CodingStyle), pep8, and | |
202 | consistency with existing code. Run ``scripts/run-all-cleanup`` before |
|
202 | consistency with existing code. Run ``scripts/run-all-cleanup`` before | |
203 | committing to ensure some basic code formatting consistency. |
|
203 | committing to ensure some basic code formatting consistency. | |
204 |
|
204 | |||
205 | We support both Python 2.6.x and 2.7.x and nothing else. For now we don't care |
|
205 | We support both Python 2.6.x and 2.7.x and nothing else. For now we don't care | |
206 | about Python 3 compatibility. |
|
206 | about Python 3 compatibility. | |
207 |
|
207 | |||
208 | We try to support the most common modern web browsers. IE9 is still supported |
|
208 | We try to support the most common modern web browsers. IE9 is still supported | |
209 | to the extent it is feasible, IE8 is not. |
|
209 | to the extent it is feasible, IE8 is not. | |
210 |
|
210 | |||
211 | We primarily support Linux and OS X on the server side but Windows should also work. |
|
211 | We primarily support Linux and OS X on the server side but Windows should also work. | |
212 |
|
212 | |||
213 | HTML templates should use 2 spaces for indentation ... but be pragmatic. We |
|
213 | HTML templates should use 2 spaces for indentation ... but be pragmatic. We | |
214 | should use templates cleverly and avoid duplication. We should use reasonable |
|
214 | should use templates cleverly and avoid duplication. We should use reasonable | |
215 | semantic markup with element classes and IDs that can be used for styling and testing. |
|
215 | semantic markup with element classes and IDs that can be used for styling and testing. | |
216 | We should only use inline styles in places where it really is semantic (such as |
|
216 | We should only use inline styles in places where it really is semantic (such as | |
217 | ``display: none``). |
|
217 | ``display: none``). | |
218 |
|
218 | |||
219 | JavaScript must use ``;`` between/after statements. Indentation 4 spaces. Inline |
|
219 | JavaScript must use ``;`` between/after statements. Indentation 4 spaces. Inline | |
220 | multiline functions should be indented two levels -- one for the ``()`` and one for |
|
220 | multiline functions should be indented two levels -- one for the ``()`` and one for | |
221 | ``{}``. |
|
221 | ``{}``. | |
222 | Variables holding jQuery objects should be named with a leading ``$``. |
|
222 | Variables holding jQuery objects should be named with a leading ``$``. | |
223 |
|
223 | |||
224 | Commit messages should have a leading short line summarizing the changes. For |
|
224 | Commit messages should have a leading short line summarizing the changes. For | |
225 | bug fixes, put ``(Issue #123)`` at the end of this line. |
|
225 | bug fixes, put ``(Issue #123)`` at the end of this line. | |
226 |
|
226 | |||
227 | Use American English grammar and spelling overall. Use `English title case`_ for |
|
227 | Use American English grammar and spelling overall. Use `English title case`_ for | |
228 | page titles, button labels, headers, and 'labels' for fields in forms. |
|
228 | page titles, button labels, headers, and 'labels' for fields in forms. | |
229 |
|
229 | |||
230 | .. _English title case: https://en.wikipedia.org/wiki/Capitalization#Title_case |
|
230 | .. _English title case: https://en.wikipedia.org/wiki/Capitalization#Title_case | |
231 |
|
231 | |||
232 | Template helpers (that is, everything in ``kallithea.lib.helpers``) |
|
232 | Template helpers (that is, everything in ``kallithea.lib.helpers``) | |
233 | should only be referenced from templates. If you need to call a |
|
233 | should only be referenced from templates. If you need to call a | |
234 | helper from the Python code, consider moving the function somewhere |
|
234 | helper from the Python code, consider moving the function somewhere | |
235 | else (e.g. to the model). |
|
235 | else (e.g. to the model). | |
236 |
|
236 | |||
237 | Notes on the SQLAlchemy session |
|
237 | Notes on the SQLAlchemy session | |
238 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
|
238 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
239 |
|
239 | |||
240 | Each HTTP request runs inside an independent SQLAlchemy session (as well |
|
240 | Each HTTP request runs inside an independent SQLAlchemy session (as well | |
241 | as in an independent database transaction). ``Session`` is the session manager |
|
241 | as in an independent database transaction). ``Session`` is the session manager | |
242 | and factory. ``Session()`` will create a new session on-demand or return the |
|
242 | and factory. ``Session()`` will create a new session on-demand or return the | |
243 | current session for the active thread. Many database operations are methods on |
|
243 | current session for the active thread. Many database operations are methods on | |
244 | such session instances - only ``Session.remove()`` should be called directly on |
|
244 | such session instances - only ``Session.remove()`` should be called directly on | |
245 | the manager. |
|
245 | the manager. | |
246 |
|
246 | |||
247 | Database model objects |
|
247 | Database model objects | |
248 | (almost) always belong to a particular SQLAlchemy session, which means |
|
248 | (almost) always belong to a particular SQLAlchemy session, which means | |
249 | that SQLAlchemy will ensure that they're kept in sync with the database |
|
249 | that SQLAlchemy will ensure that they're kept in sync with the database | |
250 | (but also means that they cannot be shared across requests). |
|
250 | (but also means that they cannot be shared across requests). | |
251 |
|
251 | |||
252 | Objects can be added to the session using ``Session().add``, but this is |
|
252 | Objects can be added to the session using ``Session().add``, but this is | |
253 | rarely needed: |
|
253 | rarely needed: | |
254 |
|
254 | |||
255 | * When creating a database object by calling the constructor directly, |
|
255 | * When creating a database object by calling the constructor directly, | |
256 | it must explicitly be added to the session. |
|
256 | it must explicitly be added to the session. | |
257 |
|
257 | |||
258 | * When creating an object using a factory function (like |
|
258 | * When creating an object using a factory function (like | |
259 | ``create_repo``), the returned object has already (by convention) |
|
259 | ``create_repo``), the returned object has already (by convention) | |
260 | been added to the session, and should not be added again. |
|
260 | been added to the session, and should not be added again. | |
261 |
|
261 | |||
262 | * When getting an object from the session (via ``Session().query`` or |
|
262 | * When getting an object from the session (via ``Session().query`` or | |
263 | any of the utility functions that look up objects in the database), |
|
263 | any of the utility functions that look up objects in the database), | |
264 | it's already part of the session, and should not be added again. |
|
264 | it's already part of the session, and should not be added again. | |
265 | SQLAlchemy monitors attribute modifications automatically for all |
|
265 | SQLAlchemy monitors attribute modifications automatically for all | |
266 | objects it knows about and syncs them to the database. |
|
266 | objects it knows about and syncs them to the database. | |
267 |
|
267 | |||
268 | SQLAlchemy also flushes changes to the database automatically; manually |
|
268 | SQLAlchemy also flushes changes to the database automatically; manually | |
269 | calling ``Session().flush`` is usually only necessary when the Python |
|
269 | calling ``Session().flush`` is usually only necessary when the Python | |
270 | code needs the database to assign an "auto-increment" primary key ID to |
|
270 | code needs the database to assign an "auto-increment" primary key ID to | |
271 | a freshly created model object (before flushing, the ID attribute will |
|
271 | a freshly created model object (before flushing, the ID attribute will | |
272 | be ``None``). |
|
272 | be ``None``). | |
273 |
|
273 | |||
274 | TurboGears2 DebugBar |
|
274 | TurboGears2 DebugBar | |
275 | ^^^^^^^^^^^^^^^^^^^^ |
|
275 | ^^^^^^^^^^^^^^^^^^^^ | |
276 |
|
276 | |||
277 | It is possible to enable the TurboGears2-provided DebugBar_, a toolbar overlayed |
|
277 | It is possible to enable the TurboGears2-provided DebugBar_, a toolbar overlayed | |
278 | over the Kallithea web interface, allowing you to see: |
|
278 | over the Kallithea web interface, allowing you to see: | |
279 |
|
279 | |||
280 | * timing information of the current request, including profiling information |
|
280 | * timing information of the current request, including profiling information | |
281 | * request data, including GET data, POST data, cookies, headers and environment |
|
281 | * request data, including GET data, POST data, cookies, headers and environment | |
282 | variables |
|
282 | variables | |
283 | * a list of executed database queries, including timing and result values |
|
283 | * a list of executed database queries, including timing and result values | |
284 |
|
284 | |||
285 | DebugBar is only activated when ``debug = true`` is set in the configuration |
|
285 | DebugBar is only activated when ``debug = true`` is set in the configuration | |
286 | file. This is important, because the DebugBar toolbar will be visible for all |
|
286 | file. This is important, because the DebugBar toolbar will be visible for all | |
287 | users, and allow them to see information they should not be allowed to see. Like |
|
287 | users, and allow them to see information they should not be allowed to see. Like | |
288 | is anyway the case for ``debug = true``, do not use this in production! |
|
288 | is anyway the case for ``debug = true``, do not use this in production! | |
289 |
|
289 | |||
290 | To enable DebugBar, install ``tgext.debugbar`` and ``kajiki`` (typically via |
|
290 | To enable DebugBar, install ``tgext.debugbar`` and ``kajiki`` (typically via | |
291 | ``pip``) and restart Kallithea (in debug mode). |
|
291 | ``pip``) and restart Kallithea (in debug mode). | |
292 |
|
292 | |||
293 |
|
293 | |||
294 | "Roadmap" |
|
294 | "Roadmap" | |
295 | --------- |
|
295 | --------- | |
296 |
|
296 | |||
297 | We do not have a road map but are waiting for your contributions. Refer to the |
|
297 | We do not have a road map but are waiting for your contributions. Refer to the | |
298 | wiki_ for some ideas of places we might want to go -- contributions in these |
|
298 | wiki_ for some ideas of places we might want to go -- contributions in these | |
299 | areas are very welcome. |
|
299 | areas are very welcome. | |
300 |
|
300 | |||
301 |
|
301 | |||
302 | Thank you for your contribution! |
|
302 | Thank you for your contribution! | |
303 | -------------------------------- |
|
303 | -------------------------------- | |
304 |
|
304 | |||
305 |
|
305 | |||
306 | .. _Weblate: http://weblate.org/ |
|
306 | .. _Weblate: http://weblate.org/ | |
307 | .. _issue tracking: https://bitbucket.org/conservancy/kallithea/issues?status=new&status=open |
|
307 | .. _issue tracking: https://bitbucket.org/conservancy/kallithea/issues?status=new&status=open | |
308 | .. _pull requests: https://bitbucket.org/conservancy/kallithea/pull-requests |
|
308 | .. _pull requests: https://bitbucket.org/conservancy/kallithea/pull-requests | |
309 | .. _bitbucket: http://bitbucket.org/ |
|
309 | .. _bitbucket: http://bitbucket.org/ | |
310 | .. _mailing list: http://lists.sfconservancy.org/mailman/listinfo/kallithea-general |
|
310 | .. _mailing list: http://lists.sfconservancy.org/mailman/listinfo/kallithea-general | |
311 | .. _kallithea-general: http://lists.sfconservancy.org/mailman/listinfo/kallithea-general |
|
311 | .. _kallithea-general: http://lists.sfconservancy.org/mailman/listinfo/kallithea-general | |
312 | .. _Hosted Weblate: https://hosted.weblate.org/projects/kallithea/kallithea/ |
|
312 | .. _Hosted Weblate: https://hosted.weblate.org/projects/kallithea/kallithea/ | |
313 | .. _wiki: https://bitbucket.org/conservancy/kallithea/wiki/Home |
|
313 | .. _wiki: https://bitbucket.org/conservancy/kallithea/wiki/Home | |
314 | .. _DebugBar: https://github.com/TurboGears/tgext.debugbar |
|
314 | .. _DebugBar: https://github.com/TurboGears/tgext.debugbar | |
315 | .. _Quick Start: https://www.mercurial-scm.org/wiki/QuickStart |
|
315 | .. _Quick Start: https://www.mercurial-scm.org/wiki/QuickStart | |
316 | .. _Beginners Guide: https://www.mercurial-scm.org/wiki/BeginnersGuides |
|
316 | .. _Beginners Guide: https://www.mercurial-scm.org/wiki/BeginnersGuides |
@@ -1,911 +1,911 b'' | |||||
1 | .. _setup: |
|
1 | .. _setup: | |
2 |
|
2 | |||
3 | ===== |
|
3 | ===== | |
4 | Setup |
|
4 | Setup | |
5 | ===== |
|
5 | ===== | |
6 |
|
6 | |||
7 |
|
7 | |||
8 | Preparing front-end |
|
8 | Preparing front-end | |
9 | ------------------- |
|
9 | ------------------- | |
10 |
|
10 | |||
11 | Temporarily, in the current Kallithea version, some extra steps are required to |
|
11 | Temporarily, in the current Kallithea version, some extra steps are required to | |
12 | build front-end files: |
|
12 | build front-end files: | |
13 |
|
13 | |||
14 | Find the right ``kallithea/public/less`` path with:: |
|
14 | Find the right ``kallithea/public/less`` path with:: | |
15 |
|
15 | |||
16 | python -c "import os, kallithea; print os.path.join(os.path.dirname(os.path.abspath(kallithea.__file__)), 'public', 'less')" |
|
16 | python -c "import os, kallithea; print os.path.join(os.path.dirname(os.path.abspath(kallithea.__file__)), 'public', 'less')" | |
17 |
|
17 | |||
18 | Then run:: |
|
18 | Then run:: | |
19 |
|
19 | |||
20 | npm --prefix kallithea/public/less install |
|
20 | npm install | |
21 | npm --prefix kallithea/public/less run less |
|
21 | npm run less | |
22 |
|
22 | |||
23 |
|
23 | |||
24 | Setting up Kallithea |
|
24 | Setting up Kallithea | |
25 | -------------------- |
|
25 | -------------------- | |
26 |
|
26 | |||
27 | First, you will need to create a Kallithea configuration file. Run the |
|
27 | First, you will need to create a Kallithea configuration file. Run the | |
28 | following command to do so:: |
|
28 | following command to do so:: | |
29 |
|
29 | |||
30 | gearbox make-config my.ini |
|
30 | gearbox make-config my.ini | |
31 |
|
31 | |||
32 | This will create the file ``my.ini`` in the current directory. This |
|
32 | This will create the file ``my.ini`` in the current directory. This | |
33 | configuration file contains the various settings for Kallithea, e.g. |
|
33 | configuration file contains the various settings for Kallithea, e.g. | |
34 | proxy port, email settings, usage of static files, cache, Celery |
|
34 | proxy port, email settings, usage of static files, cache, Celery | |
35 | settings, and logging. Extra settings can be specified like:: |
|
35 | settings, and logging. Extra settings can be specified like:: | |
36 |
|
36 | |||
37 | gearbox make-config my.ini host=8.8.8.8 "[handler_console]" formatter=color_formatter |
|
37 | gearbox make-config my.ini host=8.8.8.8 "[handler_console]" formatter=color_formatter | |
38 |
|
38 | |||
39 | Next, you need to create the databases used by Kallithea. It is recommended to |
|
39 | Next, you need to create the databases used by Kallithea. It is recommended to | |
40 | use PostgreSQL or SQLite (default). If you choose a database other than the |
|
40 | use PostgreSQL or SQLite (default). If you choose a database other than the | |
41 | default, ensure you properly adjust the database URL in your ``my.ini`` |
|
41 | default, ensure you properly adjust the database URL in your ``my.ini`` | |
42 | configuration file to use this other database. Kallithea currently supports |
|
42 | configuration file to use this other database. Kallithea currently supports | |
43 | PostgreSQL, SQLite and MySQL databases. Create the database by running |
|
43 | PostgreSQL, SQLite and MySQL databases. Create the database by running | |
44 | the following command:: |
|
44 | the following command:: | |
45 |
|
45 | |||
46 | gearbox setup-db -c my.ini |
|
46 | gearbox setup-db -c my.ini | |
47 |
|
47 | |||
48 | This will prompt you for a "root" path. This "root" path is the location where |
|
48 | This will prompt you for a "root" path. This "root" path is the location where | |
49 | Kallithea will store all of its repositories on the current machine. After |
|
49 | Kallithea will store all of its repositories on the current machine. After | |
50 | entering this "root" path ``setup-db`` will also prompt you for a username |
|
50 | entering this "root" path ``setup-db`` will also prompt you for a username | |
51 | and password for the initial admin account which ``setup-db`` sets |
|
51 | and password for the initial admin account which ``setup-db`` sets | |
52 | up for you. |
|
52 | up for you. | |
53 |
|
53 | |||
54 | The ``setup-db`` values can also be given on the command line. |
|
54 | The ``setup-db`` values can also be given on the command line. | |
55 | Example:: |
|
55 | Example:: | |
56 |
|
56 | |||
57 | gearbox setup-db -c my.ini --user=nn --password=secret --email=nn@example.com --repos=/srv/repos |
|
57 | gearbox setup-db -c my.ini --user=nn --password=secret --email=nn@example.com --repos=/srv/repos | |
58 |
|
58 | |||
59 | The ``setup-db`` command will create all needed tables and an |
|
59 | The ``setup-db`` command will create all needed tables and an | |
60 | admin account. When choosing a root path you can either use a new |
|
60 | admin account. When choosing a root path you can either use a new | |
61 | empty location, or a location which already contains existing |
|
61 | empty location, or a location which already contains existing | |
62 | repositories. If you choose a location which contains existing |
|
62 | repositories. If you choose a location which contains existing | |
63 | repositories Kallithea will add all of the repositories at the chosen |
|
63 | repositories Kallithea will add all of the repositories at the chosen | |
64 | location to its database. (Note: make sure you specify the correct |
|
64 | location to its database. (Note: make sure you specify the correct | |
65 | path to the root). |
|
65 | path to the root). | |
66 |
|
66 | |||
67 | .. note:: the given path for Mercurial_ repositories **must** be write |
|
67 | .. note:: the given path for Mercurial_ repositories **must** be write | |
68 | accessible for the application. It's very important since |
|
68 | accessible for the application. It's very important since | |
69 | the Kallithea web interface will work without write access, |
|
69 | the Kallithea web interface will work without write access, | |
70 | but when trying to do a push it will fail with permission |
|
70 | but when trying to do a push it will fail with permission | |
71 | denied errors unless it has write access. |
|
71 | denied errors unless it has write access. | |
72 |
|
72 | |||
73 | You are now ready to use Kallithea. To run it simply execute:: |
|
73 | You are now ready to use Kallithea. To run it simply execute:: | |
74 |
|
74 | |||
75 | gearbox serve -c my.ini |
|
75 | gearbox serve -c my.ini | |
76 |
|
76 | |||
77 | - This command runs the Kallithea server. The web app should be available at |
|
77 | - This command runs the Kallithea server. The web app should be available at | |
78 | http://127.0.0.1:5000. The IP address and port is configurable via the |
|
78 | http://127.0.0.1:5000. The IP address and port is configurable via the | |
79 | configuration file created in the previous step. |
|
79 | configuration file created in the previous step. | |
80 | - Log in to Kallithea using the admin account created when running ``setup-db``. |
|
80 | - Log in to Kallithea using the admin account created when running ``setup-db``. | |
81 | - The default permissions on each repository is read, and the owner is admin. |
|
81 | - The default permissions on each repository is read, and the owner is admin. | |
82 | Remember to update these if needed. |
|
82 | Remember to update these if needed. | |
83 | - In the admin panel you can toggle LDAP, anonymous, and permissions |
|
83 | - In the admin panel you can toggle LDAP, anonymous, and permissions | |
84 | settings, as well as edit more advanced options on users and |
|
84 | settings, as well as edit more advanced options on users and | |
85 | repositories. |
|
85 | repositories. | |
86 |
|
86 | |||
87 |
|
87 | |||
88 | Internationalization (i18n support) |
|
88 | Internationalization (i18n support) | |
89 | ----------------------------------- |
|
89 | ----------------------------------- | |
90 |
|
90 | |||
91 | The Kallithea web interface is automatically displayed in the user's preferred |
|
91 | The Kallithea web interface is automatically displayed in the user's preferred | |
92 | language, as indicated by the browser. Thus, different users may see the |
|
92 | language, as indicated by the browser. Thus, different users may see the | |
93 | application in different languages. If the requested language is not available |
|
93 | application in different languages. If the requested language is not available | |
94 | (because the translation file for that language does not yet exist or is |
|
94 | (because the translation file for that language does not yet exist or is | |
95 | incomplete), the language specified in setting ``i18n.lang`` in the Kallithea |
|
95 | incomplete), the language specified in setting ``i18n.lang`` in the Kallithea | |
96 | configuration file is used as fallback. If no fallback language is explicitly |
|
96 | configuration file is used as fallback. If no fallback language is explicitly | |
97 | specified, English is used. |
|
97 | specified, English is used. | |
98 |
|
98 | |||
99 | If you want to disable automatic language detection and instead configure a |
|
99 | If you want to disable automatic language detection and instead configure a | |
100 | fixed language regardless of user preference, set ``i18n.enabled = false`` and |
|
100 | fixed language regardless of user preference, set ``i18n.enabled = false`` and | |
101 | set ``i18n.lang`` to the desired language (or leave empty for English). |
|
101 | set ``i18n.lang`` to the desired language (or leave empty for English). | |
102 |
|
102 | |||
103 |
|
103 | |||
104 | Using Kallithea with SSH |
|
104 | Using Kallithea with SSH | |
105 | ------------------------ |
|
105 | ------------------------ | |
106 |
|
106 | |||
107 | Kallithea currently only hosts repositories using http and https. (The addition |
|
107 | Kallithea currently only hosts repositories using http and https. (The addition | |
108 | of ssh hosting is a planned future feature.) However you can easily use ssh in |
|
108 | of ssh hosting is a planned future feature.) However you can easily use ssh in | |
109 | parallel with Kallithea. (Repository access via ssh is a standard "out of |
|
109 | parallel with Kallithea. (Repository access via ssh is a standard "out of | |
110 | the box" feature of Mercurial_ and you can use this to access any of the |
|
110 | the box" feature of Mercurial_ and you can use this to access any of the | |
111 | repositories that Kallithea is hosting. See PublishingRepositories_) |
|
111 | repositories that Kallithea is hosting. See PublishingRepositories_) | |
112 |
|
112 | |||
113 | Kallithea repository structures are kept in directories with the same name |
|
113 | Kallithea repository structures are kept in directories with the same name | |
114 | as the project. When using repository groups, each group is a subdirectory. |
|
114 | as the project. When using repository groups, each group is a subdirectory. | |
115 | This allows you to easily use ssh for accessing repositories. |
|
115 | This allows you to easily use ssh for accessing repositories. | |
116 |
|
116 | |||
117 | In order to use ssh you need to make sure that your web server and the users' |
|
117 | In order to use ssh you need to make sure that your web server and the users' | |
118 | login accounts have the correct permissions set on the appropriate directories. |
|
118 | login accounts have the correct permissions set on the appropriate directories. | |
119 |
|
119 | |||
120 | .. note:: These permissions are independent of any permissions you |
|
120 | .. note:: These permissions are independent of any permissions you | |
121 | have set up using the Kallithea web interface. |
|
121 | have set up using the Kallithea web interface. | |
122 |
|
122 | |||
123 | If your main directory (the same as set in Kallithea settings) is for |
|
123 | If your main directory (the same as set in Kallithea settings) is for | |
124 | example set to ``/srv/repos`` and the repository you are using is |
|
124 | example set to ``/srv/repos`` and the repository you are using is | |
125 | named ``kallithea``, then to clone via ssh you should run:: |
|
125 | named ``kallithea``, then to clone via ssh you should run:: | |
126 |
|
126 | |||
127 | hg clone ssh://user@kallithea.example.com/srv/repos/kallithea |
|
127 | hg clone ssh://user@kallithea.example.com/srv/repos/kallithea | |
128 |
|
128 | |||
129 | Using other external tools such as mercurial-server_ or using ssh key-based |
|
129 | Using other external tools such as mercurial-server_ or using ssh key-based | |
130 | authentication is fully supported. |
|
130 | authentication is fully supported. | |
131 |
|
131 | |||
132 | .. note:: In an advanced setup, in order for your ssh access to use |
|
132 | .. note:: In an advanced setup, in order for your ssh access to use | |
133 | the same permissions as set up via the Kallithea web |
|
133 | the same permissions as set up via the Kallithea web | |
134 | interface, you can create an authentication hook to connect |
|
134 | interface, you can create an authentication hook to connect | |
135 | to the Kallithea db and run check functions for permissions |
|
135 | to the Kallithea db and run check functions for permissions | |
136 | against that. |
|
136 | against that. | |
137 |
|
137 | |||
138 |
|
138 | |||
139 | Setting up Whoosh full text search |
|
139 | Setting up Whoosh full text search | |
140 | ---------------------------------- |
|
140 | ---------------------------------- | |
141 |
|
141 | |||
142 | Kallithea provides full text search of repositories using `Whoosh`__. |
|
142 | Kallithea provides full text search of repositories using `Whoosh`__. | |
143 |
|
143 | |||
144 | .. __: https://pythonhosted.org/Whoosh/ |
|
144 | .. __: https://pythonhosted.org/Whoosh/ | |
145 |
|
145 | |||
146 | For an incremental index build, run:: |
|
146 | For an incremental index build, run:: | |
147 |
|
147 | |||
148 | gearbox make-index -c my.ini |
|
148 | gearbox make-index -c my.ini | |
149 |
|
149 | |||
150 | For a full index rebuild, run:: |
|
150 | For a full index rebuild, run:: | |
151 |
|
151 | |||
152 | gearbox make-index -c my.ini -f |
|
152 | gearbox make-index -c my.ini -f | |
153 |
|
153 | |||
154 | The ``--repo-location`` option allows the location of the repositories to be overridden; |
|
154 | The ``--repo-location`` option allows the location of the repositories to be overridden; | |
155 | usually, the location is retrieved from the Kallithea database. |
|
155 | usually, the location is retrieved from the Kallithea database. | |
156 |
|
156 | |||
157 | The ``--index-only`` option can be used to limit the indexed repositories to a comma-separated list:: |
|
157 | The ``--index-only`` option can be used to limit the indexed repositories to a comma-separated list:: | |
158 |
|
158 | |||
159 | gearbox make-index -c my.ini --index-only=vcs,kallithea |
|
159 | gearbox make-index -c my.ini --index-only=vcs,kallithea | |
160 |
|
160 | |||
161 | To keep your index up-to-date it is necessary to do periodic index builds; |
|
161 | To keep your index up-to-date it is necessary to do periodic index builds; | |
162 | for this, it is recommended to use a crontab entry. Example:: |
|
162 | for this, it is recommended to use a crontab entry. Example:: | |
163 |
|
163 | |||
164 | 0 3 * * * /path/to/virtualenv/bin/gearbox make-index -c /path/to/kallithea/my.ini |
|
164 | 0 3 * * * /path/to/virtualenv/bin/gearbox make-index -c /path/to/kallithea/my.ini | |
165 |
|
165 | |||
166 | When using incremental mode (the default), Whoosh will check the last |
|
166 | When using incremental mode (the default), Whoosh will check the last | |
167 | modification date of each file and add it to be reindexed if a newer file is |
|
167 | modification date of each file and add it to be reindexed if a newer file is | |
168 | available. The indexing daemon checks for any removed files and removes them |
|
168 | available. The indexing daemon checks for any removed files and removes them | |
169 | from index. |
|
169 | from index. | |
170 |
|
170 | |||
171 | If you want to rebuild the index from scratch, you can use the ``-f`` flag as above, |
|
171 | If you want to rebuild the index from scratch, you can use the ``-f`` flag as above, | |
172 | or in the admin panel you can check the "build from scratch" checkbox. |
|
172 | or in the admin panel you can check the "build from scratch" checkbox. | |
173 |
|
173 | |||
174 | .. _ldap-setup: |
|
174 | .. _ldap-setup: | |
175 |
|
175 | |||
176 |
|
176 | |||
177 | Setting up LDAP support |
|
177 | Setting up LDAP support | |
178 | ----------------------- |
|
178 | ----------------------- | |
179 |
|
179 | |||
180 | Kallithea supports LDAP authentication. In order |
|
180 | Kallithea supports LDAP authentication. In order | |
181 | to use LDAP, you have to install the python-ldap_ package. This package is |
|
181 | to use LDAP, you have to install the python-ldap_ package. This package is | |
182 | available via PyPI, so you can install it by running:: |
|
182 | available via PyPI, so you can install it by running:: | |
183 |
|
183 | |||
184 | pip install python-ldap |
|
184 | pip install python-ldap | |
185 |
|
185 | |||
186 | .. note:: ``python-ldap`` requires some libraries to be installed on |
|
186 | .. note:: ``python-ldap`` requires some libraries to be installed on | |
187 | your system, so before installing it check that you have at |
|
187 | your system, so before installing it check that you have at | |
188 | least the ``openldap`` and ``sasl`` libraries. |
|
188 | least the ``openldap`` and ``sasl`` libraries. | |
189 |
|
189 | |||
190 | Choose *Admin > Authentication*, click the ``kallithea.lib.auth_modules.auth_ldap`` button |
|
190 | Choose *Admin > Authentication*, click the ``kallithea.lib.auth_modules.auth_ldap`` button | |
191 | and then *Save*, to enable the LDAP plugin and configure its settings. |
|
191 | and then *Save*, to enable the LDAP plugin and configure its settings. | |
192 |
|
192 | |||
193 | Here's a typical LDAP setup:: |
|
193 | Here's a typical LDAP setup:: | |
194 |
|
194 | |||
195 | Connection settings |
|
195 | Connection settings | |
196 | Enable LDAP = checked |
|
196 | Enable LDAP = checked | |
197 | Host = host.example.com |
|
197 | Host = host.example.com | |
198 | Account = <account> |
|
198 | Account = <account> | |
199 | Password = <password> |
|
199 | Password = <password> | |
200 | Connection Security = LDAPS |
|
200 | Connection Security = LDAPS | |
201 | Certificate Checks = DEMAND |
|
201 | Certificate Checks = DEMAND | |
202 |
|
202 | |||
203 | Search settings |
|
203 | Search settings | |
204 | Base DN = CN=users,DC=host,DC=example,DC=org |
|
204 | Base DN = CN=users,DC=host,DC=example,DC=org | |
205 | LDAP Filter = (&(objectClass=user)(!(objectClass=computer))) |
|
205 | LDAP Filter = (&(objectClass=user)(!(objectClass=computer))) | |
206 | LDAP Search Scope = SUBTREE |
|
206 | LDAP Search Scope = SUBTREE | |
207 |
|
207 | |||
208 | Attribute mappings |
|
208 | Attribute mappings | |
209 | Login Attribute = uid |
|
209 | Login Attribute = uid | |
210 | First Name Attribute = firstName |
|
210 | First Name Attribute = firstName | |
211 | Last Name Attribute = lastName |
|
211 | Last Name Attribute = lastName | |
212 | Email Attribute = mail |
|
212 | Email Attribute = mail | |
213 |
|
213 | |||
214 | If your user groups are placed in an Organisation Unit (OU) structure, the Search Settings configuration differs:: |
|
214 | If your user groups are placed in an Organisation Unit (OU) structure, the Search Settings configuration differs:: | |
215 |
|
215 | |||
216 | Search settings |
|
216 | Search settings | |
217 | Base DN = DC=host,DC=example,DC=org |
|
217 | Base DN = DC=host,DC=example,DC=org | |
218 | LDAP Filter = (&(memberOf=CN=your user group,OU=subunit,OU=unit,DC=host,DC=example,DC=org)(objectClass=user)) |
|
218 | LDAP Filter = (&(memberOf=CN=your user group,OU=subunit,OU=unit,DC=host,DC=example,DC=org)(objectClass=user)) | |
219 | LDAP Search Scope = SUBTREE |
|
219 | LDAP Search Scope = SUBTREE | |
220 |
|
220 | |||
221 | .. _enable_ldap: |
|
221 | .. _enable_ldap: | |
222 |
|
222 | |||
223 | Enable LDAP : required |
|
223 | Enable LDAP : required | |
224 | Whether to use LDAP for authenticating users. |
|
224 | Whether to use LDAP for authenticating users. | |
225 |
|
225 | |||
226 | .. _ldap_host: |
|
226 | .. _ldap_host: | |
227 |
|
227 | |||
228 | Host : required |
|
228 | Host : required | |
229 | LDAP server hostname or IP address. Can be also a comma separated |
|
229 | LDAP server hostname or IP address. Can be also a comma separated | |
230 | list of servers to support LDAP fail-over. |
|
230 | list of servers to support LDAP fail-over. | |
231 |
|
231 | |||
232 | .. _Port: |
|
232 | .. _Port: | |
233 |
|
233 | |||
234 | Port : optional |
|
234 | Port : optional | |
235 | Defaults to 389 for PLAIN un-encrypted LDAP and START_TLS. |
|
235 | Defaults to 389 for PLAIN un-encrypted LDAP and START_TLS. | |
236 | Defaults to 636 for LDAPS. |
|
236 | Defaults to 636 for LDAPS. | |
237 |
|
237 | |||
238 | .. _ldap_account: |
|
238 | .. _ldap_account: | |
239 |
|
239 | |||
240 | Account : optional |
|
240 | Account : optional | |
241 | Only required if the LDAP server does not allow anonymous browsing of |
|
241 | Only required if the LDAP server does not allow anonymous browsing of | |
242 | records. This should be a special account for record browsing. This |
|
242 | records. This should be a special account for record browsing. This | |
243 | will require `LDAP Password`_ below. |
|
243 | will require `LDAP Password`_ below. | |
244 |
|
244 | |||
245 | .. _LDAP Password: |
|
245 | .. _LDAP Password: | |
246 |
|
246 | |||
247 | Password : optional |
|
247 | Password : optional | |
248 | Only required if the LDAP server does not allow anonymous browsing of |
|
248 | Only required if the LDAP server does not allow anonymous browsing of | |
249 | records. |
|
249 | records. | |
250 |
|
250 | |||
251 | .. _Enable LDAPS: |
|
251 | .. _Enable LDAPS: | |
252 |
|
252 | |||
253 | Connection Security : required |
|
253 | Connection Security : required | |
254 | Defines the connection to LDAP server |
|
254 | Defines the connection to LDAP server | |
255 |
|
255 | |||
256 | PLAIN |
|
256 | PLAIN | |
257 | Plain unencrypted LDAP connection. |
|
257 | Plain unencrypted LDAP connection. | |
258 | This will by default use `Port`_ 389. |
|
258 | This will by default use `Port`_ 389. | |
259 |
|
259 | |||
260 | LDAPS |
|
260 | LDAPS | |
261 | Use secure LDAPS connections according to `Certificate |
|
261 | Use secure LDAPS connections according to `Certificate | |
262 | Checks`_ configuration. |
|
262 | Checks`_ configuration. | |
263 | This will by default use `Port`_ 636. |
|
263 | This will by default use `Port`_ 636. | |
264 |
|
264 | |||
265 | START_TLS |
|
265 | START_TLS | |
266 | Use START TLS according to `Certificate Checks`_ configuration on an |
|
266 | Use START TLS according to `Certificate Checks`_ configuration on an | |
267 | apparently "plain" LDAP connection. |
|
267 | apparently "plain" LDAP connection. | |
268 | This will by default use `Port`_ 389. |
|
268 | This will by default use `Port`_ 389. | |
269 |
|
269 | |||
270 | .. _Certificate Checks: |
|
270 | .. _Certificate Checks: | |
271 |
|
271 | |||
272 | Certificate Checks : optional |
|
272 | Certificate Checks : optional | |
273 | How SSL certificates verification is handled -- this is only useful when |
|
273 | How SSL certificates verification is handled -- this is only useful when | |
274 | `Enable LDAPS`_ is enabled. Only DEMAND or HARD offer full SSL security |
|
274 | `Enable LDAPS`_ is enabled. Only DEMAND or HARD offer full SSL security | |
275 | with mandatory certificate validation, while the other options are |
|
275 | with mandatory certificate validation, while the other options are | |
276 | susceptible to man-in-the-middle attacks. |
|
276 | susceptible to man-in-the-middle attacks. | |
277 |
|
277 | |||
278 | NEVER |
|
278 | NEVER | |
279 | A serve certificate will never be requested or checked. |
|
279 | A serve certificate will never be requested or checked. | |
280 |
|
280 | |||
281 | ALLOW |
|
281 | ALLOW | |
282 | A server certificate is requested. Failure to provide a |
|
282 | A server certificate is requested. Failure to provide a | |
283 | certificate or providing a bad certificate will not terminate the |
|
283 | certificate or providing a bad certificate will not terminate the | |
284 | session. |
|
284 | session. | |
285 |
|
285 | |||
286 | TRY |
|
286 | TRY | |
287 | A server certificate is requested. Failure to provide a |
|
287 | A server certificate is requested. Failure to provide a | |
288 | certificate does not halt the session; providing a bad certificate |
|
288 | certificate does not halt the session; providing a bad certificate | |
289 | halts the session. |
|
289 | halts the session. | |
290 |
|
290 | |||
291 | DEMAND |
|
291 | DEMAND | |
292 | A server certificate is requested and must be provided and |
|
292 | A server certificate is requested and must be provided and | |
293 | authenticated for the session to proceed. |
|
293 | authenticated for the session to proceed. | |
294 |
|
294 | |||
295 | HARD |
|
295 | HARD | |
296 | The same as DEMAND. |
|
296 | The same as DEMAND. | |
297 |
|
297 | |||
298 | .. _Custom CA Certificates: |
|
298 | .. _Custom CA Certificates: | |
299 |
|
299 | |||
300 | Custom CA Certificates : optional |
|
300 | Custom CA Certificates : optional | |
301 | Directory used by OpenSSL to find CAs for validating the LDAP server certificate. |
|
301 | Directory used by OpenSSL to find CAs for validating the LDAP server certificate. | |
302 | Python 2.7.10 and later default to using the system certificate store, and |
|
302 | Python 2.7.10 and later default to using the system certificate store, and | |
303 | this should thus not be necessary when using certificates signed by a CA |
|
303 | this should thus not be necessary when using certificates signed by a CA | |
304 | trusted by the system. |
|
304 | trusted by the system. | |
305 | It can be set to something like `/etc/openldap/cacerts` on older systems or |
|
305 | It can be set to something like `/etc/openldap/cacerts` on older systems or | |
306 | if using self-signed certificates. |
|
306 | if using self-signed certificates. | |
307 |
|
307 | |||
308 | .. _Base DN: |
|
308 | .. _Base DN: | |
309 |
|
309 | |||
310 | Base DN : required |
|
310 | Base DN : required | |
311 | The Distinguished Name (DN) where searches for users will be performed. |
|
311 | The Distinguished Name (DN) where searches for users will be performed. | |
312 | Searches can be controlled by `LDAP Filter`_ and `LDAP Search Scope`_. |
|
312 | Searches can be controlled by `LDAP Filter`_ and `LDAP Search Scope`_. | |
313 |
|
313 | |||
314 | .. _LDAP Filter: |
|
314 | .. _LDAP Filter: | |
315 |
|
315 | |||
316 | LDAP Filter : optional |
|
316 | LDAP Filter : optional | |
317 | A LDAP filter defined by RFC 2254. This is more useful when `LDAP |
|
317 | A LDAP filter defined by RFC 2254. This is more useful when `LDAP | |
318 | Search Scope`_ is set to SUBTREE. The filter is useful for limiting |
|
318 | Search Scope`_ is set to SUBTREE. The filter is useful for limiting | |
319 | which LDAP objects are identified as representing Users for |
|
319 | which LDAP objects are identified as representing Users for | |
320 | authentication. The filter is augmented by `Login Attribute`_ below. |
|
320 | authentication. The filter is augmented by `Login Attribute`_ below. | |
321 | This can commonly be left blank. |
|
321 | This can commonly be left blank. | |
322 |
|
322 | |||
323 | .. _LDAP Search Scope: |
|
323 | .. _LDAP Search Scope: | |
324 |
|
324 | |||
325 | LDAP Search Scope : required |
|
325 | LDAP Search Scope : required | |
326 | This limits how far LDAP will search for a matching object. |
|
326 | This limits how far LDAP will search for a matching object. | |
327 |
|
327 | |||
328 | BASE |
|
328 | BASE | |
329 | Only allows searching of `Base DN`_ and is usually not what you |
|
329 | Only allows searching of `Base DN`_ and is usually not what you | |
330 | want. |
|
330 | want. | |
331 |
|
331 | |||
332 | ONELEVEL |
|
332 | ONELEVEL | |
333 | Searches all entries under `Base DN`_, but not Base DN itself. |
|
333 | Searches all entries under `Base DN`_, but not Base DN itself. | |
334 |
|
334 | |||
335 | SUBTREE |
|
335 | SUBTREE | |
336 | Searches all entries below `Base DN`_, but not Base DN itself. |
|
336 | Searches all entries below `Base DN`_, but not Base DN itself. | |
337 | When using SUBTREE `LDAP Filter`_ is useful to limit object |
|
337 | When using SUBTREE `LDAP Filter`_ is useful to limit object | |
338 | location. |
|
338 | location. | |
339 |
|
339 | |||
340 | .. _Login Attribute: |
|
340 | .. _Login Attribute: | |
341 |
|
341 | |||
342 | Login Attribute : required |
|
342 | Login Attribute : required | |
343 | The LDAP record attribute that will be matched as the USERNAME or |
|
343 | The LDAP record attribute that will be matched as the USERNAME or | |
344 | ACCOUNT used to connect to Kallithea. This will be added to `LDAP |
|
344 | ACCOUNT used to connect to Kallithea. This will be added to `LDAP | |
345 | Filter`_ for locating the User object. If `LDAP Filter`_ is specified as |
|
345 | Filter`_ for locating the User object. If `LDAP Filter`_ is specified as | |
346 | "LDAPFILTER", `Login Attribute`_ is specified as "uid" and the user has |
|
346 | "LDAPFILTER", `Login Attribute`_ is specified as "uid" and the user has | |
347 | connected as "jsmith" then the `LDAP Filter`_ will be augmented as below |
|
347 | connected as "jsmith" then the `LDAP Filter`_ will be augmented as below | |
348 | :: |
|
348 | :: | |
349 |
|
349 | |||
350 | (&(LDAPFILTER)(uid=jsmith)) |
|
350 | (&(LDAPFILTER)(uid=jsmith)) | |
351 |
|
351 | |||
352 | .. _ldap_attr_firstname: |
|
352 | .. _ldap_attr_firstname: | |
353 |
|
353 | |||
354 | First Name Attribute : required |
|
354 | First Name Attribute : required | |
355 | The LDAP record attribute which represents the user's first name. |
|
355 | The LDAP record attribute which represents the user's first name. | |
356 |
|
356 | |||
357 | .. _ldap_attr_lastname: |
|
357 | .. _ldap_attr_lastname: | |
358 |
|
358 | |||
359 | Last Name Attribute : required |
|
359 | Last Name Attribute : required | |
360 | The LDAP record attribute which represents the user's last name. |
|
360 | The LDAP record attribute which represents the user's last name. | |
361 |
|
361 | |||
362 | .. _ldap_attr_email: |
|
362 | .. _ldap_attr_email: | |
363 |
|
363 | |||
364 | Email Attribute : required |
|
364 | Email Attribute : required | |
365 | The LDAP record attribute which represents the user's email address. |
|
365 | The LDAP record attribute which represents the user's email address. | |
366 |
|
366 | |||
367 | If all data are entered correctly, and python-ldap_ is properly installed |
|
367 | If all data are entered correctly, and python-ldap_ is properly installed | |
368 | users should be granted access to Kallithea with LDAP accounts. At this |
|
368 | users should be granted access to Kallithea with LDAP accounts. At this | |
369 | time user information is copied from LDAP into the Kallithea user database. |
|
369 | time user information is copied from LDAP into the Kallithea user database. | |
370 | This means that updates of an LDAP user object may not be reflected as a |
|
370 | This means that updates of an LDAP user object may not be reflected as a | |
371 | user update in Kallithea. |
|
371 | user update in Kallithea. | |
372 |
|
372 | |||
373 | If You have problems with LDAP access and believe You entered correct |
|
373 | If You have problems with LDAP access and believe You entered correct | |
374 | information check out the Kallithea logs, any error messages sent from LDAP |
|
374 | information check out the Kallithea logs, any error messages sent from LDAP | |
375 | will be saved there. |
|
375 | will be saved there. | |
376 |
|
376 | |||
377 | Active Directory |
|
377 | Active Directory | |
378 | ^^^^^^^^^^^^^^^^ |
|
378 | ^^^^^^^^^^^^^^^^ | |
379 |
|
379 | |||
380 | Kallithea can use Microsoft Active Directory for user authentication. This |
|
380 | Kallithea can use Microsoft Active Directory for user authentication. This | |
381 | is done through an LDAP or LDAPS connection to Active Directory. The |
|
381 | is done through an LDAP or LDAPS connection to Active Directory. The | |
382 | following LDAP configuration settings are typical for using Active |
|
382 | following LDAP configuration settings are typical for using Active | |
383 | Directory :: |
|
383 | Directory :: | |
384 |
|
384 | |||
385 | Base DN = OU=SBSUsers,OU=Users,OU=MyBusiness,DC=v3sys,DC=local |
|
385 | Base DN = OU=SBSUsers,OU=Users,OU=MyBusiness,DC=v3sys,DC=local | |
386 | Login Attribute = sAMAccountName |
|
386 | Login Attribute = sAMAccountName | |
387 | First Name Attribute = givenName |
|
387 | First Name Attribute = givenName | |
388 | Last Name Attribute = sn |
|
388 | Last Name Attribute = sn | |
389 | Email Attribute = mail |
|
389 | Email Attribute = mail | |
390 |
|
390 | |||
391 | All other LDAP settings will likely be site-specific and should be |
|
391 | All other LDAP settings will likely be site-specific and should be | |
392 | appropriately configured. |
|
392 | appropriately configured. | |
393 |
|
393 | |||
394 |
|
394 | |||
395 | Authentication by container or reverse-proxy |
|
395 | Authentication by container or reverse-proxy | |
396 | -------------------------------------------- |
|
396 | -------------------------------------------- | |
397 |
|
397 | |||
398 | Kallithea supports delegating the authentication |
|
398 | Kallithea supports delegating the authentication | |
399 | of users to its WSGI container, or to a reverse-proxy server through which all |
|
399 | of users to its WSGI container, or to a reverse-proxy server through which all | |
400 | clients access the application. |
|
400 | clients access the application. | |
401 |
|
401 | |||
402 | When these authentication methods are enabled in Kallithea, it uses the |
|
402 | When these authentication methods are enabled in Kallithea, it uses the | |
403 | username that the container/proxy (Apache or Nginx, etc.) provides and doesn't |
|
403 | username that the container/proxy (Apache or Nginx, etc.) provides and doesn't | |
404 | perform the authentication itself. The authorization, however, is still done by |
|
404 | perform the authentication itself. The authorization, however, is still done by | |
405 | Kallithea according to its settings. |
|
405 | Kallithea according to its settings. | |
406 |
|
406 | |||
407 | When a user logs in for the first time using these authentication methods, |
|
407 | When a user logs in for the first time using these authentication methods, | |
408 | a matching user account is created in Kallithea with default permissions. An |
|
408 | a matching user account is created in Kallithea with default permissions. An | |
409 | administrator can then modify it using Kallithea's admin interface. |
|
409 | administrator can then modify it using Kallithea's admin interface. | |
410 |
|
410 | |||
411 | It's also possible for an administrator to create accounts and configure their |
|
411 | It's also possible for an administrator to create accounts and configure their | |
412 | permissions before the user logs in for the first time, using the :ref:`create-user` API. |
|
412 | permissions before the user logs in for the first time, using the :ref:`create-user` API. | |
413 |
|
413 | |||
414 | Container-based authentication |
|
414 | Container-based authentication | |
415 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
|
415 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
416 |
|
416 | |||
417 | In a container-based authentication setup, Kallithea reads the user name from |
|
417 | In a container-based authentication setup, Kallithea reads the user name from | |
418 | the ``REMOTE_USER`` server variable provided by the WSGI container. |
|
418 | the ``REMOTE_USER`` server variable provided by the WSGI container. | |
419 |
|
419 | |||
420 | After setting up your container (see `Apache with mod_wsgi`_), you'll need |
|
420 | After setting up your container (see `Apache with mod_wsgi`_), you'll need | |
421 | to configure it to require authentication on the location configured for |
|
421 | to configure it to require authentication on the location configured for | |
422 | Kallithea. |
|
422 | Kallithea. | |
423 |
|
423 | |||
424 | Proxy pass-through authentication |
|
424 | Proxy pass-through authentication | |
425 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
|
425 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
426 |
|
426 | |||
427 | In a proxy pass-through authentication setup, Kallithea reads the user name |
|
427 | In a proxy pass-through authentication setup, Kallithea reads the user name | |
428 | from the ``X-Forwarded-User`` request header, which should be configured to be |
|
428 | from the ``X-Forwarded-User`` request header, which should be configured to be | |
429 | sent by the reverse-proxy server. |
|
429 | sent by the reverse-proxy server. | |
430 |
|
430 | |||
431 | After setting up your proxy solution (see `Apache virtual host reverse proxy example`_, |
|
431 | After setting up your proxy solution (see `Apache virtual host reverse proxy example`_, | |
432 | `Apache as subdirectory`_ or `Nginx virtual host example`_), you'll need to |
|
432 | `Apache as subdirectory`_ or `Nginx virtual host example`_), you'll need to | |
433 | configure the authentication and add the username in a request header named |
|
433 | configure the authentication and add the username in a request header named | |
434 | ``X-Forwarded-User``. |
|
434 | ``X-Forwarded-User``. | |
435 |
|
435 | |||
436 | For example, the following config section for Apache sets a subdirectory in a |
|
436 | For example, the following config section for Apache sets a subdirectory in a | |
437 | reverse-proxy setup with basic auth: |
|
437 | reverse-proxy setup with basic auth: | |
438 |
|
438 | |||
439 | .. code-block:: apache |
|
439 | .. code-block:: apache | |
440 |
|
440 | |||
441 | <Location /someprefix> |
|
441 | <Location /someprefix> | |
442 | ProxyPass http://127.0.0.1:5000/someprefix |
|
442 | ProxyPass http://127.0.0.1:5000/someprefix | |
443 | ProxyPassReverse http://127.0.0.1:5000/someprefix |
|
443 | ProxyPassReverse http://127.0.0.1:5000/someprefix | |
444 | SetEnvIf X-Url-Scheme https HTTPS=1 |
|
444 | SetEnvIf X-Url-Scheme https HTTPS=1 | |
445 |
|
445 | |||
446 | AuthType Basic |
|
446 | AuthType Basic | |
447 | AuthName "Kallithea authentication" |
|
447 | AuthName "Kallithea authentication" | |
448 | AuthUserFile /srv/kallithea/.htpasswd |
|
448 | AuthUserFile /srv/kallithea/.htpasswd | |
449 | Require valid-user |
|
449 | Require valid-user | |
450 |
|
450 | |||
451 | RequestHeader unset X-Forwarded-User |
|
451 | RequestHeader unset X-Forwarded-User | |
452 |
|
452 | |||
453 | RewriteEngine On |
|
453 | RewriteEngine On | |
454 | RewriteCond %{LA-U:REMOTE_USER} (.+) |
|
454 | RewriteCond %{LA-U:REMOTE_USER} (.+) | |
455 | RewriteRule .* - [E=RU:%1] |
|
455 | RewriteRule .* - [E=RU:%1] | |
456 | RequestHeader set X-Forwarded-User %{RU}e |
|
456 | RequestHeader set X-Forwarded-User %{RU}e | |
457 | </Location> |
|
457 | </Location> | |
458 |
|
458 | |||
459 | Setting metadata in container/reverse-proxy |
|
459 | Setting metadata in container/reverse-proxy | |
460 | """"""""""""""""""""""""""""""""""""""""""" |
|
460 | """"""""""""""""""""""""""""""""""""""""""" | |
461 | When a new user account is created on the first login, Kallithea has no information about |
|
461 | When a new user account is created on the first login, Kallithea has no information about | |
462 | the user's email and full name. So you can set some additional request headers like in the |
|
462 | the user's email and full name. So you can set some additional request headers like in the | |
463 | example below. In this example the user is authenticated via Kerberos and an Apache |
|
463 | example below. In this example the user is authenticated via Kerberos and an Apache | |
464 | mod_python fixup handler is used to get the user information from a LDAP server. But you |
|
464 | mod_python fixup handler is used to get the user information from a LDAP server. But you | |
465 | could set the request headers however you want. |
|
465 | could set the request headers however you want. | |
466 |
|
466 | |||
467 | .. code-block:: apache |
|
467 | .. code-block:: apache | |
468 |
|
468 | |||
469 | <Location /someprefix> |
|
469 | <Location /someprefix> | |
470 | ProxyPass http://127.0.0.1:5000/someprefix |
|
470 | ProxyPass http://127.0.0.1:5000/someprefix | |
471 | ProxyPassReverse http://127.0.0.1:5000/someprefix |
|
471 | ProxyPassReverse http://127.0.0.1:5000/someprefix | |
472 | SetEnvIf X-Url-Scheme https HTTPS=1 |
|
472 | SetEnvIf X-Url-Scheme https HTTPS=1 | |
473 |
|
473 | |||
474 | AuthName "Kerberos Login" |
|
474 | AuthName "Kerberos Login" | |
475 | AuthType Kerberos |
|
475 | AuthType Kerberos | |
476 | Krb5Keytab /etc/apache2/http.keytab |
|
476 | Krb5Keytab /etc/apache2/http.keytab | |
477 | KrbMethodK5Passwd off |
|
477 | KrbMethodK5Passwd off | |
478 | KrbVerifyKDC on |
|
478 | KrbVerifyKDC on | |
479 | Require valid-user |
|
479 | Require valid-user | |
480 |
|
480 | |||
481 | PythonFixupHandler ldapmetadata |
|
481 | PythonFixupHandler ldapmetadata | |
482 |
|
482 | |||
483 | RequestHeader set X_REMOTE_USER %{X_REMOTE_USER}e |
|
483 | RequestHeader set X_REMOTE_USER %{X_REMOTE_USER}e | |
484 | RequestHeader set X_REMOTE_EMAIL %{X_REMOTE_EMAIL}e |
|
484 | RequestHeader set X_REMOTE_EMAIL %{X_REMOTE_EMAIL}e | |
485 | RequestHeader set X_REMOTE_FIRSTNAME %{X_REMOTE_FIRSTNAME}e |
|
485 | RequestHeader set X_REMOTE_FIRSTNAME %{X_REMOTE_FIRSTNAME}e | |
486 | RequestHeader set X_REMOTE_LASTNAME %{X_REMOTE_LASTNAME}e |
|
486 | RequestHeader set X_REMOTE_LASTNAME %{X_REMOTE_LASTNAME}e | |
487 | </Location> |
|
487 | </Location> | |
488 |
|
488 | |||
489 | .. code-block:: python |
|
489 | .. code-block:: python | |
490 |
|
490 | |||
491 | from mod_python import apache |
|
491 | from mod_python import apache | |
492 | import ldap |
|
492 | import ldap | |
493 |
|
493 | |||
494 | LDAP_SERVER = "ldaps://server.mydomain.com:636" |
|
494 | LDAP_SERVER = "ldaps://server.mydomain.com:636" | |
495 | LDAP_USER = "" |
|
495 | LDAP_USER = "" | |
496 | LDAP_PASS = "" |
|
496 | LDAP_PASS = "" | |
497 | LDAP_ROOT = "dc=mydomain,dc=com" |
|
497 | LDAP_ROOT = "dc=mydomain,dc=com" | |
498 | LDAP_FILTER = "sAMAccountName=%s" |
|
498 | LDAP_FILTER = "sAMAccountName=%s" | |
499 | LDAP_ATTR_LIST = ['sAMAccountName','givenname','sn','mail'] |
|
499 | LDAP_ATTR_LIST = ['sAMAccountName','givenname','sn','mail'] | |
500 |
|
500 | |||
501 | def fixuphandler(req): |
|
501 | def fixuphandler(req): | |
502 | if req.user is None: |
|
502 | if req.user is None: | |
503 | # no user to search for |
|
503 | # no user to search for | |
504 | return apache.OK |
|
504 | return apache.OK | |
505 | else: |
|
505 | else: | |
506 | try: |
|
506 | try: | |
507 | if('\\' in req.user): |
|
507 | if('\\' in req.user): | |
508 | username = req.user.split('\\')[1] |
|
508 | username = req.user.split('\\')[1] | |
509 | elif('@' in req.user): |
|
509 | elif('@' in req.user): | |
510 | username = req.user.split('@')[0] |
|
510 | username = req.user.split('@')[0] | |
511 | else: |
|
511 | else: | |
512 | username = req.user |
|
512 | username = req.user | |
513 | l = ldap.initialize(LDAP_SERVER) |
|
513 | l = ldap.initialize(LDAP_SERVER) | |
514 | l.simple_bind_s(LDAP_USER, LDAP_PASS) |
|
514 | l.simple_bind_s(LDAP_USER, LDAP_PASS) | |
515 | r = l.search_s(LDAP_ROOT, ldap.SCOPE_SUBTREE, LDAP_FILTER % username, attrlist=LDAP_ATTR_LIST) |
|
515 | r = l.search_s(LDAP_ROOT, ldap.SCOPE_SUBTREE, LDAP_FILTER % username, attrlist=LDAP_ATTR_LIST) | |
516 |
|
516 | |||
517 | req.subprocess_env['X_REMOTE_USER'] = username |
|
517 | req.subprocess_env['X_REMOTE_USER'] = username | |
518 | req.subprocess_env['X_REMOTE_EMAIL'] = r[0][1]['mail'][0].lower() |
|
518 | req.subprocess_env['X_REMOTE_EMAIL'] = r[0][1]['mail'][0].lower() | |
519 | req.subprocess_env['X_REMOTE_FIRSTNAME'] = "%s" % r[0][1]['givenname'][0] |
|
519 | req.subprocess_env['X_REMOTE_FIRSTNAME'] = "%s" % r[0][1]['givenname'][0] | |
520 | req.subprocess_env['X_REMOTE_LASTNAME'] = "%s" % r[0][1]['sn'][0] |
|
520 | req.subprocess_env['X_REMOTE_LASTNAME'] = "%s" % r[0][1]['sn'][0] | |
521 | except Exception, e: |
|
521 | except Exception, e: | |
522 | apache.log_error("error getting data from ldap %s" % str(e), apache.APLOG_ERR) |
|
522 | apache.log_error("error getting data from ldap %s" % str(e), apache.APLOG_ERR) | |
523 |
|
523 | |||
524 | return apache.OK |
|
524 | return apache.OK | |
525 |
|
525 | |||
526 | .. note:: |
|
526 | .. note:: | |
527 | If you enable proxy pass-through authentication, make sure your server is |
|
527 | If you enable proxy pass-through authentication, make sure your server is | |
528 | only accessible through the proxy. Otherwise, any client would be able to |
|
528 | only accessible through the proxy. Otherwise, any client would be able to | |
529 | forge the authentication header and could effectively become authenticated |
|
529 | forge the authentication header and could effectively become authenticated | |
530 | using any account of their liking. |
|
530 | using any account of their liking. | |
531 |
|
531 | |||
532 |
|
532 | |||
533 | Integration with issue trackers |
|
533 | Integration with issue trackers | |
534 | ------------------------------- |
|
534 | ------------------------------- | |
535 |
|
535 | |||
536 | Kallithea provides a simple integration with issue trackers. It's possible |
|
536 | Kallithea provides a simple integration with issue trackers. It's possible | |
537 | to define a regular expression that will match an issue ID in commit messages, |
|
537 | to define a regular expression that will match an issue ID in commit messages, | |
538 | and have that replaced with a URL to the issue. To enable this simply |
|
538 | and have that replaced with a URL to the issue. To enable this simply | |
539 | uncomment the following variables in the ini file:: |
|
539 | uncomment the following variables in the ini file:: | |
540 |
|
540 | |||
541 | issue_pat = (?:^#|\s#)(\w+) |
|
541 | issue_pat = (?:^#|\s#)(\w+) | |
542 | issue_server_link = https://issues.example.com/{repo}/issue/{id} |
|
542 | issue_server_link = https://issues.example.com/{repo}/issue/{id} | |
543 | issue_prefix = # |
|
543 | issue_prefix = # | |
544 |
|
544 | |||
545 | ``issue_pat`` is the regular expression describing which strings in |
|
545 | ``issue_pat`` is the regular expression describing which strings in | |
546 | commit messages will be treated as issue references. A match group in |
|
546 | commit messages will be treated as issue references. A match group in | |
547 | parentheses should be used to specify the actual issue id. |
|
547 | parentheses should be used to specify the actual issue id. | |
548 |
|
548 | |||
549 | The default expression matches issues in the format ``#<number>``, e.g., ``#300``. |
|
549 | The default expression matches issues in the format ``#<number>``, e.g., ``#300``. | |
550 |
|
550 | |||
551 | Matched issue references are replaced with the link specified in |
|
551 | Matched issue references are replaced with the link specified in | |
552 | ``issue_server_link``. ``{id}`` is replaced with the issue ID, and |
|
552 | ``issue_server_link``. ``{id}`` is replaced with the issue ID, and | |
553 | ``{repo}`` with the repository name. Since the # is stripped away, |
|
553 | ``{repo}`` with the repository name. Since the # is stripped away, | |
554 | ``issue_prefix`` is prepended to the link text. ``issue_prefix`` doesn't |
|
554 | ``issue_prefix`` is prepended to the link text. ``issue_prefix`` doesn't | |
555 | necessarily need to be ``#``: if you set issue prefix to ``ISSUE-`` this will |
|
555 | necessarily need to be ``#``: if you set issue prefix to ``ISSUE-`` this will | |
556 | generate a URL in the format: |
|
556 | generate a URL in the format: | |
557 |
|
557 | |||
558 | .. code-block:: html |
|
558 | .. code-block:: html | |
559 |
|
559 | |||
560 | <a href="https://issues.example.com/example_repo/issue/300">ISSUE-300</a> |
|
560 | <a href="https://issues.example.com/example_repo/issue/300">ISSUE-300</a> | |
561 |
|
561 | |||
562 | If needed, more than one pattern can be specified by appending a unique suffix to |
|
562 | If needed, more than one pattern can be specified by appending a unique suffix to | |
563 | the variables. For example:: |
|
563 | the variables. For example:: | |
564 |
|
564 | |||
565 | issue_pat_wiki = (?:wiki-)(.+) |
|
565 | issue_pat_wiki = (?:wiki-)(.+) | |
566 | issue_server_link_wiki = https://wiki.example.com/{id} |
|
566 | issue_server_link_wiki = https://wiki.example.com/{id} | |
567 | issue_prefix_wiki = WIKI- |
|
567 | issue_prefix_wiki = WIKI- | |
568 |
|
568 | |||
569 | With these settings, wiki pages can be referenced as wiki-some-id, and every |
|
569 | With these settings, wiki pages can be referenced as wiki-some-id, and every | |
570 | such reference will be transformed into: |
|
570 | such reference will be transformed into: | |
571 |
|
571 | |||
572 | .. code-block:: html |
|
572 | .. code-block:: html | |
573 |
|
573 | |||
574 | <a href="https://wiki.example.com/some-id">WIKI-some-id</a> |
|
574 | <a href="https://wiki.example.com/some-id">WIKI-some-id</a> | |
575 |
|
575 | |||
576 |
|
576 | |||
577 | Hook management |
|
577 | Hook management | |
578 | --------------- |
|
578 | --------------- | |
579 |
|
579 | |||
580 | Hooks can be managed in similar way to that used in ``.hgrc`` files. |
|
580 | Hooks can be managed in similar way to that used in ``.hgrc`` files. | |
581 | To manage hooks, choose *Admin > Settings > Hooks*. |
|
581 | To manage hooks, choose *Admin > Settings > Hooks*. | |
582 |
|
582 | |||
583 | The built-in hooks cannot be modified, though they can be enabled or disabled in the *VCS* section. |
|
583 | The built-in hooks cannot be modified, though they can be enabled or disabled in the *VCS* section. | |
584 |
|
584 | |||
585 | To add another custom hook simply fill in the first textbox with |
|
585 | To add another custom hook simply fill in the first textbox with | |
586 | ``<name>.<hook_type>`` and the second with the hook path. Example hooks |
|
586 | ``<name>.<hook_type>`` and the second with the hook path. Example hooks | |
587 | can be found in ``kallithea.lib.hooks``. |
|
587 | can be found in ``kallithea.lib.hooks``. | |
588 |
|
588 | |||
589 |
|
589 | |||
590 | Changing default encoding |
|
590 | Changing default encoding | |
591 | ------------------------- |
|
591 | ------------------------- | |
592 |
|
592 | |||
593 | By default, Kallithea uses UTF-8 encoding. |
|
593 | By default, Kallithea uses UTF-8 encoding. | |
594 | This is configurable as ``default_encoding`` in the .ini file. |
|
594 | This is configurable as ``default_encoding`` in the .ini file. | |
595 | This affects many parts in Kallithea including user names, filenames, and |
|
595 | This affects many parts in Kallithea including user names, filenames, and | |
596 | encoding of commit messages. In addition Kallithea can detect if the ``chardet`` |
|
596 | encoding of commit messages. In addition Kallithea can detect if the ``chardet`` | |
597 | library is installed. If ``chardet`` is detected Kallithea will fallback to it |
|
597 | library is installed. If ``chardet`` is detected Kallithea will fallback to it | |
598 | when there are encode/decode errors. |
|
598 | when there are encode/decode errors. | |
599 |
|
599 | |||
600 |
|
600 | |||
601 | Celery configuration |
|
601 | Celery configuration | |
602 | -------------------- |
|
602 | -------------------- | |
603 |
|
603 | |||
604 | Kallithea can use the distributed task queue system Celery_ to run tasks like |
|
604 | Kallithea can use the distributed task queue system Celery_ to run tasks like | |
605 | cloning repositories or sending emails. |
|
605 | cloning repositories or sending emails. | |
606 |
|
606 | |||
607 | Kallithea will in most setups work perfectly fine out of the box (without |
|
607 | Kallithea will in most setups work perfectly fine out of the box (without | |
608 | Celery), executing all tasks in the web server process. Some tasks can however |
|
608 | Celery), executing all tasks in the web server process. Some tasks can however | |
609 | take some time to run and it can be better to run such tasks asynchronously in |
|
609 | take some time to run and it can be better to run such tasks asynchronously in | |
610 | a separate process so the web server can focus on serving web requests. |
|
610 | a separate process so the web server can focus on serving web requests. | |
611 |
|
611 | |||
612 | For installation and configuration of Celery, see the `Celery documentation`_. |
|
612 | For installation and configuration of Celery, see the `Celery documentation`_. | |
613 | Note that Celery requires a message broker service like RabbitMQ_ (recommended) |
|
613 | Note that Celery requires a message broker service like RabbitMQ_ (recommended) | |
614 | or Redis_. |
|
614 | or Redis_. | |
615 |
|
615 | |||
616 | The use of Celery is configured in the Kallithea ini configuration file. |
|
616 | The use of Celery is configured in the Kallithea ini configuration file. | |
617 | To enable it, simply set:: |
|
617 | To enable it, simply set:: | |
618 |
|
618 | |||
619 | use_celery = true |
|
619 | use_celery = true | |
620 |
|
620 | |||
621 | and add or change the ``celery.*`` and ``broker.*`` configuration variables. |
|
621 | and add or change the ``celery.*`` and ``broker.*`` configuration variables. | |
622 |
|
622 | |||
623 | Remember that the ini files use the format with '.' and not with '_' like |
|
623 | Remember that the ini files use the format with '.' and not with '_' like | |
624 | Celery. So for example setting `BROKER_HOST` in Celery means setting |
|
624 | Celery. So for example setting `BROKER_HOST` in Celery means setting | |
625 | `broker.host` in the configuration file. |
|
625 | `broker.host` in the configuration file. | |
626 |
|
626 | |||
627 | To start the Celery process, run:: |
|
627 | To start the Celery process, run:: | |
628 |
|
628 | |||
629 | gearbox celeryd -c <configfile.ini> |
|
629 | gearbox celeryd -c <configfile.ini> | |
630 |
|
630 | |||
631 | Extra options to the Celery worker can be passed after ``--`` - see ``-- -h`` |
|
631 | Extra options to the Celery worker can be passed after ``--`` - see ``-- -h`` | |
632 | for more info. |
|
632 | for more info. | |
633 |
|
633 | |||
634 | .. note:: |
|
634 | .. note:: | |
635 | Make sure you run this command from the same virtualenv, and with the same |
|
635 | Make sure you run this command from the same virtualenv, and with the same | |
636 | user that Kallithea runs. |
|
636 | user that Kallithea runs. | |
637 |
|
637 | |||
638 |
|
638 | |||
639 | HTTPS support |
|
639 | HTTPS support | |
640 | ------------- |
|
640 | ------------- | |
641 |
|
641 | |||
642 | Kallithea will by default generate URLs based on the WSGI environment. |
|
642 | Kallithea will by default generate URLs based on the WSGI environment. | |
643 |
|
643 | |||
644 | Alternatively, you can use some special configuration settings to control |
|
644 | Alternatively, you can use some special configuration settings to control | |
645 | directly which scheme/protocol Kallithea will use when generating URLs: |
|
645 | directly which scheme/protocol Kallithea will use when generating URLs: | |
646 |
|
646 | |||
647 | - With ``https_fixup = true``, the scheme will be taken from the |
|
647 | - With ``https_fixup = true``, the scheme will be taken from the | |
648 | ``X-Url-Scheme``, ``X-Forwarded-Scheme`` or ``X-Forwarded-Proto`` HTTP header |
|
648 | ``X-Url-Scheme``, ``X-Forwarded-Scheme`` or ``X-Forwarded-Proto`` HTTP header | |
649 | (default ``http``). |
|
649 | (default ``http``). | |
650 | - With ``force_https = true`` the default will be ``https``. |
|
650 | - With ``force_https = true`` the default will be ``https``. | |
651 | - With ``use_htsts = true``, Kallithea will set ``Strict-Transport-Security`` when using https. |
|
651 | - With ``use_htsts = true``, Kallithea will set ``Strict-Transport-Security`` when using https. | |
652 |
|
652 | |||
653 |
|
653 | |||
654 | Nginx virtual host example |
|
654 | Nginx virtual host example | |
655 | -------------------------- |
|
655 | -------------------------- | |
656 |
|
656 | |||
657 | Sample config for Nginx using proxy: |
|
657 | Sample config for Nginx using proxy: | |
658 |
|
658 | |||
659 | .. code-block:: nginx |
|
659 | .. code-block:: nginx | |
660 |
|
660 | |||
661 | upstream kallithea { |
|
661 | upstream kallithea { | |
662 | server 127.0.0.1:5000; |
|
662 | server 127.0.0.1:5000; | |
663 | # add more instances for load balancing |
|
663 | # add more instances for load balancing | |
664 | #server 127.0.0.1:5001; |
|
664 | #server 127.0.0.1:5001; | |
665 | #server 127.0.0.1:5002; |
|
665 | #server 127.0.0.1:5002; | |
666 | } |
|
666 | } | |
667 |
|
667 | |||
668 | ## gist alias |
|
668 | ## gist alias | |
669 | server { |
|
669 | server { | |
670 | listen 443; |
|
670 | listen 443; | |
671 | server_name gist.example.com; |
|
671 | server_name gist.example.com; | |
672 | access_log /var/log/nginx/gist.access.log; |
|
672 | access_log /var/log/nginx/gist.access.log; | |
673 | error_log /var/log/nginx/gist.error.log; |
|
673 | error_log /var/log/nginx/gist.error.log; | |
674 |
|
674 | |||
675 | ssl on; |
|
675 | ssl on; | |
676 | ssl_certificate gist.your.kallithea.server.crt; |
|
676 | ssl_certificate gist.your.kallithea.server.crt; | |
677 | ssl_certificate_key gist.your.kallithea.server.key; |
|
677 | ssl_certificate_key gist.your.kallithea.server.key; | |
678 |
|
678 | |||
679 | ssl_session_timeout 5m; |
|
679 | ssl_session_timeout 5m; | |
680 |
|
680 | |||
681 | ssl_protocols SSLv3 TLSv1; |
|
681 | ssl_protocols SSLv3 TLSv1; | |
682 | ssl_ciphers DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:EDH-RSA-DES-CBC3-SHA:AES256-SHA:DES-CBC3-SHA:AES128-SHA:RC4-SHA:RC4-MD5; |
|
682 | ssl_ciphers DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:EDH-RSA-DES-CBC3-SHA:AES256-SHA:DES-CBC3-SHA:AES128-SHA:RC4-SHA:RC4-MD5; | |
683 | ssl_prefer_server_ciphers on; |
|
683 | ssl_prefer_server_ciphers on; | |
684 |
|
684 | |||
685 | rewrite ^/(.+)$ https://kallithea.example.com/_admin/gists/$1; |
|
685 | rewrite ^/(.+)$ https://kallithea.example.com/_admin/gists/$1; | |
686 | rewrite (.*) https://kallithea.example.com/_admin/gists; |
|
686 | rewrite (.*) https://kallithea.example.com/_admin/gists; | |
687 | } |
|
687 | } | |
688 |
|
688 | |||
689 | server { |
|
689 | server { | |
690 | listen 443; |
|
690 | listen 443; | |
691 | server_name kallithea.example.com |
|
691 | server_name kallithea.example.com | |
692 | access_log /var/log/nginx/kallithea.access.log; |
|
692 | access_log /var/log/nginx/kallithea.access.log; | |
693 | error_log /var/log/nginx/kallithea.error.log; |
|
693 | error_log /var/log/nginx/kallithea.error.log; | |
694 |
|
694 | |||
695 | ssl on; |
|
695 | ssl on; | |
696 | ssl_certificate your.kallithea.server.crt; |
|
696 | ssl_certificate your.kallithea.server.crt; | |
697 | ssl_certificate_key your.kallithea.server.key; |
|
697 | ssl_certificate_key your.kallithea.server.key; | |
698 |
|
698 | |||
699 | ssl_session_timeout 5m; |
|
699 | ssl_session_timeout 5m; | |
700 |
|
700 | |||
701 | ssl_protocols SSLv3 TLSv1; |
|
701 | ssl_protocols SSLv3 TLSv1; | |
702 | ssl_ciphers DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:EDH-RSA-DES-CBC3-SHA:AES256-SHA:DES-CBC3-SHA:AES128-SHA:RC4-SHA:RC4-MD5; |
|
702 | ssl_ciphers DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:EDH-RSA-DES-CBC3-SHA:AES256-SHA:DES-CBC3-SHA:AES128-SHA:RC4-SHA:RC4-MD5; | |
703 | ssl_prefer_server_ciphers on; |
|
703 | ssl_prefer_server_ciphers on; | |
704 |
|
704 | |||
705 | ## uncomment root directive if you want to serve static files by nginx |
|
705 | ## uncomment root directive if you want to serve static files by nginx | |
706 | ## requires static_files = false in .ini file |
|
706 | ## requires static_files = false in .ini file | |
707 | #root /srv/kallithea/kallithea/kallithea/public; |
|
707 | #root /srv/kallithea/kallithea/kallithea/public; | |
708 | include /etc/nginx/proxy.conf; |
|
708 | include /etc/nginx/proxy.conf; | |
709 | location / { |
|
709 | location / { | |
710 | try_files $uri @kallithea; |
|
710 | try_files $uri @kallithea; | |
711 | } |
|
711 | } | |
712 |
|
712 | |||
713 | location @kallithea { |
|
713 | location @kallithea { | |
714 | proxy_pass http://127.0.0.1:5000; |
|
714 | proxy_pass http://127.0.0.1:5000; | |
715 | } |
|
715 | } | |
716 |
|
716 | |||
717 | } |
|
717 | } | |
718 |
|
718 | |||
719 | Here's the proxy.conf. It's tuned so it will not timeout on long |
|
719 | Here's the proxy.conf. It's tuned so it will not timeout on long | |
720 | pushes or large pushes:: |
|
720 | pushes or large pushes:: | |
721 |
|
721 | |||
722 | proxy_redirect off; |
|
722 | proxy_redirect off; | |
723 | proxy_set_header Host $host; |
|
723 | proxy_set_header Host $host; | |
724 | ## needed for container auth |
|
724 | ## needed for container auth | |
725 | #proxy_set_header REMOTE_USER $remote_user; |
|
725 | #proxy_set_header REMOTE_USER $remote_user; | |
726 | #proxy_set_header X-Forwarded-User $remote_user; |
|
726 | #proxy_set_header X-Forwarded-User $remote_user; | |
727 | proxy_set_header X-Url-Scheme $scheme; |
|
727 | proxy_set_header X-Url-Scheme $scheme; | |
728 | proxy_set_header X-Host $http_host; |
|
728 | proxy_set_header X-Host $http_host; | |
729 | proxy_set_header X-Real-IP $remote_addr; |
|
729 | proxy_set_header X-Real-IP $remote_addr; | |
730 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
|
730 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
731 | proxy_set_header Proxy-host $proxy_host; |
|
731 | proxy_set_header Proxy-host $proxy_host; | |
732 | proxy_buffering off; |
|
732 | proxy_buffering off; | |
733 | proxy_connect_timeout 7200; |
|
733 | proxy_connect_timeout 7200; | |
734 | proxy_send_timeout 7200; |
|
734 | proxy_send_timeout 7200; | |
735 | proxy_read_timeout 7200; |
|
735 | proxy_read_timeout 7200; | |
736 | proxy_buffers 8 32k; |
|
736 | proxy_buffers 8 32k; | |
737 | client_max_body_size 1024m; |
|
737 | client_max_body_size 1024m; | |
738 | client_body_buffer_size 128k; |
|
738 | client_body_buffer_size 128k; | |
739 | large_client_header_buffers 8 64k; |
|
739 | large_client_header_buffers 8 64k; | |
740 |
|
740 | |||
741 |
|
741 | |||
742 | Apache virtual host reverse proxy example |
|
742 | Apache virtual host reverse proxy example | |
743 | ----------------------------------------- |
|
743 | ----------------------------------------- | |
744 |
|
744 | |||
745 | Here is a sample configuration file for Apache using proxy: |
|
745 | Here is a sample configuration file for Apache using proxy: | |
746 |
|
746 | |||
747 | .. code-block:: apache |
|
747 | .. code-block:: apache | |
748 |
|
748 | |||
749 | <VirtualHost *:80> |
|
749 | <VirtualHost *:80> | |
750 | ServerName kallithea.example.com |
|
750 | ServerName kallithea.example.com | |
751 |
|
751 | |||
752 | <Proxy *> |
|
752 | <Proxy *> | |
753 | # For Apache 2.4 and later: |
|
753 | # For Apache 2.4 and later: | |
754 | Require all granted |
|
754 | Require all granted | |
755 |
|
755 | |||
756 | # For Apache 2.2 and earlier, instead use: |
|
756 | # For Apache 2.2 and earlier, instead use: | |
757 | # Order allow,deny |
|
757 | # Order allow,deny | |
758 | # Allow from all |
|
758 | # Allow from all | |
759 | </Proxy> |
|
759 | </Proxy> | |
760 |
|
760 | |||
761 | #important ! |
|
761 | #important ! | |
762 | #Directive to properly generate url (clone url) for Kallithea |
|
762 | #Directive to properly generate url (clone url) for Kallithea | |
763 | ProxyPreserveHost On |
|
763 | ProxyPreserveHost On | |
764 |
|
764 | |||
765 | #kallithea instance |
|
765 | #kallithea instance | |
766 | ProxyPass / http://127.0.0.1:5000/ |
|
766 | ProxyPass / http://127.0.0.1:5000/ | |
767 | ProxyPassReverse / http://127.0.0.1:5000/ |
|
767 | ProxyPassReverse / http://127.0.0.1:5000/ | |
768 |
|
768 | |||
769 | #to enable https use line below |
|
769 | #to enable https use line below | |
770 | #SetEnvIf X-Url-Scheme https HTTPS=1 |
|
770 | #SetEnvIf X-Url-Scheme https HTTPS=1 | |
771 | </VirtualHost> |
|
771 | </VirtualHost> | |
772 |
|
772 | |||
773 | Additional tutorial |
|
773 | Additional tutorial | |
774 | http://pylonsbook.com/en/1.1/deployment.html#using-apache-to-proxy-requests-to-pylons |
|
774 | http://pylonsbook.com/en/1.1/deployment.html#using-apache-to-proxy-requests-to-pylons | |
775 |
|
775 | |||
776 |
|
776 | |||
777 | Apache as subdirectory |
|
777 | Apache as subdirectory | |
778 | ---------------------- |
|
778 | ---------------------- | |
779 |
|
779 | |||
780 | Apache subdirectory part: |
|
780 | Apache subdirectory part: | |
781 |
|
781 | |||
782 | .. code-block:: apache |
|
782 | .. code-block:: apache | |
783 |
|
783 | |||
784 | <Location /PREFIX > |
|
784 | <Location /PREFIX > | |
785 | ProxyPass http://127.0.0.1:5000/PREFIX |
|
785 | ProxyPass http://127.0.0.1:5000/PREFIX | |
786 | ProxyPassReverse http://127.0.0.1:5000/PREFIX |
|
786 | ProxyPassReverse http://127.0.0.1:5000/PREFIX | |
787 | SetEnvIf X-Url-Scheme https HTTPS=1 |
|
787 | SetEnvIf X-Url-Scheme https HTTPS=1 | |
788 | </Location> |
|
788 | </Location> | |
789 |
|
789 | |||
790 | Besides the regular apache setup you will need to add the following line |
|
790 | Besides the regular apache setup you will need to add the following line | |
791 | into ``[app:main]`` section of your .ini file:: |
|
791 | into ``[app:main]`` section of your .ini file:: | |
792 |
|
792 | |||
793 | filter-with = proxy-prefix |
|
793 | filter-with = proxy-prefix | |
794 |
|
794 | |||
795 | Add the following at the end of the .ini file:: |
|
795 | Add the following at the end of the .ini file:: | |
796 |
|
796 | |||
797 | [filter:proxy-prefix] |
|
797 | [filter:proxy-prefix] | |
798 | use = egg:PasteDeploy#prefix |
|
798 | use = egg:PasteDeploy#prefix | |
799 | prefix = /PREFIX |
|
799 | prefix = /PREFIX | |
800 |
|
800 | |||
801 | then change ``PREFIX`` into your chosen prefix |
|
801 | then change ``PREFIX`` into your chosen prefix | |
802 |
|
802 | |||
803 |
|
803 | |||
804 | Apache with mod_wsgi |
|
804 | Apache with mod_wsgi | |
805 | -------------------- |
|
805 | -------------------- | |
806 |
|
806 | |||
807 | Alternatively, Kallithea can be set up with Apache under mod_wsgi. For |
|
807 | Alternatively, Kallithea can be set up with Apache under mod_wsgi. For | |
808 | that, you'll need to: |
|
808 | that, you'll need to: | |
809 |
|
809 | |||
810 | - Install mod_wsgi. If using a Debian-based distro, you can install |
|
810 | - Install mod_wsgi. If using a Debian-based distro, you can install | |
811 | the package libapache2-mod-wsgi:: |
|
811 | the package libapache2-mod-wsgi:: | |
812 |
|
812 | |||
813 | aptitude install libapache2-mod-wsgi |
|
813 | aptitude install libapache2-mod-wsgi | |
814 |
|
814 | |||
815 | - Enable mod_wsgi:: |
|
815 | - Enable mod_wsgi:: | |
816 |
|
816 | |||
817 | a2enmod wsgi |
|
817 | a2enmod wsgi | |
818 |
|
818 | |||
819 | - Add global Apache configuration to tell mod_wsgi that Python only will be |
|
819 | - Add global Apache configuration to tell mod_wsgi that Python only will be | |
820 | used in the WSGI processes and shouldn't be initialized in the Apache |
|
820 | used in the WSGI processes and shouldn't be initialized in the Apache | |
821 | processes:: |
|
821 | processes:: | |
822 |
|
822 | |||
823 | WSGIRestrictEmbedded On |
|
823 | WSGIRestrictEmbedded On | |
824 |
|
824 | |||
825 | - Create a wsgi dispatch script, like the one below. Make sure you |
|
825 | - Create a wsgi dispatch script, like the one below. Make sure you | |
826 | check that the paths correctly point to where you installed Kallithea |
|
826 | check that the paths correctly point to where you installed Kallithea | |
827 | and its Python Virtual Environment. |
|
827 | and its Python Virtual Environment. | |
828 | - Enable the ``WSGIScriptAlias`` directive for the WSGI dispatch script, |
|
828 | - Enable the ``WSGIScriptAlias`` directive for the WSGI dispatch script, | |
829 | as in the following example. Once again, check the paths are |
|
829 | as in the following example. Once again, check the paths are | |
830 | correctly specified. |
|
830 | correctly specified. | |
831 |
|
831 | |||
832 | Here is a sample excerpt from an Apache Virtual Host configuration file: |
|
832 | Here is a sample excerpt from an Apache Virtual Host configuration file: | |
833 |
|
833 | |||
834 | .. code-block:: apache |
|
834 | .. code-block:: apache | |
835 |
|
835 | |||
836 | WSGIDaemonProcess kallithea processes=5 threads=1 maximum-requests=100 \ |
|
836 | WSGIDaemonProcess kallithea processes=5 threads=1 maximum-requests=100 \ | |
837 | python-home=/srv/kallithea/venv |
|
837 | python-home=/srv/kallithea/venv | |
838 | WSGIProcessGroup kallithea |
|
838 | WSGIProcessGroup kallithea | |
839 | WSGIScriptAlias / /srv/kallithea/dispatch.wsgi |
|
839 | WSGIScriptAlias / /srv/kallithea/dispatch.wsgi | |
840 | WSGIPassAuthorization On |
|
840 | WSGIPassAuthorization On | |
841 |
|
841 | |||
842 | Or if using a dispatcher WSGI script with proper virtualenv activation: |
|
842 | Or if using a dispatcher WSGI script with proper virtualenv activation: | |
843 |
|
843 | |||
844 | .. code-block:: apache |
|
844 | .. code-block:: apache | |
845 |
|
845 | |||
846 | WSGIDaemonProcess kallithea processes=5 threads=1 maximum-requests=100 |
|
846 | WSGIDaemonProcess kallithea processes=5 threads=1 maximum-requests=100 | |
847 | WSGIProcessGroup kallithea |
|
847 | WSGIProcessGroup kallithea | |
848 | WSGIScriptAlias / /srv/kallithea/dispatch.wsgi |
|
848 | WSGIScriptAlias / /srv/kallithea/dispatch.wsgi | |
849 | WSGIPassAuthorization On |
|
849 | WSGIPassAuthorization On | |
850 |
|
850 | |||
851 | Apache will by default run as a special Apache user, on Linux systems |
|
851 | Apache will by default run as a special Apache user, on Linux systems | |
852 | usually ``www-data`` or ``apache``. If you need to have the repositories |
|
852 | usually ``www-data`` or ``apache``. If you need to have the repositories | |
853 | directory owned by a different user, use the user and group options to |
|
853 | directory owned by a different user, use the user and group options to | |
854 | WSGIDaemonProcess to set the name of the user and group. |
|
854 | WSGIDaemonProcess to set the name of the user and group. | |
855 |
|
855 | |||
856 | Example WSGI dispatch script: |
|
856 | Example WSGI dispatch script: | |
857 |
|
857 | |||
858 | .. code-block:: python |
|
858 | .. code-block:: python | |
859 |
|
859 | |||
860 | import os |
|
860 | import os | |
861 | os.environ["HGENCODING"] = "UTF-8" |
|
861 | os.environ["HGENCODING"] = "UTF-8" | |
862 | os.environ['PYTHON_EGG_CACHE'] = '/srv/kallithea/.egg-cache' |
|
862 | os.environ['PYTHON_EGG_CACHE'] = '/srv/kallithea/.egg-cache' | |
863 |
|
863 | |||
864 | # sometimes it's needed to set the current dir |
|
864 | # sometimes it's needed to set the current dir | |
865 | os.chdir('/srv/kallithea/') |
|
865 | os.chdir('/srv/kallithea/') | |
866 |
|
866 | |||
867 | import site |
|
867 | import site | |
868 | site.addsitedir("/srv/kallithea/venv/lib/python2.7/site-packages") |
|
868 | site.addsitedir("/srv/kallithea/venv/lib/python2.7/site-packages") | |
869 |
|
869 | |||
870 | ini = '/srv/kallithea/my.ini' |
|
870 | ini = '/srv/kallithea/my.ini' | |
871 | from paste.script.util.logging_config import fileConfig |
|
871 | from paste.script.util.logging_config import fileConfig | |
872 | fileConfig(ini) |
|
872 | fileConfig(ini) | |
873 | from paste.deploy import loadapp |
|
873 | from paste.deploy import loadapp | |
874 | application = loadapp('config:' + ini) |
|
874 | application = loadapp('config:' + ini) | |
875 |
|
875 | |||
876 | Or using proper virtualenv activation: |
|
876 | Or using proper virtualenv activation: | |
877 |
|
877 | |||
878 | .. code-block:: python |
|
878 | .. code-block:: python | |
879 |
|
879 | |||
880 | activate_this = '/srv/kallithea/venv/bin/activate_this.py' |
|
880 | activate_this = '/srv/kallithea/venv/bin/activate_this.py' | |
881 | execfile(activate_this, dict(__file__=activate_this)) |
|
881 | execfile(activate_this, dict(__file__=activate_this)) | |
882 |
|
882 | |||
883 | import os |
|
883 | import os | |
884 | os.environ['HOME'] = '/srv/kallithea' |
|
884 | os.environ['HOME'] = '/srv/kallithea' | |
885 |
|
885 | |||
886 | ini = '/srv/kallithea/kallithea.ini' |
|
886 | ini = '/srv/kallithea/kallithea.ini' | |
887 | from paste.script.util.logging_config import fileConfig |
|
887 | from paste.script.util.logging_config import fileConfig | |
888 | fileConfig(ini) |
|
888 | fileConfig(ini) | |
889 | from paste.deploy import loadapp |
|
889 | from paste.deploy import loadapp | |
890 | application = loadapp('config:' + ini) |
|
890 | application = loadapp('config:' + ini) | |
891 |
|
891 | |||
892 |
|
892 | |||
893 | Other configuration files |
|
893 | Other configuration files | |
894 | ------------------------- |
|
894 | ------------------------- | |
895 |
|
895 | |||
896 | A number of `example init.d scripts`__ can be found in |
|
896 | A number of `example init.d scripts`__ can be found in | |
897 | the ``init.d`` directory of the Kallithea source. |
|
897 | the ``init.d`` directory of the Kallithea source. | |
898 |
|
898 | |||
899 | .. __: https://kallithea-scm.org/repos/kallithea/files/tip/init.d/ . |
|
899 | .. __: https://kallithea-scm.org/repos/kallithea/files/tip/init.d/ . | |
900 |
|
900 | |||
901 |
|
901 | |||
902 | .. _virtualenv: http://pypi.python.org/pypi/virtualenv |
|
902 | .. _virtualenv: http://pypi.python.org/pypi/virtualenv | |
903 | .. _python: http://www.python.org/ |
|
903 | .. _python: http://www.python.org/ | |
904 | .. _Mercurial: https://www.mercurial-scm.org/ |
|
904 | .. _Mercurial: https://www.mercurial-scm.org/ | |
905 | .. _Celery: http://celeryproject.org/ |
|
905 | .. _Celery: http://celeryproject.org/ | |
906 | .. _Celery documentation: http://docs.celeryproject.org/en/latest/getting-started/index.html |
|
906 | .. _Celery documentation: http://docs.celeryproject.org/en/latest/getting-started/index.html | |
907 | .. _RabbitMQ: http://www.rabbitmq.com/ |
|
907 | .. _RabbitMQ: http://www.rabbitmq.com/ | |
908 | .. _Redis: http://redis.io/ |
|
908 | .. _Redis: http://redis.io/ | |
909 | .. _python-ldap: http://www.python-ldap.org/ |
|
909 | .. _python-ldap: http://www.python-ldap.org/ | |
910 | .. _mercurial-server: http://www.lshift.net/mercurial-server.html |
|
910 | .. _mercurial-server: http://www.lshift.net/mercurial-server.html | |
911 | .. _PublishingRepositories: https://www.mercurial-scm.org/wiki/PublishingRepositories |
|
911 | .. _PublishingRepositories: https://www.mercurial-scm.org/wiki/PublishingRepositories |
@@ -1,197 +1,197 b'' | |||||
1 | .. _upgrade: |
|
1 | .. _upgrade: | |
2 |
|
2 | |||
3 | =================== |
|
3 | =================== | |
4 | Upgrading Kallithea |
|
4 | Upgrading Kallithea | |
5 | =================== |
|
5 | =================== | |
6 |
|
6 | |||
7 | This describes the process for upgrading Kallithea, independently of the |
|
7 | This describes the process for upgrading Kallithea, independently of the | |
8 | Kallithea installation method. |
|
8 | Kallithea installation method. | |
9 |
|
9 | |||
10 | .. note:: |
|
10 | .. note:: | |
11 | If you are upgrading from a RhodeCode installation, you must first |
|
11 | If you are upgrading from a RhodeCode installation, you must first | |
12 | install Kallithea 0.3.2 and follow the instructions in the 0.3.2 |
|
12 | install Kallithea 0.3.2 and follow the instructions in the 0.3.2 | |
13 | README to perform a one-time conversion of the database from |
|
13 | README to perform a one-time conversion of the database from | |
14 | RhodeCode to Kallithea, before upgrading to the latest version |
|
14 | RhodeCode to Kallithea, before upgrading to the latest version | |
15 | of Kallithea. |
|
15 | of Kallithea. | |
16 |
|
16 | |||
17 |
|
17 | |||
18 | 1. Stop the Kallithea web application |
|
18 | 1. Stop the Kallithea web application | |
19 | ------------------------------------- |
|
19 | ------------------------------------- | |
20 |
|
20 | |||
21 | This step depends entirely on the web server software used to serve |
|
21 | This step depends entirely on the web server software used to serve | |
22 | Kallithea, but in any case, Kallithea should not be running during |
|
22 | Kallithea, but in any case, Kallithea should not be running during | |
23 | the upgrade. |
|
23 | the upgrade. | |
24 |
|
24 | |||
25 | .. note:: |
|
25 | .. note:: | |
26 | If you're using Celery, make sure you stop all instances during the |
|
26 | If you're using Celery, make sure you stop all instances during the | |
27 | upgrade. |
|
27 | upgrade. | |
28 |
|
28 | |||
29 |
|
29 | |||
30 | 2. Create a backup of both database and configuration |
|
30 | 2. Create a backup of both database and configuration | |
31 | ----------------------------------------------------- |
|
31 | ----------------------------------------------------- | |
32 |
|
32 | |||
33 | You are of course strongly recommended to make backups regularly, but it |
|
33 | You are of course strongly recommended to make backups regularly, but it | |
34 | is *especially* important to make a full database and configuration |
|
34 | is *especially* important to make a full database and configuration | |
35 | backup before performing a Kallithea upgrade. |
|
35 | backup before performing a Kallithea upgrade. | |
36 |
|
36 | |||
37 | Back up your configuration |
|
37 | Back up your configuration | |
38 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ |
|
38 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
39 |
|
39 | |||
40 | Make a copy of your Kallithea configuration (``.ini``) file. |
|
40 | Make a copy of your Kallithea configuration (``.ini``) file. | |
41 |
|
41 | |||
42 | If you are using :ref:`rcextensions <customization>`, you should also |
|
42 | If you are using :ref:`rcextensions <customization>`, you should also | |
43 | make a copy of the entire ``rcextensions`` directory. |
|
43 | make a copy of the entire ``rcextensions`` directory. | |
44 |
|
44 | |||
45 | Back up your database |
|
45 | Back up your database | |
46 | ^^^^^^^^^^^^^^^^^^^^^ |
|
46 | ^^^^^^^^^^^^^^^^^^^^^ | |
47 |
|
47 | |||
48 | If using SQLite, simply make a copy of the Kallithea database (``.db``) |
|
48 | If using SQLite, simply make a copy of the Kallithea database (``.db``) | |
49 | file. |
|
49 | file. | |
50 |
|
50 | |||
51 | If using PostgreSQL, please consult the documentation for the ``pg_dump`` |
|
51 | If using PostgreSQL, please consult the documentation for the ``pg_dump`` | |
52 | utility. |
|
52 | utility. | |
53 |
|
53 | |||
54 | If using MySQL, please consult the documentation for the ``mysqldump`` |
|
54 | If using MySQL, please consult the documentation for the ``mysqldump`` | |
55 | utility. |
|
55 | utility. | |
56 |
|
56 | |||
57 | Look for ``sqlalchemy.url`` in your configuration file to determine |
|
57 | Look for ``sqlalchemy.url`` in your configuration file to determine | |
58 | database type, settings, location, etc. |
|
58 | database type, settings, location, etc. | |
59 |
|
59 | |||
60 |
|
60 | |||
61 | 3. Activate the Kallithea virtual environment (if any) |
|
61 | 3. Activate the Kallithea virtual environment (if any) | |
62 | ------------------------------------------------------ |
|
62 | ------------------------------------------------------ | |
63 |
|
63 | |||
64 | Verify that you are using the Python environment that you originally |
|
64 | Verify that you are using the Python environment that you originally | |
65 | installed Kallithea in by running:: |
|
65 | installed Kallithea in by running:: | |
66 |
|
66 | |||
67 | pip freeze |
|
67 | pip freeze | |
68 |
|
68 | |||
69 | This will list all packages installed in the current environment. If |
|
69 | This will list all packages installed in the current environment. If | |
70 | Kallithea isn't listed, activate the correct virtual environment. |
|
70 | Kallithea isn't listed, activate the correct virtual environment. | |
71 | See the appropriate installation page for details. |
|
71 | See the appropriate installation page for details. | |
72 |
|
72 | |||
73 |
|
73 | |||
74 | 4. Install new version of Kallithea |
|
74 | 4. Install new version of Kallithea | |
75 | ----------------------------------- |
|
75 | ----------------------------------- | |
76 |
|
76 | |||
77 | Please refer to the instructions for the installation method you |
|
77 | Please refer to the instructions for the installation method you | |
78 | originally used to install Kallithea. |
|
78 | originally used to install Kallithea. | |
79 |
|
79 | |||
80 | If you originally installed using pip, it is as simple as:: |
|
80 | If you originally installed using pip, it is as simple as:: | |
81 |
|
81 | |||
82 | pip install --upgrade kallithea |
|
82 | pip install --upgrade kallithea | |
83 |
|
83 | |||
84 | If you originally installed from version control, it is as simple as:: |
|
84 | If you originally installed from version control, it is as simple as:: | |
85 |
|
85 | |||
86 | cd my-kallithea-clone |
|
86 | cd my-kallithea-clone | |
87 | hg pull -u |
|
87 | hg pull -u | |
88 | pip install --upgrade -e . |
|
88 | pip install --upgrade -e . | |
89 |
|
89 | |||
90 | Temporarily, in the current version, an extra step is required to build |
|
90 | Temporarily, in the current version, an extra step is required to build | |
91 | front-end files: |
|
91 | front-end files: | |
92 |
|
92 | |||
93 | Find the right ``kallithea/public/less`` path with:: |
|
93 | Find the right ``kallithea/public/less`` path with:: | |
94 |
|
94 | |||
95 | python -c "import os, kallithea; print os.path.join(os.path.dirname(os.path.abspath(kallithea.__file__)), 'public', 'less')" |
|
95 | python -c "import os, kallithea; print os.path.join(os.path.dirname(os.path.abspath(kallithea.__file__)), 'public', 'less')" | |
96 |
|
96 | |||
97 | Then run:: |
|
97 | Then run:: | |
98 |
|
98 | |||
99 | npm --prefix kallithea/public/less install |
|
99 | npm install | |
100 | npm --prefix kallithea/public/less run less |
|
100 | npm run less | |
101 |
|
101 | |||
102 |
|
102 | |||
103 | 5. Upgrade your configuration |
|
103 | 5. Upgrade your configuration | |
104 | ----------------------------- |
|
104 | ----------------------------- | |
105 |
|
105 | |||
106 | Run the following command to create a new configuration (``.ini``) file:: |
|
106 | Run the following command to create a new configuration (``.ini``) file:: | |
107 |
|
107 | |||
108 | gearbox make-config new.ini |
|
108 | gearbox make-config new.ini | |
109 |
|
109 | |||
110 | Then compare it with your old config file and see what changed. |
|
110 | Then compare it with your old config file and see what changed. | |
111 |
|
111 | |||
112 | .. note:: |
|
112 | .. note:: | |
113 | Please always make sure your ``.ini`` files are up to date. Errors |
|
113 | Please always make sure your ``.ini`` files are up to date. Errors | |
114 | can often be caused by missing parameters added in new versions. |
|
114 | can often be caused by missing parameters added in new versions. | |
115 |
|
115 | |||
116 | .. _upgrade_db: |
|
116 | .. _upgrade_db: | |
117 |
|
117 | |||
118 |
|
118 | |||
119 | 6. Upgrade your database |
|
119 | 6. Upgrade your database | |
120 | ------------------------ |
|
120 | ------------------------ | |
121 |
|
121 | |||
122 | .. note:: |
|
122 | .. note:: | |
123 | If you are *downgrading* Kallithea, you should perform the database |
|
123 | If you are *downgrading* Kallithea, you should perform the database | |
124 | migration step *before* installing the older version. (That is, |
|
124 | migration step *before* installing the older version. (That is, | |
125 | always perform migrations using the most recent of the two versions |
|
125 | always perform migrations using the most recent of the two versions | |
126 | you're migrating between.) |
|
126 | you're migrating between.) | |
127 |
|
127 | |||
128 | First, run the following command to see your current database version:: |
|
128 | First, run the following command to see your current database version:: | |
129 |
|
129 | |||
130 | alembic -c my.ini current |
|
130 | alembic -c my.ini current | |
131 |
|
131 | |||
132 | Typical output will be something like "9358dc3d6828 (head)", which is |
|
132 | Typical output will be something like "9358dc3d6828 (head)", which is | |
133 | the current Alembic database "revision ID". Write down the entire output |
|
133 | the current Alembic database "revision ID". Write down the entire output | |
134 | for troubleshooting purposes. |
|
134 | for troubleshooting purposes. | |
135 |
|
135 | |||
136 | The output will be empty if you're upgrading from Kallithea 0.3.x or |
|
136 | The output will be empty if you're upgrading from Kallithea 0.3.x or | |
137 | older. That's expected. If you get an error that the config file was not |
|
137 | older. That's expected. If you get an error that the config file was not | |
138 | found or has no ``[alembic]`` section, see the next section. |
|
138 | found or has no ``[alembic]`` section, see the next section. | |
139 |
|
139 | |||
140 | Next, if you are performing an *upgrade*: Run the following command to |
|
140 | Next, if you are performing an *upgrade*: Run the following command to | |
141 | upgrade your database to the current Kallithea version:: |
|
141 | upgrade your database to the current Kallithea version:: | |
142 |
|
142 | |||
143 | alembic -c my.ini upgrade head |
|
143 | alembic -c my.ini upgrade head | |
144 |
|
144 | |||
145 | If you are performing a *downgrade*: Run the following command to |
|
145 | If you are performing a *downgrade*: Run the following command to | |
146 | downgrade your database to the given version:: |
|
146 | downgrade your database to the given version:: | |
147 |
|
147 | |||
148 | alembic -c my.ini downgrade 0.4 |
|
148 | alembic -c my.ini downgrade 0.4 | |
149 |
|
149 | |||
150 | Alembic will show the necessary migrations (if any) as it executes them. |
|
150 | Alembic will show the necessary migrations (if any) as it executes them. | |
151 | If no "ERROR" is displayed, the command was successful. |
|
151 | If no "ERROR" is displayed, the command was successful. | |
152 |
|
152 | |||
153 | Should an error occur, the database may be "stranded" half-way |
|
153 | Should an error occur, the database may be "stranded" half-way | |
154 | through the migration, and you should restore it from backup. |
|
154 | through the migration, and you should restore it from backup. | |
155 |
|
155 | |||
156 | Enabling old Kallithea config files for Alembic use |
|
156 | Enabling old Kallithea config files for Alembic use | |
157 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
|
157 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
158 |
|
158 | |||
159 | Kallithea configuration files created before the introduction of Alembic |
|
159 | Kallithea configuration files created before the introduction of Alembic | |
160 | (i.e. predating Kallithea 0.4) need to be updated for use with Alembic. |
|
160 | (i.e. predating Kallithea 0.4) need to be updated for use with Alembic. | |
161 | Without this, Alembic will fail with an error like this:: |
|
161 | Without this, Alembic will fail with an error like this:: | |
162 |
|
162 | |||
163 | FAILED: No config file 'my.ini' found, or file has no '[alembic]' section |
|
163 | FAILED: No config file 'my.ini' found, or file has no '[alembic]' section | |
164 |
|
164 | |||
165 | If Alembic complains specifically about a missing ``alembic.ini``, it is |
|
165 | If Alembic complains specifically about a missing ``alembic.ini``, it is | |
166 | likely because you did not specify a config file using the ``-c`` option. |
|
166 | likely because you did not specify a config file using the ``-c`` option. | |
167 | On the other hand, if the mentioned config file actually exists, you |
|
167 | On the other hand, if the mentioned config file actually exists, you | |
168 | need to append the following lines to it:: |
|
168 | need to append the following lines to it:: | |
169 |
|
169 | |||
170 | [alembic] |
|
170 | [alembic] | |
171 | script_location = kallithea:alembic |
|
171 | script_location = kallithea:alembic | |
172 |
|
172 | |||
173 | Your config file should now work with Alembic. |
|
173 | Your config file should now work with Alembic. | |
174 |
|
174 | |||
175 |
|
175 | |||
176 | 7. Rebuild the Whoosh full-text index |
|
176 | 7. Rebuild the Whoosh full-text index | |
177 | ------------------------------------- |
|
177 | ------------------------------------- | |
178 |
|
178 | |||
179 | It is recommended that you rebuild the Whoosh index after upgrading since |
|
179 | It is recommended that you rebuild the Whoosh index after upgrading since | |
180 | new Whoosh versions can introduce incompatible index changes. |
|
180 | new Whoosh versions can introduce incompatible index changes. | |
181 |
|
181 | |||
182 |
|
182 | |||
183 | 8. Start the Kallithea web application |
|
183 | 8. Start the Kallithea web application | |
184 | -------------------------------------- |
|
184 | -------------------------------------- | |
185 |
|
185 | |||
186 | This step once again depends entirely on the web server software used to |
|
186 | This step once again depends entirely on the web server software used to | |
187 | serve Kallithea. |
|
187 | serve Kallithea. | |
188 |
|
188 | |||
189 | Before starting the new version of Kallithea, you may find it helpful to |
|
189 | Before starting the new version of Kallithea, you may find it helpful to | |
190 | clear out your log file so that new errors are readily apparent. |
|
190 | clear out your log file so that new errors are readily apparent. | |
191 |
|
191 | |||
192 | .. note:: |
|
192 | .. note:: | |
193 | If you're using Celery, make sure you restart all instances of it after |
|
193 | If you're using Celery, make sure you restart all instances of it after | |
194 | upgrade. |
|
194 | upgrade. | |
195 |
|
195 | |||
196 |
|
196 | |||
197 | .. _virtualenv: http://pypi.python.org/pypi/virtualenv |
|
197 | .. _virtualenv: http://pypi.python.org/pypi/virtualenv |
@@ -1,23 +1,23 b'' | |||||
1 | /*! |
|
1 | /*! | |
2 | * Don't edit the css file directly. |
|
2 | * Don't edit the css file directly. | |
3 | * |
|
3 | * | |
4 | * Instead, edit the less file(s) and regenerate the css: |
|
4 | * Instead, edit the less file(s) and regenerate the css: | |
5 | * |
|
5 | * | |
6 | * npm --prefix kallithea/public/less install |
|
6 | * npm install | |
7 | * npm --prefix kallithea/public/less run less |
|
7 | * npm run less | |
8 | * |
|
8 | * | |
9 | */ |
|
9 | */ | |
10 |
|
10 | |||
11 | /* 3rd party styles */ |
|
11 | /* 3rd party styles */ | |
12 | @import "node_modules/bootstrap/less/bootstrap.less"; |
|
12 | @import "node_modules/bootstrap/less/bootstrap.less"; | |
13 | @import (inline) "../css/jquery.dataTables.css"; |
|
13 | @import (inline) "../css/jquery.dataTables.css"; | |
14 | @import (less) "../js/select2/select2.css"; |
|
14 | @import (less) "../js/select2/select2.css"; | |
15 | @import (less) "../js/select2/select2-bootstrap.css"; |
|
15 | @import (less) "../js/select2/select2-bootstrap.css"; | |
16 |
|
16 | |||
17 | /* kallithea styles */ |
|
17 | /* kallithea styles */ | |
18 | @import "kallithea-variables.less"; |
|
18 | @import "kallithea-variables.less"; | |
19 | @import "kallithea-tags.less"; |
|
19 | @import "kallithea-tags.less"; | |
20 | @import "yui-ac.less"; |
|
20 | @import "yui-ac.less"; | |
21 | @import "kallithea-select2.less"; |
|
21 | @import "kallithea-select2.less"; | |
22 | @import "kallithea-diff.less"; |
|
22 | @import "kallithea-diff.less"; | |
23 | @import "style.less"; |
|
23 | @import "style.less"; |
@@ -1,14 +1,14 b'' | |||||
1 | { |
|
1 | { | |
2 | "name": "kallithea", |
|
2 | "name": "kallithea", | |
3 | "private": true, |
|
3 | "private": true, | |
4 | "dependencies": { |
|
4 | "dependencies": { | |
5 | "bootstrap": "3.3.7" |
|
5 | "bootstrap": "3.3.7" | |
6 | }, |
|
6 | }, | |
7 | "devDependencies": { |
|
7 | "devDependencies": { | |
8 | "less": "~2.7", |
|
8 | "less": "~2.7", | |
9 | "less-plugin-clean-css": "~1.5" |
|
9 | "less-plugin-clean-css": "~1.5" | |
10 | }, |
|
10 | }, | |
11 | "scripts": { |
|
11 | "scripts": { | |
12 |
"less": "lessc --relative-urls main.less |
|
12 | "less": "lessc --relative-urls kallithea/public/less/main.less kallithea/public/css/style.css" | |
13 | } |
|
13 | } | |
14 | } |
|
14 | } |
General Comments 0
You need to be logged in to leave comments.
Login now