Files @ f629e9a0c376
Branch filter:

Location: kallithea/docs/usage/general.rst - annotation

f629e9a0c376 6.6 KiB text/prs.fallenstein.rst Show Source Show as Raw Download as Raw
Andrew Shadura
auth: secure password reset implementation

This is a better implementation of password reset function, which
doesn't involve sending a new password to the user's email address
in clear text, and at the same time is stateless.

The old implementation generated a new password and sent it
in clear text to whatever email assigned to the user currently,
so that any user, possibly unauthenticated, could request a reset
for any username or email. Apart from potential insecurity, this
made it possible for anyone to disrupt users' workflow by repeatedly
resetting their passwords.

The idea behind this implementation is to generate
an authentication token which is dependent on the user state
at the time before the password change takes place, so the token
is one-time and can't be reused, and also to bind the token to
the browser session.

The token is calculated as SHA1 hash of the following:

* user's identifier (number, not a name)
* timestamp
* hashed user's password
* session identifier
* per-application secret

We use numeric user's identifier, as it's fixed and doesn't change,
so renaming users doesn't affect the mechanism. Timestamp is added
to make it possible to limit the token's validness (currently hard
coded to 24h), and we don't want users to be able to fake that field
easily. Hashed user's password is needed to prevent using the token
again once the password has been changed. Session identifier is
an additional security measure to ensure someone else stealing the
token can't use it. Finally, per-application secret is just another
way to make it harder for an attacker to guess all values in an
attempt to generate a valid token.

When the token is generated, an anonymous user is directed to a
confirmation page where the timestamp and the usernames are already
preloaded, so the user needs to specify the token. User can either
click the link in the email if it's really them reading it, or to type
the token manually.

Using the right token in the same session as it was requested directs
the user to a password change form, where the user is supposed to
specify a new password (twice, of course). Upon completing the form
(which is POSTed) the password change happens and a notification
mail is sent.

The test is updated to test the basic functionality with a bad and
a good token, but it doesn't (yet) cover all code paths.

