Skip to content

Commit 35425c6

Browse files
authored
Merge pull request #115 from ComputerScienceHouse/cole-dev
bump, clean, and switch to using keycloak custom TOTP API
2 parents aaa88ba + 8774c0d commit 35425c6

19 files changed

Lines changed: 585 additions & 309 deletions

.github/pull_request_template.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
## What
2+
3+
_what the PR changes_
4+
5+
## Why
6+
7+
_why these changes were made_
8+
9+
## Test Plan
10+
11+
_how did you verify these changes did what you expected_
12+
13+
## Env Vars
14+
15+
_did you add, remove, or rename any environment variables_
16+
17+
## Checklist
18+
19+
- [ ] Tested all changes locally

.github/workflows/python-app.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ jobs:
1818
- name: Install ldap dependencies
1919
run: sudo apt-get install libldap2-dev libsasl2-dev
2020
- uses: actions/checkout@v2
21-
- name: Set up Python 3.6
21+
- name: Set up Python 3.13
2222
uses: actions/setup-python@v2
2323
with:
24-
python-version: 3.6
24+
python-version: 3.13
2525
- name: Install dependencies
2626
run: |
2727
python -m pip install --upgrade pip

.pylintrc

Lines changed: 16 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ persistent=yes
1616

1717
# List of plugins (as comma separated values of python modules names) to load,
1818
# usually to register additional checkers.
19-
load-plugins=
19+
#load-plugins=
2020

2121
# Use multiple processes to speed up Pylint.
2222
jobs=1
@@ -28,14 +28,14 @@ unsafe-load-any-extension=no
2828
# A comma-separated list of package or module names from where C extensions may
2929
# be loaded. Extensions are loading into the active Python interpreter and may
3030
# run arbitrary code
31-
extension-pkg-whitelist=
31+
#extension-pkg-whitelist=
3232

3333

3434
[MESSAGES CONTROL]
3535

3636
# Only show warnings with the listed confidence levels. Leave empty to show
3737
# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED
38-
confidence=
38+
#confidence=
3939

4040
# Enable the message, report, category or checker with the given id(s). You can
4141
# either give multiple identifier separated by comma (,) or put this option
@@ -62,12 +62,11 @@ disable=
6262
too-few-public-methods,
6363
no-member,
6464
too-many-format-args,
65-
bad-continuation,
6665
bare-except,
6766
inconsistent-return-statements,
6867
no-name-in-module,
6968
cyclic-import,
70-
unnecessary-pass,
69+
unnecessary-pass
7170

7271

7372
[REPORTS]
@@ -77,11 +76,6 @@ disable=
7776
# mypackage.mymodule.MyReporterClass.
7877
output-format=text
7978

80-
# Put messages in a separate file for each module / package specified on the
81-
# command line instead of printing them on stdout. Reports (if any) will be
82-
# written in a file name "pylint_global.[txt|html]".
83-
files-output=no
84-
8579
# Tells whether to display a full report or only the messages
8680
reports=no
8781

@@ -136,7 +130,7 @@ dummy-variables-rgx=_$|dummy
136130

137131
# List of additional names supposed to be defined in builtins. Remember that
138132
# you should avoid to define new builtins when possible.
139-
additional-builtins=
133+
#additional-builtins=
140134

