When making this website, i wanted a simple, reasonable way to make it look good on most displays. Not counting any minimization techniques, the following 58 bytes worked well for me:
main {
max-width: 38rem;
padding: 2rem;
margin: auto;
}| LDAP_SERVER = "ldaps://my-ldap-server.com/" | |
| LDAP_BASE = "dc=my-ldap-server,dc=com" | |
| def users_ldap_groups(uid): | |
| """ Returns a list of the groups that the uid is a member of. | |
| Returns False if it can't find the uid or throws an exception. | |
| It's up to the caller to ensure that the UID they're using exists! | |
| """ | |
| logger.debug("uid: ", uid) |
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| from flask import * | |
| import os | |
| from werkzeug import secure_filename | |
| app = Flask(__name__) | |
| #searchword = request.args.get('q', '') |
| ######################## | |
| # UUID for SQLite hack # | |
| ######################## | |
| from sqlalchemy.types import TypeDecorator, CHAR | |
| from sqlalchemy.dialects.postgresql import UUID | |
| import uuid | |
| class GUID(TypeDecorator): |
If anyone is interested in setting up their system to automatically (or manually) sign their git commits with their GPG key, here are the steps:
$ git config --global commit.gpgsign true ([OPTIONAL] every commit will now be signed)$ git config --global user.signingkey ABCDEF01 (where ABCDEF01 is the fingerprint of the key to use)$ git config --global alias.logs "log --show-signature" (now available as $ git logs)$ git config --global alias.cis "commit -S" (optional if global signing is false)$ echo "Some content" >> example.txt$ git add example.txt$ git cis -m "This commit is signed by a GPG key." (regular commit will work if global signing is enabled)| # Generate a new pgp key: (better to use gpg2 instead of gpg in all below commands) | |
| gpg --gen-key | |
| # maybe you need some random work in your OS to generate a key. so run this command: `find ./* /home/username -type d | xargs grep some_random_string > /dev/null` | |
| # check current keys: | |
| gpg --list-secret-keys --keyid-format LONG | |
| # See your gpg public key: | |
| gpg --armor --export YOUR_KEY_ID | |
| # YOUR_KEY_ID is the hash in front of `sec` in previous command. (for example sec 4096R/234FAA343232333 => key id is: 234FAA343232333) |
| def auth_ldap_user(username, password): | |
| server = Server(settings.LDAP_HOST_URL, use_ssl=settings.LDAP_SSL) | |
| if settings.LDAP_BIND_DN is not None: | |
| conn = Connection( | |
| server, | |
| settings.LDAP_BIND_DN, | |
| password=settings.LDAP_BIND_DN_PASSWORD, | |
| authentication=settings.LDAP_AUTH_METHOD, | |
| auto_bind=True, | |
| ) |
| def pwned(password): | |
| """ | |
| Check password against pwnedpasswords API using k-Anonymity. | |
| https://haveibeenpwned.com/API/v3 | |
| :return: Count of password in DB (0 means hasn't been compromised) | |
| Can raise HTTPError | |
| .. versionadded:: 3.4.0 | |
| """ | |
| def convert_password_tuple(value): |
| import ldap | |
| def check_credentials(username, password): | |
| """Verifies credentials for username and password. | |
| Returns None on success or a string describing the error on failure | |
| # Adapt to your needs | |
| """ | |
| LDAP_SERVER = 'ldap://xxx' | |
| # fully qualified AD user name | |
| LDAP_USERNAME = '%[email protected]' % username |
| from flask import Flask | |
| from importlib import import_module | |
| from app.extensions import celery | |
| def create_application(config_path: str = None) -> Flask: | |
| app = Flask(__name__) | |
| app.config.from_pyfile("settings.cfg") | |
| app.config.from_envvar("APP_CONFIG", silent=True) |