Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
uffd-nginxauth
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
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
uffd
uffd-nginxauth
Commits
e54bc82e
Verified
Commit
e54bc82e
authored
4 years ago
by
nd
Browse files
Options
Downloads
Patches
Plain Diff
add support for a session timeout
parent
05579748
No related branches found
No related tags found
No related merge requests found
Pipeline
#6115
failed
4 years ago
Stage: test
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
app.py
+9
-1
9 additions, 1 deletion
app.py
default_config.py
+1
-0
1 addition, 0 deletions
default_config.py
with
10 additions
and
1 deletion
app.py
+
9
−
1
View file @
e54bc82e
...
@@ -16,9 +16,16 @@ def create_app(test_config=None):
...
@@ -16,9 +16,16 @@ def create_app(test_config=None):
# oauthlib enforces the OAuth2.0 requirement to use HTTPS, when this is not set
# oauthlib enforces the OAuth2.0 requirement to use HTTPS, when this is not set
os
.
environ
[
'
OAUTHLIB_INSECURE_TRANSPORT
'
]
=
'
1
'
# That behaviour sucks, so disable it
os
.
environ
[
'
OAUTHLIB_INSECURE_TRANSPORT
'
]
=
'
1
'
# That behaviour sucks, so disable it
def
session_valid
():
if
not
session
.
get
(
'
user_id
'
):
return
False
if
datetime
.
datetime
.
now
().
timestamp
()
>
session
[
'
logintime
'
]
+
current_app
.
config
[
'
SESSION_LIFETIME_SECONDS
'
]:
return
False
return
True
@app.route
(
"
/auth
"
)
@app.route
(
"
/auth
"
)
def
auth
():
def
auth
():
if
not
session
.
get
(
'
user_
id
'
):
if
not
session
_val
id
(
):
abort
(
401
)
abort
(
401
)
resp
=
Response
(
'
Ok
'
,
200
)
resp
=
Response
(
'
Ok
'
,
200
)
resp
.
headers
[
'
OAUTH-USER-ID
'
]
=
session
[
'
user_id
'
]
resp
.
headers
[
'
OAUTH-USER-ID
'
]
=
session
[
'
user_id
'
]
...
@@ -38,6 +45,7 @@ def create_app(test_config=None):
...
@@ -38,6 +45,7 @@ def create_app(test_config=None):
client
=
get_oauth
()
client
=
get_oauth
()
url
,
state
=
client
.
authorization_url
(
app
.
config
[
'
OAUTH2_AUTH_URL
'
])
url
,
state
=
client
.
authorization_url
(
app
.
config
[
'
OAUTH2_AUTH_URL
'
])
session
[
'
state
'
]
=
state
session
[
'
state
'
]
=
state
session
[
'
logintime
'
]
=
datetime
.
datetime
.
now
().
timestamp
()
parts
=
request
.
full_path
.
split
(
'
?rawurl=
'
,
1
)
parts
=
request
.
full_path
.
split
(
'
?rawurl=
'
,
1
)
if
len
(
parts
)
==
2
:
if
len
(
parts
)
==
2
:
session
[
'
url
'
]
=
parts
[
1
]
session
[
'
url
'
]
=
parts
[
1
]
...
...
This diff is collapsed.
Click to expand it.
default_config.py
+
1
−
0
View file @
e54bc82e
...
@@ -12,3 +12,4 @@ OAUTH2_USERINFO_URL = 'http://localhost:5001/oauth2/userinfo'
...
@@ -12,3 +12,4 @@ OAUTH2_USERINFO_URL = 'http://localhost:5001/oauth2/userinfo'
SESSION_COOKIE_SECURE
=
True
SESSION_COOKIE_SECURE
=
True
SESSION_COOKIE_HTTPONLY
=
True
SESSION_COOKIE_HTTPONLY
=
True
SESSION_COOKIE_SAMESITE
=
'
Strict
'
SESSION_COOKIE_SAMESITE
=
'
Strict
'
SESSION_LIFETIME_SECONDS
=
3600
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