141135
# List of strings which can identify a callback function by name. A callback
142136
# name must start or end with one of those strings.
@@ -155,9 +149,6 @@ ignore-long-lines=^\s*(# )?<?https?://\S+>?$
155149
# else.
156150
single-line-if-stmt=no
157151

158-
# List of optional constructs for which whitespace checking is disabled
159-
no-space-check=trailing-comma,dict-separator
160-
161152
# Maximum number of lines in a module
162153
max-module-lines=2000
163154

@@ -169,14 +160,11 @@ indent-string=' '
169160
indent-after-paren=4
170161

171162
# Expected format of line ending, e.g. empty (any line ending), LF or CRLF.
172-
expected-line-ending-format=
163+
#expected-line-ending-format=
173164

174165

175166
[BASIC]
176167

177-
# List of builtins function names that should not be used, separated by a comma
178-
bad-functions=map,filter,input
179-
180168
# Good variable names which should always be accepted, separated by a comma
181169
good-names=i,j,k,ex,Run,_
182170

@@ -185,71 +173,41 @@ bad-names=foo,bar,baz,toto,tutu,tata
185173

186174
# Colon-delimited sets of names that determine each other's naming style when
187175
# the name regexes allow several styles.
188-
name-group=
176+
#name-group=
189177

190178
# Include a hint for the correct naming format with invalid-name
191179
include-naming-hint=no
192180

193181
# Regular expression matching correct function names
194182
function-rgx=[a-z_][a-z0-9_]{2,30}$
195183

196-
# Naming hint for function names
197-
function-name-hint=[a-z_][a-z0-9_]{2,30}$
198-
199184
# Regular expression matching correct variable names
200185
variable-rgx=[a-z_][a-z0-9_]{2,30}$
201186

202-
# Naming hint for variable names
203-
variable-name-hint=[a-z_][a-z0-9_]{2,30}$
204-
205187
# Regular expression matching correct constant names
206188
const-rgx=[a-z_][a-z0-9_]{2,30}$
207189

208-
# Naming hint for constant names
209-
const-name-hint=(([A-Z_][A-Z0-9_]*)|(__.*__))$
210-
211190
# Regular expression matching correct attribute names
212191
attr-rgx=[a-z_][a-z0-9_]{2,30}$
213192

214-
# Naming hint for attribute names
215-
attr-name-hint=[a-z_][a-z0-9_]{2,30}$
216-
217193
# Regular expression matching correct argument names
218194
argument-rgx=[a-z_][a-z0-9_]{2,30}$
219195

220-
# Naming hint for argument names
221-
argument-name-hint=[a-z_][a-z0-9_]{2,30}$
222-
223196
# Regular expression matching correct class attribute names
224197
class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$
225198

226-
# Naming hint for class attribute names
227-
class-attribute-name-hint=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$
228-
229199
# Regular expression matching correct inline iteration names
230200
inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$
231201

232-
# Naming hint for inline iteration names
233-
inlinevar-name-hint=[A-Za-z_][A-Za-z0-9_]*$
234-
235202
# Regular expression matching correct class names
236203
class-rgx=[A-Z_][a-zA-Z0-9]+$
237204

238-
# Naming hint for class names
239-
class-name-hint=[A-Z_][a-zA-Z0-9]+$
240-
241205
# Regular expression matching correct module names
242206
module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
243207

244-
# Naming hint for module names
245-
module-name-hint=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
246-
247208
# Regular expression matching correct method names
248209
method-rgx=[a-z_][a-z0-9_]{2,30}$
249210

250-
# Naming hint for method names
251-
method-name-hint=[a-z_][a-z0-9_]{2,30}$
252-
253211
# Regular expression which should only match function or class names that do
254212
# not require a docstring.
255213
no-docstring-rgx=__.*__
@@ -271,11 +229,11 @@ ignore-mixin-members=yes
271229
# List of module names for which member attributes should not be checked
272230
# (useful for modules/projects where namespaces are manipulated during runtime
273231
# and thus existing member attributes cannot be deduced by static analysis
274-
ignored-modules=
232+
#ignored-modules=
275233

276234
# List of classes names for which member attributes should not be checked
277235
# (useful for classes with attributes dynamically set).
278-
ignored-classes=SQLObject, optparse.Values, thread._local, _thread._local
236+
ignored-classes=SQLObject,optparse.Values,thread._local,_thread._local
279237

280238
# List of members which are set dynamically and missed by pylint inference
281239
# system, and so shouldn't trigger E1101 when accessed. Python regular
@@ -291,13 +249,13 @@ contextmanager-decorators=contextlib.contextmanager
291249

292250
# Spelling dictionary name. Available dictionaries: none. To make it working
293251
# install python-enchant package.
294-
spelling-dict=
252+
#spelling-dict=
295253

296254
# List of comma separated words that should not be checked.
297-
spelling-ignore-words=
255+
#spelling-ignore-words=
298256

299257
# A path to a file that contains private dictionary; one word per line.
300-
spelling-private-dict-file=
258+
#spelling-private-dict-file=
301259

302260
# Tells whether to store unknown words to indicated private dictionary in
303261
# --spelling-private-dict-file option instead of raising a message.
@@ -361,19 +319,19 @@ deprecated-modules=regsub,TERMIOS,Bastion,rexec
361319

362320
# Create a graph of every (i.e. internal and external) dependencies in the
363321
# given file (report RP0402 must not be disabled)
364-
import-graph=
322+
#import-graph=
365323

366324
# Create a graph of external dependencies in the given file (report RP0402 must
367325
# not be disabled)
368-
ext-import-graph=
326+
#ext-import-graph=
369327

370328
# Create a graph of internal dependencies in the given file (report RP0402 must
371329
# not be disabled)
372-
int-import-graph=
330+
#int-import-graph=
373331

374332

375333
[EXCEPTIONS]
376334

377335
# Exceptions that will emit a warning when being caught. Defaults to
378336
# "Exception"
379-
overgeneral-exceptions=Exception
337+
overgeneral-exceptions=builtins.Exception

Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM docker.io/python:3.13-slim
2+
MAINTAINER Computer Science House <webmaster@csh.rit.edu>
3+
4+
RUN mkdir /opt/selfservice
5+
6+
ADD requirements.txt /opt/selfservice
7+
8+
WORKDIR /opt/selfservice
9+
10+
RUN apt-get -yq update && \
11+
apt-get -yq install libsasl2-dev libldap2-dev libldap-common libssl-dev git gcc g++ make && \
12+
pip install -r requirements.txt && \
13+
apt-get -yq clean all
14+
15+
ADD . /opt/selfservice
16+
17+
EXPOSE 8080
18+
19+
CMD ["gunicorn", "selfservice:app", "--bind=0.0.0.0:8080", "--access-logfile=-", "--timeout=256"]
20+

config.env.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@
3535
)
3636
SQLALCHEMY_TRACK_MODIFICATIONS = False
3737

