These are chat archives for allegro/ralph

29th
Sep 2016
Pete
@kasim1r
Sep 29 2016 11:03
basic question
yes, sorry, me again :P
documentation of Ralph takes place in http://ralph-ng.readthedocs.io or in the git repo?
or: which is newer / better / more relevant ?
Mateusz Kurek
@mkurek
Sep 29 2016 11:06
source code is in git repo, but every time there is change in docs in git repo, it's built on http://ralph-ng.readthedocs.io/ automatically
Pete
@kasim1r
Sep 29 2016 11:12
ah, cool
Pete
@kasim1r
Sep 29 2016 11:24
are you guys running allegro.pl?
Mateusz Kurek
@mkurek
Sep 29 2016 11:26
yes :)
Pete
@kasim1r
Sep 29 2016 11:27
excellent!
Pete
@kasim1r
Sep 29 2016 11:38
the sample configuration for LDAP you show, where exactly would I have to put that?
the part starting with import ldap
lib/python3.4/site-packages/django_auth_ldap/config.py ?
hm, probably not.
Mateusz Kurek
@mkurek
Sep 29 2016 11:42
it'll be the best if you'd create your own settings file and run ralph like DJANGO_SETTINGS_MODULE=local_settings ralph runserver ..., where local_settings.py is file with settings in your current dir. On top of this file you should place from ralph.settings.prod import *
it's not tested so it might not work exactly as i told you - but maybe one of Ralph folks ( @szok @ar4s @xliiv @vi4m or me) could test it in next few days
Pete
@kasim1r
Sep 29 2016 11:43
i'll try
I#ll also combine that with running Ralph not as root, but as a standard user
for that I would chown -R ralph.ralph /opt/ralph
do you think it's safe to do that?
Mateusz Kurek
@mkurek
Sep 29 2016 11:47
imo yes
Pete
@kasim1r
Sep 29 2016 11:48
using the Ubuntu package, that's why I'm asking
Pete
@kasim1r
Sep 29 2016 13:32
hey, @mkurek I did as you said, let me describe what I have now
I created a user ralph
in his homedir I have local-settings.py
from ralph.settings.prod import
AUTHENTICATION_BACKENDS = (
'django_auth_ldap.backend.LDAPBackend',
'django.contrib.auth.backends.ModelBackend',
)
LOGGING['loggers']['django_auth_ldap'] = {
'handlers': ['file'],
'propagate': True,
'level': 'DEBUG',
}
import ldap
from django_auth_ldap.config import LDAPSearch, GroupOfNamesType
AUTH_LDAP_SERVER_URI = "ldap://private.domain:389"
AUTH_LDAP_BIND_DN = "CN=bla,DC=private,DC=domain"
AUTH_LDAP_BIND_PASSWORD = "securepw"
AUTH_LDAP_PROTOCOL_VERSION = 3
AUTH_LDAP_USER_USERNAME_ATTR = "sAMAccountName"
AUTH_LDAP_USER_SEARCH_BASE = "OU=users,DC=private,DC=domain"
AUTH_LDAP_USER_SEARCH_FILTER = '(&(objectClass=
)({0}=%(user)s))'.format(
AUTH_LDAP_USER_USERNAME_ATTR)
AUTH_LDAP_USER_SEARCH = LDAPSearch(AUTH_LDAP_USER_SEARCH_BASE,
ldap.SCOPE_SUBTREE, AUTH_LDAP_USER_SEARCH_FILTER)
AUTH_LDAP_USER_ATTR_MAP = {
"first_name": "givenName",
"last_name": "sn",
"email": "mail"
"company": "company",
"manager": "manager",
"department": "department",
"employee_id": "employeeID",
"location": "officeName",
"country": "ISO-country-code",
}
then I created a (very very basic) start-script
export DATABASE_NAME=ralph
export DATABASE_USER=ralph
export DATABASE_PASSWORD=blabla
export DATABASE_HOST=localhost
export PATH=/opt/ralph/ralph-core/bin/:$PATH
export RALPH_DEBUG=1
export DJANGO_SETTINGS_MODULE=local_settings
ralph runserver 0.0.0.0:8000
what I now get is
ImportError: No module named 'local_settings'
what am I doing wrong?
Pete
@kasim1r
Sep 29 2016 13:48
should I put local_settings.py into /opt/ralph/ralph-core/lib/python3.4/site-packages/django/conf/ ?
no, didn't help
damian1976
@damian1976
Sep 29 2016 13:53
have you got a folder like /opt/ralph/ralph-core/src ?
Pete
@kasim1r
Sep 29 2016 13:54
no. I'm using the Ubuntu package
✪ vi4m Marcin Kliks
@vi4m
Sep 29 2016 13:54
@ar4s @kasim1r @mkurek i think we should ship django-auth-ldap inside the package
damian1976
@damian1976
Sep 29 2016 13:54
ok. so you can't see prod.py or base.py or dev.py ?
✪ vi4m Marcin Kliks
@vi4m
Sep 29 2016 13:55
it's small enough to be zero-problem for us, and for user it will be more user friendly to just have it installed
Pete
@kasim1r
Sep 29 2016 13:55
/opt/ralph/ralph-core/lib/python3.4/site-packages/ralph/settings/prod.py
base.py : lots of them under /opt/ralph
damian1976
@damian1976
Sep 29 2016 13:56
ok, so place your local.py or local_settings.py there
/opt/ralph/ralph-core/lib/python3.4/site-packages/ralph/settings/
Pete
@kasim1r
Sep 29 2016 13:56
ImportError: No module named 'local_settings' still
damian1976
@damian1976
Sep 29 2016 13:57
and then try DJANGO_SETTINGS_MODULE=ralph.settings.local ralph runserver (if your file is called local.py)
or DJANGO_SETTINGS_MODULE=ralph.settings.local_settings ralph runserver
✪ vi4m Marcin Kliks
@vi4m
Sep 29 2016 13:58
and remember about the difference between local-settings.py / local_settings
Pete
@kasim1r
Sep 29 2016 13:59
"company": "company",
^
SyntaxError: invalid syntax
the up tick cpoint to the ":"
damian1976
@damian1976
Sep 29 2016 13:59
ok, so you made a step forward :)
Pete
@kasim1r
Sep 29 2016 14:00
yeees
damian1976
@damian1976
Sep 29 2016 14:00
you are missing comma before company in the preceeding line
Arkadiusz Adamski
@ar4s
Sep 29 2016 14:00
missing comma after "email": "mail"
Pete
@kasim1r
Sep 29 2016 14:01
yay :)
success
the code was copy-paste from the Docu :P
damian1976
@damian1976
Sep 29 2016 14:01
great:)
Pete
@kasim1r
Sep 29 2016 14:03
yahooo, I can log in. after adding "staff status" to the user, which got auto created
Pete
@kasim1r
Sep 29 2016 14:08
is it "okay" to put an nginx in front of ralph for HTTPS?
damian1976
@damian1976
Sep 29 2016 14:14
this is what I have
works like a charm:)
Pete
@kasim1r
Sep 29 2016 14:15
OK. do I need to adapt the URL anywhere? cos it's no longer going to be ralph.my.domain:8000 but https://ralph.my.domain
which I call in the browser
and in the API
damian1976
@damian1976
Sep 29 2016 14:18

what you have to do is something like that: in nginx conf you define server for port 80. In there you create

return         301 https://$server_name$request_uri;

and in second the server section for 443 you create a section

location / {
                proxy_pass http://ralph.my.domain:8000;
        }
Pete
@kasim1r
Sep 29 2016 14:24
yes, thx, what I meant is: does ralph need to know that the URL it's actually running on is different nbow
*now
Pete
@kasim1r
Sep 29 2016 14:34
forget it, the API is obviously returning the called URL
very nice