Skip to content

Conversation

@nathanthorpe
Copy link
Contributor

@nathanthorpe nathanthorpe commented Sep 12, 2022

  • Implements the device code authorization flow allowing federated users / MFAd users to sign in, doesn't need your username and password.
  • pubweb-cli configure now asks you what authorization method you want
  • Allow user to cache their auth so they don't have to re-log in (uses refresh token)
  • Saves token info encrypted using Data Protection API, Keychain, or LibSecret depending on what OS you have
  • Refactor configuration class and default auth method initialization
  • Add lock around the get_token method and reuse Request Auth Wrapper
  • Add client information in user-agent header to track versions

@nathanthorpe nathanthorpe linked an issue Sep 14, 2022 that may be closed by this pull request
@nathanthorpe nathanthorpe linked an issue Oct 21, 2022 that may be closed by this pull request
# Conflicts:
#	pubweb/__init__.py
#	pubweb/api/auth/iam.py
#	pubweb/api/auth/oauth_client.py
#	pubweb/api/auth/username.py
#	pubweb/api/clients/api.py
#	pubweb/api/clients/portal.py
#	pubweb/api/models/dataset.py
#	pubweb/api/models/file.py
#	pubweb/api/services/base.py
#	pubweb/api/services/file.py
#	pubweb/auth/__init__.py
#	pubweb/cli/controller.py
#	pubweb/models/project.py
#	setup.py
Copy link
Contributor

@sminot sminot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish I had more constructive things to add! From what little I can understand, it looks good to me.

class Constants:
home = os.environ.get('PW_HOME', '~/.pubweb')
config_path = Path(home, 'config.ini').expanduser()
default_base_url = "pubweb.cloud"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be configurable as an environment variable?

ini_config.read(str(Constants.config_path.absolute()))
main_config = ini_config['General']
auth_method = main_config.get('auth_method')
base_url = (os.environ.get('PW_BASE_URL') or
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see, it is configurable here. I suppose I expected it to follow the same pattern as PW_HOME but now I see it doesn't need to

self.auth_endpoint = f'https://api.{self.base_url}/auth'

try:
info_resp = requests.get(f'{self.rest_endpoint}/info/system')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a rest endpoint?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah but it only has like 2 functions

setup.py Outdated
"jsonschema>=4.6.1",
"s3fs==0.4.2",
"fsspec==2022.10.0"
"fsspec==2022.10.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I keep having a hard time installing the package. Do the versions all have to be so explicitly hardcoded?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok yeah I'll fix that

from pubweb.api.config import AuthConfig, save_config, load_config
from pubweb.file_utils import get_files_in_directory, check_dataset_files
from pubweb.file_utils import check_dataset_files
from pubweb.file_utils import get_files_in_directory
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was the reason for splitting these 2 imports apart?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no probably a merge artifact

@nathanthorpe nathanthorpe merged commit 5c87507 into main Nov 30, 2022
@nathanthorpe nathanthorpe deleted the device_code_flow branch November 30, 2022 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dynamic configuration based on a BASE URL property Allow authentication for federated users

4 participants