-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[App] Introduce basic auth to Lightning CLI #16105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 22 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
b7a3692
Introduce basic auth to Lightning CLI for app creation
dmitsf cd42ca7
Parsing creds added
dmitsf d58c12f
Parsing creds added
dmitsf 2a62293
Parsing creds added
dmitsf 2130071
Adding auth field to app instance body
dmitsf 3074ae9
Adding tests
dmitsf 0c0755e
Merge branch 'master' into ENG-2309-basic-auth-for-ozgurs-app
dmitsf f7c5fcd
Merge branch 'master' into ENG-2309-basic-auth-for-ozgurs-app
dmitsf 9908192
Adding tests
dmitsf 9cfbf2a
Adding changelog entry
dmitsf 9b3ce7f
Adding more tests
dmitsf 1dcf10f
Adding more tests
dmitsf 876f59d
Merge branch 'master' into ENG-2309-basic-auth-for-ozgurs-app
dmitsf 3d5c53b
Update runtime.py
dmitsf 209a798
Setting auth on update
dmitsf d542049
Merge branch 'master' into ENG-2309-basic-auth-for-ozgurs-app
Borda 6ba205f
Merge branch 'master' into ENG-2309-basic-auth-for-ozgurs-app
dmitsf 1d9df59
Fix test
dmitsf e45f9ae
Fix test
dmitsf 569963e
Merge branch 'master' into ENG-2309-basic-auth-for-ozgurs-app
dmitsf 3f7c95b
Update lightning-cloud dep
dmitsf af8c702
Apply suggestions from code review
Borda 88c125c
Update runtime.py
dmitsf 01d36e5
Merge branch 'master' into ENG-2309-basic-auth-for-ozgurs-app
dmitsf 27697d5
Fix for release
dmitsf 4776206
Update base.txt
dmitsf 24d391d
Merge branch 'master' into ENG-2309-basic-auth-for-ozgurs-app
dmitsf ff4ffe3
Merge branch 'master' into ENG-2309-basic-auth-for-ozgurs-app
dmitsf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from typing import Dict | ||
|
||
|
||
def _credential_string_to_basic_auth_params(credential_string: str) -> Dict[str, str]: | ||
"""Returns the name/ID pair for each given Secret name. | ||
|
||
Raises a `ValueError` if any of the given Secret names do not exist. | ||
""" | ||
if credential_string.count(":") != 1: | ||
raise ValueError( | ||
"Credential string must follow the format username:password; " | ||
+ f"the provided one ('{credential_string}') does not." | ||
) | ||
|
||
username, password = credential_string.split(":") | ||
|
||
if not username: | ||
raise ValueError("Username cannot be empty.") | ||
|
||
if not password: | ||
raise ValueError("Password cannot be empty.") | ||
|
||
return {"username": username, "password": password} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from typing import Dict | ||
|
||
import pytest | ||
|
||
from lightning_app.utilities.auth import _credential_string_to_basic_auth_params | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"credential_string, expected_parsed, exception_message", | ||
[ | ||
("", None, "Credential string must follow the format username:password; the provided one ('') does not."), | ||
(":", None, "Username cannot be empty."), | ||
(":pass", None, "Username cannot be empty."), | ||
("user:", None, "Password cannot be empty."), | ||
("user:pass", {"username": "user", "password": "pass"}, ""), | ||
], | ||
) | ||
def test__credential_string_to_basic_auth_params( | ||
credential_string: str, expected_parsed: Dict[str, str], exception_message: str | ||
): | ||
if expected_parsed is not None: | ||
assert _credential_string_to_basic_auth_params(credential_string) == expected_parsed | ||
else: | ||
with pytest.raises(ValueError) as exception: | ||
_credential_string_to_basic_auth_params(credential_string) | ||
assert exception_message == str(exception.value) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.