The original work from Andrew has been thorougly reviewed and heavily
modified by Søren Løvborg.
bbd499c7b55e
bbd499c7b55e
17c9393e9645
e73a69cb98dc
bbd499c7b55e
bbd499c7b55e
bbd499c7b55e
5ae8e644aa88
9472a0150bf0
bbd499c7b55e
4e6dfdb3fa01
4e6dfdb3fa01
4e6dfdb3fa01
35d560f0f842
35d560f0f842
5ae8e644aa88
2d4e1f5e854e
03bbd33bc084
2d4e1f5e854e
35d560f0f842
35d560f0f842
35d560f0f842
35d560f0f842
4e6dfdb3fa01
bbd499c7b55e
35d560f0f842
35d560f0f842
35d560f0f842
35d560f0f842
fbbe80e3322b
a144d15488db
a144d15488db
bbd499c7b55e
a144d15488db
a144d15488db
a144d15488db
a144d15488db
a144d15488db
a144d15488db
a144d15488db
bbd499c7b55e
bbd499c7b55e
543bf62d06c7
543bf62d06c7
543bf62d06c7
543bf62d06c7
543bf62d06c7
543bf62d06c7
543bf62d06c7
543bf62d06c7
543bf62d06c7
543bf62d06c7
bbd499c7b55e
543bf62d06c7
543bf62d06c7
543bf62d06c7
543bf62d06c7
bbd499c7b55e
543bf62d06c7
543bf62d06c7
543bf62d06c7
543bf62d06c7
543bf62d06c7
543bf62d06c7
bbd499c7b55e
543bf62d06c7
543bf62d06c7
543bf62d06c7
543bf62d06c7
543bf62d06c7
543bf62d06c7
543bf62d06c7
bbd499c7b55e
5ae8e644aa88
4185f87f0ee0
4185f87f0ee0
a8c66e870bd0
4e6dfdb3fa01
4185f87f0ee0
8b8edfc25856
5ae8e644aa88
4185f87f0ee0
4185f87f0ee0
4185f87f0ee0
5ae8e644aa88
8b8edfc25856
4185f87f0ee0
4185f87f0ee0
4185f87f0ee0
4185f87f0ee0
4185f87f0ee0
4185f87f0ee0
4185f87f0ee0
4185f87f0ee0
4185f87f0ee0
a8c66e870bd0
5ae8e644aa88
8b8edfc25856
4185f87f0ee0
4185f87f0ee0
a8c66e870bd0
5ae8e644aa88
2079e864ce51
2079e864ce51
bbd499c7b55e
5ae8e644aa88
2079e864ce51
4e6dfdb3fa01
bbd499c7b55e
2079e864ce51
667b5cea6d4f
667b5cea6d4f
667b5cea6d4f
926f55b038bc
926f55b038bc
bbd499c7b55e
9472a0150bf0
bbd499c7b55e
584693b3deb0
584693b3deb0
584693b3deb0
584693b3deb0
22f79562836c
22f79562836c
22f79562836c
22f79562836c
22f79562836c
e5ab200892e3
4e6dfdb3fa01
22f79562836c
22f79562836c
22f79562836c
22f79562836c
22f79562836c
e5ab200892e3
e5ab200892e3
22f79562836c
e5ab200892e3
e5ab200892e3
e5ab200892e3
e5ab200892e3
e5ab200892e3
e5ab200892e3
9f5a4e785823
9f5a4e785823
daa83b2dd1f4
daa83b2dd1f4
9f5a4e785823
daa83b2dd1f4
daa83b2dd1f4
daa83b2dd1f4
9f5a4e785823
daa83b2dd1f4
daa83b2dd1f4
0b6982223baa
5ae8e644aa88
5ae8e644aa88
5ae8e644aa88
5ae8e644aa88
5ae8e644aa88
584ec42af63d
daa83b2dd1f4
daa83b2dd1f4
daa83b2dd1f4
daa83b2dd1f4
9f5a4e785823
22a3fa3c4254
9f5a4e785823
9f5a4e785823
5ae8e644aa88
5ae8e644aa88
5ae8e644aa88
9f5a4e785823
9f5a4e785823
9f5a4e785823
9f5a4e785823
9f5a4e785823
9f5a4e785823
9f5a4e785823
9f5a4e785823
9f5a4e785823
.. _general:

=======================
General Kallithea usage
=======================


Repository deletion
-------------------

Currently when an admin or owner deletes a repository, Kallithea does
not physically delete said repository from the filesystem, but instead
renames it in a special way so that it is not possible to push, clone
or access the repository.

There is a special command for cleaning up such archived repositories::

    paster cleanup-repos --older-than=30d my.ini

This command scans for archived repositories that are older than
30 days, displays them, and asks if you want to delete them (unless given
the ``--dont-ask`` flag). If you host a large amount of repositories with
forks that are constantly being deleted, it is recommended that you run this
command via crontab.

It is worth noting that even if someone is given administrative access to
Kallithea and deletes a repository, you can easily restore such an action by
renaming the repository directory, removing the ``rm__<date>`` prefix.


File view: follow current branch
--------------------------------

In the file view, left and right arrows allow to jump to the previous and next
revision. Depending on the way revisions were created in the repository, this
could jump to a different branch.  When the checkbox ``Follow current branch``
is checked, these arrows will only jump to revisions on the same branch as the
currently visible revision.  So for example, if someone is viewing files in the
``beta`` branch and marks the `Follow current branch` checkbox, the < and >
arrows will only show revisions on the ``beta`` branch.


Changelog features
------------------

The core feature of a repository's ``changelog`` page is to show the revisions
in a repository. However, there are several other features available from the
changelog.

Branch filter
  By default, the changelog shows revisions from all branches in the
  repository. Use the branch filter to restrict to a given branch.

