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
Commits
865cda6f
Commit
865cda6f
authored
1 year ago
by
Moul
Browse files
Options
Downloads
Patches
Plain Diff
auth: import top-level click
parent
a4c6d7da
No related branches found
Branches containing commit
No related tags found
1 merge request
!240
Drop auth-file default path #420, Use click.prompt(), click_context testing
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
silkaj/auth.py
+12
-12
12 additions, 12 deletions
silkaj/auth.py
with
12 additions
and
12 deletions
silkaj/auth.py
+
12
−
12
View file @
865cda6f
...
...
@@ -18,7 +18,7 @@ import sys
from
getpass
import
getpass
from
pathlib
import
Path
from
click
import
Context
,
command
,
confirm
,
option
,
pass_context
import
click
from
duniterpy.key
import
SigningKey
from
duniterpy.key.scrypt_params
import
ScryptParams
...
...
@@ -30,8 +30,8 @@ PUBSEC_PUBKEY_PATTERN = f"pub: ({PUBKEY_PATTERN})"
PUBSEC_SIGNKEY_PATTERN
=
"
sec: ([1-9A-HJ-NP-Za-km-z]{87,90})
"
@pass_context
def
auth_method
(
ctx
:
Context
)
->
SigningKey
:
@
click.
pass_context
def
auth_method
(
ctx
:
click
.
Context
)
->
SigningKey
:
if
"
AUTH_SEED
"
in
ctx
.
obj
and
ctx
.
obj
[
"
AUTH_SEED
"
]:
return
auth_by_seed
()
if
"
AUTH_FILE
"
in
ctx
.
obj
and
ctx
.
obj
[
"
AUTH_FILE
"
]:
...
...
@@ -41,8 +41,8 @@ def auth_method(ctx: Context) -> SigningKey:
return
auth_by_scrypt
()
@pass_context
def
has_auth_method
(
ctx
:
Context
)
->
bool
:
@
click.
pass_context
def
has_auth_method
(
ctx
:
click
.
Context
)
->
bool
:
return
(
(
"
AUTH_SCRYPT
"
in
ctx
.
obj
and
ctx
.
obj
[
"
AUTH_SCRYPT
"
])
or
(
"
AUTH_FILE
"
in
ctx
.
obj
and
ctx
.
obj
[
"
AUTH_FILE
"
])
...
...
@@ -51,8 +51,8 @@ def has_auth_method(ctx: Context) -> bool:
)
@command
(
"
authentication
"
,
help
=
"
Generate authentication file
"
)
@option
(
"
--file
"
,
default
=
"
authfile
"
,
show_default
=
True
,
help
=
"
Path file
"
)
@
click.
command
(
"
authentication
"
,
help
=
"
Generate authentication file
"
)
@
click.
option
(
"
--file
"
,
default
=
"
authfile
"
,
show_default
=
True
,
help
=
"
Path file
"
)
def
generate_auth_file
(
file
:
str
)
->
None
:
key
=
auth_method
()
authfile
=
Path
(
file
)
...
...
@@ -60,7 +60,7 @@ def generate_auth_file(file: str) -> None:
if
authfile
.
is_file
():
message
=
f
"
Would you like to erase
{
file
}
by an authfile corresponding
\n\
to following pubkey `
{
pubkey_cksum
}
`?
"
confirm
(
message
,
abort
=
True
)
click
.
confirm
(
message
,
abort
=
True
)
key
.
save_seedhex_file
(
file
)
print
(
f
"
Authentication file
'
authfile
'
generated and stored in current
\
...
...
@@ -68,8 +68,8 @@ to following pubkey `{pubkey_cksum}`?"
)
@pass_context
def
auth_by_auth_file
(
ctx
:
Context
)
->
SigningKey
:
@
click.
pass_context
def
auth_by_auth_file
(
ctx
:
click
.
Context
)
->
SigningKey
:
"""
Uses an authentication file to generate the key
Authfile can either be:
...
...
@@ -106,8 +106,8 @@ def auth_by_seed() -> SigningKey:
sys
.
exit
(
FAILURE_EXIT_STATUS
)
@pass_context
def
auth_by_scrypt
(
ctx
:
Context
)
->
SigningKey
:
@
click.
pass_context
def
auth_by_scrypt
(
ctx
:
click
.
Context
)
->
SigningKey
:
salt
=
getpass
(
"
Please enter your Scrypt Salt (Secret identifier):
"
)
password
=
getpass
(
"
Please enter your Scrypt password (masked):
"
)
...
...
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