Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
File Transfer Service
fts-rest
Commits
8d304c05
Commit
8d304c05
authored
Nov 15, 2016
by
Alejandro Alvarez Ayllon
Browse files
FTS-784
: Drop strftime, use more explicit types
parent
3852c84b
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/fts3rest/fts3rest/lib/middleware/fts3auth/methods/http.py
View file @
8d304c05
...
...
@@ -16,11 +16,10 @@
# limitations under the License.
import
re
import
time
import
dateutil.parser
import
calendar
import
logging
import
urllib
from
datetime
import
datetime
,
timedelta
from
M2Crypto.X509
import
X509Error
from
base64
import
b64decode
from
M2Crypto
import
X509
,
EVP
...
...
@@ -64,17 +63,18 @@ def do_authentication(credentials, env):
except
:
pass
ts
=
dateutil
.
parser
.
parse
(
cred
[
'ts'
])
.
strftime
(
'%s'
)
ts
=
dateutil
.
parser
.
parse
(
cred
[
'ts'
])
except
(
TypeError
,
ValueError
):
log
.
info
(
"Cannot decode certificate, signature or timestamp"
)
raise
InvalidCredentials
(
"Cannot decode certificate, signature or timestamp"
)
td
=
datetime
.
utcnow
()
-
ts
td
=
abs
(
int
(
calendar
.
timegm
(
time
.
gmtime
()))
-
int
(
ts
))
if
td
>
600
:
log
.
info
(
"Authorization has expired by "
+
str
(
td
)
+
" seconds"
)
raise
InvalidCredentials
(
"Authorization has expired by "
+
str
(
td
)
+
" seconds"
)
if
td
>
timedelta
(
seconds
=
600
):
msg
=
"Authorization has left %s"
%
td
log
.
info
(
msg
)
raise
InvalidCredentials
(
msg
)
if
proxy
:
try
:
x509
=
X509
.
load_cert_string
(
proxy
,
X509
.
FORMAT_DER
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment