-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from CodeBattles-nn/dev
Security fixes
- Loading branch information
Showing
12 changed files
with
67 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,5 @@ Flask-Cors~=4.0.0 | |
redis~=5.0.1 | ||
captcha~=0.5.0 | ||
gunicorn~=22.0.0 | ||
wtforms~=3.1.2 | ||
wtforms_json~=0.3.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
import wtforms_json | ||
from flask import Flask, request, make_response | ||
|
||
wtforms_json.init() | ||
|
||
app = Flask(__name__) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from functools import wraps | ||
from typing import Type | ||
|
||
from flask import abort, request | ||
from wtforms import Form | ||
|
||
|
||
def json_validate(clazz: Type[Form]): | ||
def decorator(f): | ||
@wraps(f) | ||
def decorated_function(*args, **kwargs): | ||
x: Form = clazz.from_json(request.json) | ||
if not x.validate(): | ||
return abort(400) | ||
return f(*args, **kwargs, data=x) | ||
|
||
return decorated_function | ||
|
||
return decorator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from wtforms import Form, StringField, IntegerField | ||
from wtforms.validators import DataRequired, Regexp | ||
|
||
from utils import LETTER_REGEX | ||
|
||
|
||
class LoginForm(Form): | ||
id = IntegerField('id', validators=[DataRequired()]) | ||
login = StringField('login', validators=[DataRequired()]) | ||
password = StringField('password', validators=[DataRequired()]) | ||
|
||
|
||
class SendProgramForm(Form): | ||
cars = StringField('cars', validators=[DataRequired()]) | ||
src = StringField('src', validators=[DataRequired()]) | ||
problem = StringField('problem', | ||
validators=[DataRequired(), Regexp(LETTER_REGEX)]) |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters