Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Hiboo
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cyrinux
Hiboo
Commits
fd3b7048
Commit
fd3b7048
authored
1 year ago
by
kaiyou
Browse files
Options
Downloads
Plain Diff
Merge branch '110-update-python-deps' into 'main'
Resolve "Mise à jour des dépendences python" Closes
#110
See merge request
!76
parents
b15e0cfb
dd1c88d6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
hiboo/captcha/captcha.py
+10
-6
10 additions, 6 deletions
hiboo/captcha/captcha.py
hiboo/models.py
+16
-18
16 additions, 18 deletions
hiboo/models.py
hiboo/utils.py
+1
-3
1 addition, 3 deletions
hiboo/utils.py
poetry.lock
+912
-831
912 additions, 831 deletions
poetry.lock
pyproject.toml
+18
-18
18 additions, 18 deletions
pyproject.toml
with
957 additions
and
876 deletions
hiboo/captcha/captcha.py
+
10
−
6
View file @
fd3b7048
...
...
@@ -67,29 +67,33 @@ class ImageCaptchaField(fields.CaptchaField):
'
<p><img src=
"
data:image/png;base64,{}
"
></p>
'
.
format
(
output
)
)
+
super
(
ImageCaptchaField
,
self
).
__call__
(
**
kwargs
)
def
get_size
(
self
,
text
,
scale
=
(
1
,
1
)):
left
,
top
,
right
,
bottom
=
self
.
font
.
getbbox
(
text
)
sx
,
sy
=
scale
return
(
int
(
sx
*
(
right
-
left
)),
int
(
sy
*
(
bottom
-
top
)))
def
make_char
(
self
,
char
,
rotation_range
=
15
):
"""
Renders a character
"""
drawn
=
"
{}
"
.
format
(
char
)
rotation
=
random
.
randrange
(
-
rotation_range
,
rotation_range
)
image
=
Image
.
new
(
"
L
"
,
self
.
font
.
getsize
(
drawn
),
self
.
bgcolor
)
bbox
=
self
.
font
.
getbbox
(
drawn
)
image
=
Image
.
new
(
"
L
"
,
self
.
get_size
(
drawn
,
(
2
,
2
)),
self
.
bgcolor
)
draw
=
ImageDraw
.
Draw
(
image
)
draw
.
text
((
0
,
0
),
drawn
,
font
=
self
.
font
,
fill
=
self
.
fgcolor
)
return
image
.
rotate
(
rotation
,
expand
=
0
,
resample
=
Image
.
BICUBIC
)
\
.
crop
(
image
.
getbbox
())
return
image
.
rotate
(
rotation
,
expand
=
True
,
fillcolor
=
self
.
bgcolor
,
resample
=
Image
.
BICUBIC
)
def
make_text
(
self
,
text
,
**
kwargs
):
"""
Renders a text
"""
size
=
self
.
font
.
getsize
(
text
)
size
=
(
size
[
0
]
*
2
,
int
(
size
[
1
]
*
1.433
))
size
=
self
.
get_size
(
text
,
(
4
,
3
))
image
=
Image
.
new
(
"
RGB
"
,
size
,
self
.
bgcolor
)
xpos
=
2
for
char
in
text
:
charimage
=
self
.
make_char
(
char
)
image
.
paste
(
charimage
,
(
xpos
,
4
,
xpos
+
charimage
.
size
[
0
],
4
+
charimage
.
size
[
1
]))
xpos
=
xpos
+
2
+
charimage
.
size
[
0
]
return
image
.
crop
((
0
,
0
,
xpos
+
1
,
size
[
1
]))
return
image
def
make_image
(
self
,
challenge
):
pass
...
...
This diff is collapsed.
Click to expand it.
hiboo/models.py
+
16
−
18
View file @
fd3b7048
from
passlib
import
context
,
hash
from
flask
import
current_app
as
app
from
sqlalchemy
.ext
import
declarative
,
mutable
from
sqlalchemy.
orm.collections
import
attribute_mapped_collection
from
sqlalchemy
import
orm
,
types
,
schema
,
sql
from
sqlalchemy.
ext
import
mutable
from
flask_babel
import
lazy_gettext
as
_
from
hiboo
import
actions
import
flask_sqlalchemy
import
flask_babel
import
sqlalchemy
import
datetime
import
json
import
uuid
...
...
@@ -30,32 +28,32 @@ def log(category, value=None, comment=None, user=None, profile=None,
db
.
session
.
add
(
event
)
class
Base
(
flask_sqlalchemy
.
Model
):
class
Base
(
orm
.
DeclarativeBase
):
"""
Base class for all models
"""
metadata
=
sqlalchemy
.
schema
.
MetaData
(
metadata
=
schema
.
MetaData
(
naming_convention
=
{
"
fk
"
:
"
%(table_name)s_%(column_0_name)s_fkey
"
,
"
pk
"
:
"
%(table_name)s_pkey
"
}
)
@
declarative
.declared_attr
@
orm
.declared_attr
def
uuid
(
cls
):
return
s
qlal
chem
y
.
Column
(
sqlalchemy
.
String
(
36
),
primary_key
=
True
,
return
schem
a
.
Column
(
types
.
String
(
36
),
primary_key
=
True
,
default
=
lambda
:
str
(
uuid
.
uuid4
()))
@
declarative
.declared_attr
@
orm
.declared_attr
def
created_at
(
cls
):
return
s
qlal
chem
y
.
Column
(
sqlalchemy
.
DateTime
,
nullable
=
False
,
default
=
datetime
.
datetime
.
now
)
return
schem
a
.
Column
(
types
.
DateTime
,
nullable
=
False
,
default
=
datetime
.
datetime
.
now
)
@
declarative
.declared_attr
@
orm
.declared_attr
def
updated_at
(
cls
):
return
s
qlal
chem
y
.
Column
(
sqlalchemy
.
DateTime
,
nullable
=
True
,
onupdate
=
datetime
.
datetime
.
now
)
return
schem
a
.
Column
(
types
.
DateTime
,
nullable
=
True
,
onupdate
=
datetime
.
datetime
.
now
)
@
declarative
.declared_attr
@
orm
.declared_attr
def
comment
(
cls
):
return
s
qlal
chem
y
.
Column
(
sqlalchemy
.
String
(
255
),
nullable
=
True
)
return
schem
a
.
Column
(
types
.
String
(
255
),
nullable
=
True
)
db
=
flask_sqlalchemy
.
SQLAlchemy
(
model_class
=
Base
)
...
...
@@ -143,7 +141,7 @@ class User(db.Model):
.
filter
(
Profile
.
uuid
==
None
)
.
filter
(
cls
.
get_timeout
()
>
sqlalchemy
.
sql
.
func
.
coalesce
(
cls
.
updated_at
,
cls
.
created_at
)
sql
.
func
.
coalesce
(
cls
.
updated_at
,
cls
.
created_at
)
))
for
user
in
unused
.
all
():
print
(
"
Deleting user {}
"
.
format
(
user
.
username
))
...
...
@@ -173,7 +171,7 @@ class Auth(db.Model):
user_uuid
=
db
.
Column
(
db
.
String
(
36
),
db
.
ForeignKey
(
User
.
uuid
))
user
=
db
.
relationship
(
User
,
backref
=
db
.
backref
(
'
auths
'
,
collection_class
=
attribute_mapped_collection
(
'
realm
'
),
collection_class
=
orm
.
attribute_mapped_collection
(
'
realm
'
),
cascade
=
'
all, delete-orphan
'
))
value
=
db
.
Column
(
db
.
String
)
extra
=
db
.
Column
(
mutable
.
MutableDict
.
as_mutable
(
JSONEncoded
))
...
...
@@ -320,9 +318,9 @@ class Profile(db.Model):
@classmethod
def
transition_ready
(
cls
):
return
cls
.
query
.
filter
(
sql
alchemy
.
or_
(
return
cls
.
query
.
filter
(
sql
.
expression
.
or_
(
cls
.
transition_step
.
in_
([
cls
.
START
,
cls
.
DONE
]),
sql
alchemy
.
and_
(
sql
.
expression
.
and_
(
cls
.
transition_step
==
cls
.
INIT
,
datetime
.
datetime
.
now
()
>
cls
.
transition_time
)
...
...
This diff is collapsed.
Click to expand it.
hiboo/utils.py
+
1
−
3
View file @
fd3b7048
...
...
@@ -81,15 +81,13 @@ limiter = flask_limiter.Limiter(key_func=lambda: current_user.id)
# Application translation
translation
=
flask_babel
.
Babel
()
@translation.localeselector
def
get_locale
():
return
babel
.
negotiate_locale
(
[
l
.
replace
(
'
-
'
,
'
_
'
)
for
l
in
flask
.
request
.
accept_languages
.
values
()],
list
(
map
(
str
,
translation
.
list_translations
()))
)
translation
=
flask_babel
.
Babel
(
locale_selector
=
get_locale
)
# Data migrate
migrate
=
flask_migrate
.
Migrate
()
...
...
This diff is collapsed.
Click to expand it.
poetry.lock
+
912
−
831
View file @
fd3b7048
Source diff could not be displayed: it is too large. Options to address this:
view the blob
.
This diff is collapsed.
Click to expand it.
pyproject.toml
+
18
−
18
View file @
fd3b7048
...
...
@@ -27,31 +27,31 @@ authors = [
[tool.poetry.dependencies]
python
=
"^3.9"
Flask
=
"^
2.2.3
"
Flask
=
"^
3.0.1
"
Flask-Login
=
"^0.6.2"
Flask-SQLAlchemy
=
"^
2.5
.1"
flask-babel
=
"^
2
.0.0"
Flask-Migrate
=
"^
3.1.0
"
Flask-WTF
=
"^1.
1
.1"
Flask-Limiter
=
"^
2
.5.0"
Flask-SQLAlchemy
=
"^
3.1
.1"
flask-babel
=
"^
4
.0.0"
Flask-Migrate
=
"^
4.0.5
"
Flask-WTF
=
"^1.
2
.1"
Flask-Limiter
=
"^
3
.5.0"
flask-redis
=
"^0.4.0"
Flask-DebugToolbar
=
"^0.1
3
.1"
SQLAlchemy
=
"^
1.4.0
"
Flask-DebugToolbar
=
"^0.1
4
.1"
SQLAlchemy
=
"^
2.0.25
"
WTForms-Components
=
"^0.10.5"
passlib
=
"^1.7.4"
PyYAML
=
"^6.0"
bcrypt
=
"^
3.2
.2"
pysaml2
=
"^7.
4.1
"
PyYAML
=
"^6.0
.1
"
bcrypt
=
"^
4.1
.2"
pysaml2
=
"^7.
5.0
"
xmlsec
=
"^1.3.13"
cryptography
=
"^
37
.0.
4
"
Authlib
=
"^1.
2
.0"
cryptography
=
"^
42
.0.
2
"
Authlib
=
"^1.
3
.0"
terminaltables
=
"^3.1.10"
Werkzeug
=
"^
2.2.3
"
email-validator
=
"^
1.3.
1"
pyotp
=
"^2.
8
.0"
Werkzeug
=
"^
3.0.1
"
email-validator
=
"^
2.1.0.post
1"
pyotp
=
"^2.
9
.0"
qrcode
=
"^7.4.2"
jwcrypto
=
"^1.
4.2
"
Pillow
=
"^
9.5
.0"
jwcrypto
=
"^1.
5.1
"
Pillow
=
"^
10.2
.0"
[tool.poetry.group.dev]
optional
=
true
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment