from datetime import timedelta

### Set the time after which the admin session expires
# There are two sessions on pagure, login that holds for 31 days and
# the session defined here after which an user has to re-login.
# This session is used when accessing all administrative parts of pagure
# (ie: changing a project's or a user's settings)
ADMIN_SESSION_LIFETIME = timedelta(minutes=20)

### Secret key for the Flask application
SECRET_KEY='{{ pagure_secret_key }}'
SALT_EMAIL='{{ pagure_secret_salt_email }}'

### url to the database server:
#DB_URL=mysql://user:pass@host/db_name
#DB_URL=postgres://user:pass@host/db_name
DB_URL = 'postgresql://{{ pagure_db_user }}:{{ pagure_db_pass }}@{{ pagure_db_host }}/{{ pagure_db_name }}'

### The FAS group in which the admin of pagure are
ADMIN_GROUP = ['sysadmin-main']

### The email address to which the flask.log will send the errors (tracebacks)
EMAIL_ERROR = 'pingou@pingoured.fr'

### Default SMTP server to use for sending emails
SMTP_SERVER = 'localhost'

### Email used to sent emails
{% if env == 'pagure-staging' %}
FROM_EMAIL = 'pagure@stg.pagure.io'
DOMAIN_EMAIL_NOTIFICATIONS = 'stg.pagure.io'
{% else %}
FROM_EMAIL = 'pagure@pagure.io'
DOMAIN_EMAIL_NOTIFICATIONS = 'pagure.io'
{% endif %}

### The URL at which the project is available.
{% if env == 'pagure-staging' %}
APP_URL = 'https://stg.pagure.io/'
DOC_APP_URL = 'http://docs.stg.pagure.org'
{% else %}
APP_URL = 'https://pagure.io/'
DOC_APP_URL = 'https://docs.pagure.org'
{% endif %}

### The URL to use to clone git repositories.
{% if env == 'pagure-staging' %}
GIT_URL_SSH = 'git@stg.pagure.io'
GIT_URL_GIT = 'https://stg.pagure.io'
{% else %}
GIT_URL_SSH = 'git@pagure.io'
GIT_URL_GIT = 'https://pagure.io'
{% endif %}

### The IP addresses allowed for the internal endpoints
{% if env == 'pagure-staging' %}
IP_ALLOWED_INTERNAL = ['127.0.0.1', 'localhost', '::1', '140.211.169.203']
{% else %}
IP_ALLOWED_INTERNAL = ['127.0.0.1', 'localhost', '::1', '140.211.169.204']
{% endif %}

# Redis configuration
{% if env == 'pagure-staging' %}
EVENTSOURCE_SOURCE = 'https://stg.pagure.io:8088'
{% else %}
EVENTSOURCE_SOURCE = 'https://pagure.io:8088'
{% endif %}
REDIS_HOST = '0.0.0.0'
REDIS_PORT = 6379
REDIS_DB = 0

### Folder containing to the git repos
GIT_FOLDER = '/srv/git/repositories'

### Folder containing the forks repos
FORK_FOLDER = '/srv/git/repositories/forks'

### Folder containing the docs repos
DOCS_FOLDER = '/srv/git/repositories/docs'

### Folder containing the pull-requests repos
REQUESTS_FOLDER = '/srv/git/repositories/requests'

### Folder containing the tickets repos
TICKETS_FOLDER = '/srv/git/repositories/tickets'

### Configuration file for gitolite
GITOLITE_CONFIG = '/srv/git/.gitolite/conf/gitolite.conf'

### Path of the release folder
UPLOAD_FOLDER = 'releases/'
UPLOAD_FOLDER_PATH = '/var/www/' + UPLOAD_FOLDER


### Home folder of the gitolite user
### Folder where to run gl-compile-conf from
GITOLITE_HOME = '/srv/git/'

### Folder containing all the public ssh keys for gitolite
GITOLITE_KEYDIR = '/srv/git/.gitolite/keydir/'

### Path to the gitolite.rc file
GL_RC = '/srv/git/.gitolite.rc'

### Path to the /bin directory where the gitolite tools can be found
GL_BINDIR = '/usr/bin/'


