Page MenuHomeSoftware Heritage

Login: Add an option to choose an authentication method (by username/password or token)
Needs RevisionPublic

Authored by franckbret on Dec 1 2022, 11:05 AM.

Details

Reviewers
anlambert
Group Reviewers
Reviewers
Summary

Manage token based authentication
Ensure consistency of click styles
Fix "AttributeError: module 'click' has no attribute 'exit'" issue when
submitting bad login credentials.
Adapt dash imports to remove deprecated warnings

Related T4590

Diff Detail

Repository
rDTSCN Code scanner
Branch
impscan
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 33063
Build 51821: Phabricator diff pipeline on jenkinsJenkins console · Jenkins
Build 51820: arc lint + arc unit

Event Timeline

Build is green

Patch application report for D8909 (id=32110)

Rebasing onto 0f4f9d4f8e...

Current branch diff-target is up to date.
Changes applied before test
commit 5ee208707b9d98fe1dab386576805280aebd315a
Author: Franck Bret <franck.bret@octobus.net>
Date:   Thu Nov 24 14:59:25 2022 +0100

    Login: Add an option to choose an authentication method (by
    username/password or token)
    
    Manage token based authentication
    Ensure consistency of click styles
    Fix "AttributeError: module 'click' has no attribute 'exit'" issue when
    submitting bad login credentials.

commit 47353a7e8f64d9d8ae57927f57563a429c0ffc70
Author: Franck Bret <franck.bret@octobus.net>
Date:   Tue Nov 22 12:40:26 2022 +0100

    Adapt dash imports to remove deprecated warnings

See https://jenkins.softwareheritage.org/job/DTSCN/job/tests-on-diff/191/ for more details.

@anlambert Shouldn't this be replaced by swh auth generate-token?

Some screen capture of the differents scenario when login:

With username/password

WIth token

With bad credentials or bad token

@anlambert Shouldn't this be replaced by swh auth generate-token?

@anlambert @vlorentz seems legit that anything related to auth for a cli command should be centralized in swh auth.

I can adapt to :

  • make swh scanner depends on swh auth
  • alias swh scanner login to one of swh auth
  • add a set token command to swh auth

What do you think?

@anlambert Shouldn't this be replaced by swh auth generate-token?

@anlambert @vlorentz seems legit that anything related to auth for a cli command should be centralized in swh auth.

I can adapt to :

  • make swh scanner depends on swh auth
  • alias swh scanner login to one of swh auth
  • add a set token command to swh auth

What do you think?

@franckbret , sorry for the late reply.

I also think it is better to keep implementation related to login in swh-auth component to avoid duplicating code.
Two possible solutions here, either wrap login implementation in dedicated functions in swh-auth and call them
in swh-scanner commands or invoke swh-auth commands from swh-scanner ones.

Also +1 adding a set-token command in swh-auth to add bearer token in global config file.

This revision now requires changes to proceed.Dec 6 2022, 1:52 PM