Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TDDDE27_2024_WEB_PROJECT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
TDDD27_MYPET
TDDDE27_2024_WEB_PROJECT
Commits
a0a5786a
Commit
a0a5786a
authored
1 year ago
by
danielmyren
Browse files
Options
Downloads
Patches
Plain Diff
minor changes, it's possible to start the server
parent
f2a292e7
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
.gitignore
+2
-1
2 additions, 1 deletion
.gitignore
backend/__init__.py
+20
-8
20 additions, 8 deletions
backend/__init__.py
backend/auth.py
+2
-2
2 additions, 2 deletions
backend/auth.py
backend/requirements.txt
+1
-0
1 addition, 0 deletions
backend/requirements.txt
with
25 additions
and
11 deletions
.gitignore
+
2
−
1
View file @
a0a5786a
.DS_Store
/backend/venv
\ No newline at end of file
/backend/venv
/backend/__pycache__/
\ No newline at end of file
This diff is collapsed.
Click to expand it.
backend/__init__.py
+
20
−
8
View file @
a0a5786a
import
os
from
flask
import
Flask
from
flask_sqlalchemy
import
SQLAlchemy
from
flask_security
import
Security
,
SQLAlchemyUserDatastore
,
auth_required
,
hash_password
from
flask_security.models
import
fsqla_v3
as
fsqla
from
flask_login
import
LoginManager
def
create_app
():
app
=
app
=
Flask
(
__name__
)
...
...
@@ -13,10 +15,10 @@ def create_app():
# Standard Configurations:
# Register models
from
.
server
import
default
as
default_blueprint
from
server
import
default
as
default_blueprint
app
.
register_blueprint
(
default_blueprint
)
from
.
auth
import
auth
as
auth_blueprint
from
auth
import
auth
as
auth_blueprint
app
.
register_blueprint
(
auth_blueprint
)
...
...
@@ -26,15 +28,14 @@ def create_app():
if
app
.
config
[
'
DEBUG
'
]:
# Generate a nice key using secrets.token_urlsafe()
# Add
app.config['SECRET_KEY'] = os.environ.get("SECRET_KEY",
TODO
)
app
.
config
[
'
SECRET_KEY
'
]
=
os
.
environ
.
get
(
"
SECRET_KEY
"
,
"
FaHW65b6vBDGlhazs-8JZHb4jiZvI_9jj6hcUa_EV1Q
"
)
# Bcrypt is set as default SECURITY_PASSWORD_HASH, which requires a salt
# Generate a good salt using: secrets.SystemRandom().getrandbits(128)
#
app.config['SECURITY_PASSWORD_SALT'] = os.environ.get("SECURITY_PASSWORD_SALT",
TODO
)
app
.
config
[
'
SECURITY_PASSWORD_SALT
'
]
=
os
.
environ
.
get
(
"
SECURITY_PASSWORD_SALT
"
,
"
327589938147555935984237744799432734422
"
)
# have session and remember cookie be samesite (flask/flask_login)
# app.config["REMEMBER_COOKIE_SAMESITE"] = "strict"
# app.config["SESSION_COOKIE_SAMESITE"] = "strict"
pass
app
.
config
[
"
REMEMBER_COOKIE_SAMESITE
"
]
=
"
strict
"
app
.
config
[
"
SESSION_COOKIE_SAMESITE
"
]
=
"
strict
"
else
:
# Secrets for the development environment are hard-coded.
# Secrets for production/deployment must be passed securely to the app.
...
...
@@ -57,10 +58,21 @@ def create_app():
class
User
(
db
.
Model
,
fsqla
.
FsUserMixin
):
pass
db
.
init_app
(
app
)
user_datastore
=
SQLAlchemyUserDatastore
(
db
,
User
,
Role
)
app
.
security
=
Security
(
app
,
user_datastore
)
return
app
,
db
if
__name__
==
'
__main__
'
:
app
,
db
=
create_app
()
with
app
.
app_context
():
# Create User to test with
db
.
create_all
()
if
not
app
.
security
.
datastore
.
find_user
(
email
=
"
test@me.com
"
):
app
.
security
.
datastore
.
create_user
(
email
=
"
test@me.com
"
,
password
=
hash_password
(
"
password
"
))
db
.
session
.
commit
()
app
.
run
()
\ No newline at end of file
This diff is collapsed.
Click to expand it.
backend/auth.py
+
2
−
2
View file @
a0a5786a
...
...
@@ -8,10 +8,10 @@ auth = Blueprint("auth", __name__)
def
login
():
pass
@auth.route
(
"
signup
"
)
@auth.route
(
"
/
signup
"
)
def
signup
():
pass
@auth.route
(
"
logout
"
)
@auth.route
(
"
/
logout
"
)
def
logout
():
pass
\ No newline at end of file
This diff is collapsed.
Click to expand it.
backend/requirements.txt
+
1
−
0
View file @
a0a5786a
...
...
@@ -20,6 +20,7 @@ itsdangerous==2.1.2
Jinja2==3.1.3
MarkupSafe==2.1.5
passlib==1.7.4
setuptools==69.5.1
six==1.16.0
SQLAlchemy==2.0.29
SQLAlchemy-Utils==0.41.2
...
...
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