### Temp folder to be used to make the clones to work around bug in libgit2:
## refs: https://github.com/libgit2/libgit2/issues/2965
## and   https://github.com/libgit2/libgit2/issues/2797
TMP_FOLDER = '/srv/tmp'

# Optional configuration

### Number of items displayed per page
# Used when listing items
ITEM_PER_PAGE = 50

### Maximum size of the uploaded content
# Used to limit the size of file attached to a ticket for example
MAX_CONTENT_LENGTH = 4 * 1024 * 1024  # 4 megabytes

### Lenght for short commits ids or file hex
SHORT_LENGTH = 6

### List of blacklisted project names that can conflicts for pagure's URLs
### or other
BLACKLISTED_PROJECTS = [
    'static', 'pv', 'releases', 'new', 'api', 'settings',
    'logout', 'login', 'users', 'groups']

DISABLED_PLUGINS = ['IRC']


# Authentication related configuration option

### Switch the authentication method
# Specify which authentication method to use, defaults to `fas` can be or
# `local`
# Default: ``fas``.
PAGURE_AUTH = 'fas'

# When this is set to True, the session cookie will only be returned to the
# server via ssl (https). If you connect to the server via plain http, the
# cookie will not be sent. This prevents sniffing of the cookie contents.
# This may be set to False when testing your application but should always
# be set to True in production.
# Default: ``True``.
SESSION_COOKIE_SECURE = True

# The name of the cookie used to store the session id.
# Default: ``.pagure``.
SESSION_COOKIE_NAME = 'pagure'

# Boolean specifying wether to check the user's IP address when retrieving
# its session. This make things more secure (thus is on by default) but
# under certain setup it might not work (for example is there are proxies
# in front of the application).
CHECK_SESSION_IP = True

# Used by SESSION_COOKIE_PATH
APPLICATION_ROOT = '/'

# Set the SSH certs/keys
{% if env == 'pagure-staging' %}
SSH_KEYS = {
    'RSA': {
        'fingerprint': '2048 69:50:46:24:c7:94:44:f8:8d:83:05:5c:eb:73:fb:c4   (RSA)',
        'pubkey': 'stg.pagure.io,140.211.169.203 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDJNu490Rp305zGCJLvhVIrKjL7Xngew3NxgRYeopHBDvj+EFQUqULXtgrI5nUBMSB94RrsuHynFAXYy2m0snHjWzWjbIxM4ZVD2sX4GiKX6qu7WyxcGmGcL08MF919r+JSPL9oWWSq/CvvBF0M1eeqkIpjMZHpVKgR3uTMD5yW994NBLAQi9i1UdwGYNQc1KqWvlvW1XhFFtiIGscIFGRKsUOMvnJvWdU6T+djmzMy4hcahxnsPCZxCjbQpuH1JjihNNVWYOq7Ztjs1gxpTTV19ATp4Z2F95uyyQ3Y+Em9KeXcKXYxwVzYVho5SSB1ZYBL+xAH1osK23PvGD39UYp9'
    }
}
{% else %}
SSH_KEYS = {
    'RSA': {
        'fingerprint': '2048 90:8e:7f:a3:f7:f1:70:cb:56:77:96:17:44:c4:fc:82   (RSA)',
        'pubkey': 'pagure.io,140.211.169.204 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC198DWs0SQ3DX0ptu+8Wq6wnZMrXUCufN+wdSCtlyhHUeQ3q5B4Hgto1n2FMj752vToCfNTn9mWO7l2rNTrKeBsELpubl2jECHu4LqxkRVihu5UEzejfjiWNDN2jdXbYFY27GW9zymD7Gq3u+T/Mkp4lIcQKRoJaLobBmcVxrLPEEJMKI4AJY31jgxMTnxi7KcR+U5udQrZ3dzCn2BqUdiN5dMgckr4yNPjhl3emJeVJ/uhAJrEsgjzqxAb60smMO5/1By+yF85Wih4TnFtF4LwYYuxgqiNv72Xy4D/MGxCqkO/nH5eRNfcJ+AJFE7727F7Tnbo4xmAjilvRria/+l'
    }
}
{% endif %}
