Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
sso
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
8
Issues
8
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
ai
sso
Commits
9882453c
Commit
9882453c
authored
May 03, 2014
by
ale
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
only ask for OTP if stdin is a tty
parent
49095906
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
2 deletions
+7
-2
src/python/sso/urllib2_handler.py
src/python/sso/urllib2_handler.py
+7
-2
No files found.
src/python/sso/urllib2_handler.py
View file @
9882453c
import
cookielib
import
getpass
import
os
import
urllib2
import
urllib
import
re
import
sys
class
SSOProcessor
(
urllib2
.
BaseHandler
):
...
...
@@ -40,8 +42,11 @@ class SSOProcessor(urllib2.BaseHandler):
self
.
_username
,
form_data
[
's'
].
rstrip
(
'/'
)))
form_data
[
'password'
]
=
self
.
_password
if
self
.
_otp_pattern
.
search
(
response_data
):
form_data
[
'otp'
]
=
raw_input
(
'OTP for %s@%s: '
%
(
self
.
_username
,
form_data
[
's'
].
rstrip
(
'/'
)))
# Only ask for an OTP when the standard input is a tty,
# otherwise simply don't send any OTP.
if
os
.
isatty
(
sys
.
stdin
):
form_data
[
'otp'
]
=
raw_input
(
'OTP for %s@%s: '
%
(
self
.
_username
,
form_data
[
's'
].
rstrip
(
'/'
)))
newreq
=
urllib2
.
Request
(
request_baseurl
,
data
=
urllib
.
urlencode
(
form_data
))
newreq
.
sso_attempt
=
True
...
...
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