Viewing a changeset
  A particular changeset can be opened by clicking on either the changeset
  hash or the commit message, or by ticking the checkbox and clicking the
  ``Show selected changeset`` button at the top.

Viewing all changes between two changesets
  To get a list of all changesets between two selected changesets, along with
  the changes in each one of them, tick the checkboxes of the first and
  last changeset in the desired range and click the ``Show selected changesets``
  button at the top. You can only show the range between the first and last
  checkbox (no cherry-picking).

  From that page, you can proceed to viewing the overall delta between the
  selected changesets, by clicking the ``Compare revisions`` button.

Creating a pull request
  You can create a new pull request for the changes of a particular changeset
  (and its ancestors) by selecting it and clicking the ``Open new pull request
  for selected changesets`` button.


Permanent repository URLs
-------------------------

Due to the complicated nature of repository grouping, URLs of repositories
can often change. For example, a repository originally accessible from::

  http://example.com/repo_name

would get a new URL after moving it to test_group::

  http://example.com/test_group/repo_name

Such moving of a repository to a group can be an issue for build systems and
other scripts where the repository paths are hardcoded. To mitigate this,
Kallithea provides permanent URLs using the repository ID prefixed with an
underscore. In all Kallithea URLs, for example those for the changelog and the
file view, a repository name can be replaced by this ``_ID`` string. Since IDs
are always the same, moving the repository to a different group will not affect
such URLs.

In the example, the repository could also be accessible as::

  http://example.com/_<ID>

The ID of a given repository can be shown from the repository ``Summary`` page,
by selecting the ``Show by ID`` button next to ``Clone URL``.


Email notifications
-------------------

With email settings properly configured in the Kallithea
configuration file, Kallithea will send emails on user registration and when
errors occur.

Emails are also sent for comments on changesets. In this case, an email is sent
to the committer of the changeset (if known to Kallithea), to all reviewers of
the pull request (if applicable) and to all people mentioned in the comment
using @mention notation.


Trending source files
---------------------

Trending source files are calculated based on a predefined dictionary of known
types and extensions. If an extension is missing or you would like to scan
custom files, it is possible to extend the ``LANGUAGES_EXTENSIONS_MAP``
dictionary located in ``kallithea/config/conf.py`` with new types.


Cloning remote repositories
---------------------------

Kallithea has the ability to clone repositories from given remote locations.
Currently it supports the following options:

- hg  -> hg clone
- svn -> hg clone
- git -> git clone

.. note:: svn -> hg cloning requires the ``hgsubversion`` library to be
   installed.

If you need to clone repositories that are protected via basic authentication,
you can pass the credentials in the URL, e.g.
``http://user:passw@remote.server/repo``. Kallithea will then try to login and
clone using the given credentials. Please note that the given credentials will
be stored as plaintext inside the database. However, the authentication
information will not be shown in the clone URL on the summary page.


Specific features configurable in the Admin settings
----------------------------------------------------

In general, the Admin settings should be self-explanatory and will not be
described in more detail in this documentation. However, there are a few
features that merit further explanation.

Repository extra fields
~~~~~~~~~~~~~~~~~~~~~~~

In the *Visual* tab, there is an option "Use repository extra
fields", which allows to set custom fields for each repository in the system.

Once enabled site-wide, the custom fields can be edited per-repository under
*Options* | *Settings* | *Extra Fields*.

Example usage of such fields would be to define company-specific information
into repositories, e.g., defining a ``repo_manager`` key that would give info
about a manager of each repository.  There's no limit for adding custom fields.
Newly created fields are accessible via the API.

Meta tagging
~~~~~~~~~~~~

In the *Visual* tab, option "Stylify recognised meta tags" will cause Kallithea
to turn certain text fragments in repository and repository group
descriptions into colored tags. Currently recognised tags are::

    [featured]
    [stale]
    [dead]
    [lang => lang]
    [license => License]
    [requires => Repo]
    [recommends => Repo]
    [see => URI]