38-
RECAPTCHA_ENABLED = True
39-
RECAPTCHA_SITE_KEY = os.environ.get("RECAPTCHA_SITE_KEY", "")
40-
RECAPTCHA_SECRET_KEY = os.environ.get("RECAPTCHA_SECRET_KEY", "")
41-
RECAPTCHA_THEME = "light"
42-
RECAPTCHA_TYPE = "image"
43-
RECAPTCHA_SIZE = "normal"
38+
XCAPTCHA_ENABLED = True
39+
XCAPTCHA_SITE_KEY = os.environ.get("XCAPTCHA_SITE_KEY", "")
40+
XCAPTCHA_SECRET_KEY = os.environ.get("XCAPTCHA_SECRET_KEY", "")
41+
XCAPTCHA_THEME = "light"
42+
XCAPTCHA_TYPE = "image"
43+
XCAPTCHA_SIZE = "normal"
4444

4545
TWILIO_SID = os.environ.get("TWILIO_SID", "")
4646
TWILIO_TOKEN = os.environ.get("TWILIO_TOKEN", "")

docker-compose.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: '2'
22
services:
33
postgres:
4-
image: postgres:9.6
4+
image: docker.io/postgres:9.6
55
container_name: selfservice-postgres
66
restart: always
77
volumes:
@@ -12,7 +12,7 @@ services:
1212
ports:
1313
- 127.0.0.1:5433:5432
1414
phppgadmin:
15-
image: bitnami/phppgadmin:latest
15+
image: docker.io/dockage/phppgadmin:latest
1616
container_name: selfservice-pgadmin
1717
links:
1818
- postgres
@@ -22,4 +22,4 @@ services:
2222
restart: always
2323
ports:
2424
- 127.0.0.1:8081:8080
25-
- 127.0.0.1:8444:8443
25+
- 127.0.0.1:8444:8443

migrations/versions/a83f363599a0_.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ def upgrade():
2020
# ### commands auto generated by Alembic - please adjust! ###
2121
op.create_table('otp_session',
2222
sa.Column('secret', sa.String(length=100), nullable=False),
23-
sa.Column('form', sa.Binary(), nullable=True),
24-
sa.Column('session', sa.Binary(), nullable=True),
23+
sa.Column('form', sa.LargeBinary(), nullable=True),
24+
sa.Column('session', sa.LargeBinary(), nullable=True),
2525
sa.PrimaryKeyConstraint('secret')
2626
)
2727
op.create_table('session',
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
"""Remove OTPSession table
2+
3+
Revision ID: fdb69cd98e19
4+
Revises: a541afdca952
5+
Create Date: 2025-12-21 15:34:01.851353
6+
7+
"""
8+
from alembic import op
9+
import sqlalchemy as sa
10+
from sqlalchemy.dialects import postgresql
11+
12+
# revision identifiers, used by Alembic.
13+
revision = 'fdb69cd98e19'
14+
down_revision = 'a541afdca952'
15+
branch_labels = None
16+
depends_on = None
17+
18+
19+
def upgrade():
20+
# ### commands auto generated by Alembic - please adjust! ###
21+
op.drop_table('otp_session')
22+
# ### end Alembic commands ###
23+
24+
25+
def downgrade():
26+
# ### commands auto generated by Alembic - please adjust! ###
27+
op.create_table('otp_session',
28+
sa.Column('secret', sa.VARCHAR(length=100), autoincrement=False, nullable=False),
29+
sa.Column('form', postgresql.BYTEA(), autoincrement=False, nullable=True),
30+
sa.Column('session', postgresql.BYTEA(), autoincrement=False, nullable=True),
31+
sa.PrimaryKeyConstraint('secret', name=op.f('otp_session_pkey'))
32+
)
33+
# ### end Alembic commands ###

requirements.dev

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)