Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
silkaj
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
clients
python
silkaj
Merge requests
!31
Typo pep8
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Typo pep8
typo_pep8
into
master
Overview
4
Commits
8
Pipelines
0
Changes
6
Merged
Moul
requested to merge
typo_pep8
into
master
8 years ago
Overview
4
Commits
8
Pipelines
0
Changes
6
Expand
0
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
551aa95b
8 commits,
7 years ago
6 files
+
211
−
144
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
6
Search (e.g. *.vue) (Ctrl+P)
src/auth.py
+
10
−
7
Options
@@ -2,6 +2,7 @@ from tools import *
import
getpass
import
os
def
auth_method
(
c
):
if
c
.
contains_switches
(
'
auth-scrypt
'
):
return
auth_by_scrypt
()
@@ -12,16 +13,18 @@ def auth_method(c):
print
(
"
Error: no authentication method
"
)
exit
()
def
generate_auth_file
(
c
):
if
c
.
contains_definitions
(
'
file
'
):
file
=
c
.
get_definition
(
'
file
'
)
else
:
file
=
"
authfile
"
seed
=
auth_method
(
c
)
with
open
(
file
,
"
w
"
)
as
f
:
with
open
(
file
,
"
w
"
)
as
f
:
f
.
write
(
seed
)
print
(
"
Authfile generated for the public key:
"
,
get_publickey_from_seed
(
seed
))
def
auth_by_auth_file
(
c
):
if
c
.
contains_definitions
(
'
file
'
):
file
=
c
.
get_definition
(
'
file
'
)
@@ -30,14 +33,15 @@ def auth_by_auth_file(c):
if
not
os
.
path
.
isfile
(
file
):
print
(
"
Error: the file
\"
"
+
file
+
"
\"
does not exist
"
)
exit
()
with
open
(
file
)
as
f
:
seed
=
f
.
read
()
with
open
(
file
)
as
f
:
seed
=
f
.
read
()
regex
=
re
.
compile
(
'
^[0-9a-fA-F]{64}$
'
)
if
not
re
.
search
(
regex
,
seed
):
print
(
"
Error: the format of the file is invalid
"
)
exit
()
return
seed
def
auth_by_seed
():
seed
=
input
(
"
Please enter your seed on hex format:
"
)
regex
=
re
.
compile
(
'
^[0-9a-fA-F]{64}$
'
)
@@ -50,15 +54,14 @@ def auth_by_seed():
def
auth_by_scrypt
():
salt
=
input
(
"
Please enter your Scrypt Salt (Secret identifier):
"
)
password
=
getpass
.
getpass
(
"
Please enter your Scrypt password (masked):
"
)
scrypt_param
=
input
(
"
Please enter your Scrypt parameters (N,r,p): [4096,16,1]
"
)
scrypt_param
=
input
(
"
Please enter your Scrypt parameters (N,r,p):
default
[4096,16,1]
:
"
)
if
not
scrypt_param
:
scrypt_param
=
"
4096,16,1
"
scrypt_param_splited
=
scrypt_param
.
split
(
"
,
"
)
scrypt_param_splited
=
scrypt_param
.
split
(
"
,
"
)
n
=
int
(
scrypt_param_splited
[
0
])
r
=
int
(
scrypt_param_splited
[
1
])
p
=
int
(
scrypt_param_splited
[
2
])
if
(
n
<=
0
or
n
>
65536
or
r
<=
0
or
r
>
512
or
p
<=
0
or
p
>
32
):
print
(
"
Error: the values of Scrypt parameters are not good
"
)
seed
=
get_seed_from_scrypt
(
salt
,
password
,
n
,
r
,
p
)
return
seed
return
get_seed_from_scrypt
(
salt
,
password
,
n
,
r
,
p
)
Loading