Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LDAP attribute mapping env variables. #344

Merged
merged 9 commits into from Oct 27, 2022

Conversation

BrianCArnold
Copy link
Contributor

When using a default Samba DC LDAP instance, uid isn't used to hold the username, so for this, and other LDAP implementations, it's necessary to be able to specify which LDAP attributes are actually used for first name, last name, username, email, etc.

This doesn't change the default behavior, as it uses the current hardcoded values as the default values instead of requiring admins to specify it if they are upgrading to a version containing this feature.

Specifically made sure that LDAP auth works the same if the
new environment variables aren't set, in order to maintain
behavior for users who are already using LDAP if they don't
set the new envvars.
@BrianCArnold
Copy link
Contributor Author

The current version doesn't work right, I'm still figuring out what's wrong.

@BrianCArnold
Copy link
Contributor Author

I figured out what I did wrong, stupid mistakes because I'm not a python programmer. Everything appears to work as desired now.

@bbilly1
Copy link
Member

bbilly1 commented Oct 24, 2022

Thanks for your addition. @DanielBatteryStapler is our resident LDAP expert who created the original implementation. Can you take a look at these changes?

Then you might have seen, the linter is unhappy with the formatting. Mostly about line length and whitespaces. In the deploy.sh script there is a validation function so you can run the linter locally.

@BrianCArnold
Copy link
Contributor Author

I see what the linter trying to get at. I wonder why it didn't have an issue with the original version, seems similar. I'm about to start my workday, I'll get back to it and fix it some time later today.

@DanielBatteryStapler
Copy link
Contributor

Changes look great to me, I approve. Thank you for your additions! I thought about including exactly this in my initial LDAP additions, but I got lazy and thought that the defaults would be good enough -- guess I was wrong about that one. Glad to see that get fixed.

@BrianCArnold
Copy link
Contributor Author

This should be fixed according to the linter.

@BrianCArnold
Copy link
Contributor Author

That's odd, the linter accepted it on my end...

@bbilly1
Copy link
Member

bbilly1 commented Oct 26, 2022

Almost there, flake8 doesn't like the long lines in settings.py between line 108 and 115. Unfortunately I need to run the action here manually for fist time contributors, it's a github thing...

@BrianCArnold
Copy link
Contributor Author

oh, i was pretty sure I fixed those too, I'll check.

@bbilly1
Copy link
Member

bbilly1 commented Oct 26, 2022

Python also has this nifty multi line comment feature, basically wrap it in """ like this:

"""
this is a multi
line comment
spanning over
multiple lines,
nicely.
"""

Does the same as your solution, but you look more like a Python pro. :-)

@DanielBatteryStapler
Copy link
Contributor

I'm just gonna pop in to be annoying and say those aren't multi-line comments, those are multi-line string literals and you're simply ignoring their value! Still useful as comments though lol

@BrianCArnold
Copy link
Contributor Author

... I'm not sure if I love or hate that.

@BrianCArnold
Copy link
Contributor Author

The language behavior, not you popping in. I enjoy "technically correct", I am a programmer, a after all.

@bbilly1
Copy link
Member

bbilly1 commented Oct 26, 2022

Yeah, technically correct yes, bot not really what people use, e.g. if you google python "multiline comment" you get 2.4M+ results, all (probably?) talking about the same thing. If you google python "multiline string literals" you get 19k not really useful results.

But I had to look it up, PEP8 technically calls them Docstring, even has it's own page in PEP 257. They are usually on top of the declaration, but let's not get hung up on that.

And yes, I always enjoy the technically things too. :-)

@BrianCArnold
Copy link
Contributor Author

Shortened line lengths.

@BrianCArnold
Copy link
Contributor Author

I officially renounce Python, lol

@bbilly1
Copy link
Member

bbilly1 commented Oct 27, 2022

Sorry, I took the liberty to fix the remaining few whitespace issues. I know, python linting needs some time to get used to. Please don't be discouraged, there are lots of great opportunities to help with this project! :-)

@bbilly1 bbilly1 merged commit 6b2fe12 into tubearchivist:master Oct 27, 2022
@BrianCArnold
Copy link
Contributor Author

I just need to take the time to actually get a decent python environment set up, i've been using a docker container to run black, but it's not ideal, and VSCode doesn't seem to be getting along with my Python environment.

@bbilly1
Copy link
Member

bbilly1 commented Oct 27, 2022

Yeah, after some time fixing the same issues over and over, you'll get the hang of it. I know it's the equivalent of a grammar naz*, but it does make the code much more readable, particularly if you have a few people working on the same code base...

Anyways, thanks for your contribution, all help is welcome with this project!

@BrianCArnold
Copy link
Contributor Author

I'm actually a huge stickler for linting and keeping code clean, it's just that I don't care as just about EOL white space, and I have my line length set as warnings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants