Skip to content
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

Fix/device login #344

Merged
merged 12 commits into from
Mar 11, 2024
Merged

Fix/device login #344

merged 12 commits into from
Mar 11, 2024

Conversation

aaperis
Copy link
Contributor

@aaperis aaperis commented Feb 23, 2024

Related issue(s) and PR(s)
This PR closes #329.

Description

The reason why sda-cli login didnot seem to work is because it tried to connect to a /token that was behind a basic authentication method.

As a public app, sda-cli cannot leverage traditional methods to authenticate to the /token endpoint of LS-AAI.

  • To mitigate this issue, this PR adds to the device flow a PKCE flow so that the sda-cli can connect securely to LS-AAI token endpoints that do not require authentication through sending secrets.

  • Additionally, a mock-oidc server configured for device-flow and sda-auth configured only for serving the /info endpoint are added to the docker-compose.yml of the local dev environment for local testing. These additions can be the starting point for work in
    Add tests for cases when sda-cli calls the /info endpoint of sda-auth  #314
    and
    Add tests for login module #252.

  • along the way go was updated to 1.21 (crypt4gh v1.8.11 required this)

How to test
Configure an OIDC service with device flow enabled, token_authentication_method=none and PKCE enabled with method=S256.

OR locally:
under /testing folder run:

export TAG=v0.2.103 && docker compose --profile login up auth oidc --build --force-recreate

and from another terminal:

go build .
./sda-cli login http://localhost:8080

and after the login succeeds ls .sda-cli-session .

@aaperis aaperis requested a review from a team February 23, 2024 07:05
@aaperis aaperis marked this pull request as ready for review February 23, 2024 07:05
@aaperis aaperis self-assigned this Feb 26, 2024
pahatz
pahatz previously approved these changes Feb 27, 2024
Copy link
Contributor

@pahatz pahatz left a comment

Choose a reason for hiding this comment

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

Looks good!

pontus
pontus previously approved these changes Feb 29, 2024
jbygdell
jbygdell previously approved these changes Feb 29, 2024
Copy link
Contributor

@jbygdell jbygdell left a comment

Choose a reason for hiding this comment

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

Looks reasonable, some comments and questions though.

@aaperis aaperis dismissed stale reviews from jbygdell and pontus via 6b2ce15 March 3, 2024 13:55
@codecov-commenter
Copy link

codecov-commenter commented Mar 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 52.66%. Comparing base (8ebbad2) to head (e7a1214).

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #344   +/-   ##
=======================================
  Coverage   52.66%   52.66%           
=======================================
  Files           9        9           
  Lines        1183     1183           
=======================================
  Hits          623      623           
  Misses        481      481           
  Partials       79       79           
Flag Coverage Δ
unittests 52.66% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@nanjiangshu nanjiangshu left a comment

Choose a reason for hiding this comment

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

It works great when I tested locally with the instructions provided!
I have one minor comment though
When the URL has a trailing character /, which may happen when a user copies the URL from the address bar, the error message reported is not meaningful. For example,
running the command

./sda-cli login https://login.test.bp.nbis.se/

will return
Error: invalid character 'N' looking for beginning of value

One can either sanitize the trailing / from the URL or provide a more understandable error message.

MalinAhlberg
MalinAhlberg previously approved these changes Mar 5, 2024
Copy link
Member

@MalinAhlberg MalinAhlberg left a comment

Choose a reason for hiding this comment

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

Looks good!
I left one minor question/comment. Also, I needed to run go mod tidy before being able to run go build.

Copy link
Contributor

@kostas-kou kostas-kou left a comment

Choose a reason for hiding this comment

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

I agree with Malin's comment. Easier to debug when one is logging their own error messages as well

kostas-kou
kostas-kou previously approved these changes Mar 7, 2024
pontus
pontus previously approved these changes Mar 7, 2024
Copy link
Contributor

@pontus pontus left a comment

Choose a reason for hiding this comment

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

(see comments, but I don't object to merging.)

@aaperis aaperis dismissed stale reviews from pontus, kostas-kou, and MalinAhlberg via 119ea2f March 7, 2024 16:19
@aaperis aaperis closed this Mar 7, 2024
@aaperis aaperis reopened this Mar 7, 2024
@aaperis
Copy link
Contributor Author

aaperis commented Mar 7, 2024

It works great when I tested locally with the instructions provided! I have one minor comment though When the URL has a trailing character /, which may happen when a user copies the URL from the address bar, the error message reported is not meaningful. For example, running the command

./sda-cli login https://login.test.bp.nbis.se/

will return Error: invalid character 'N' looking for beginning of value

One can either sanitize the trailing / from the URL or provide a more understandable error message.

fixed

@aaperis aaperis force-pushed the fix/device-login branch 2 times, most recently from 86db45b to e7a1214 Compare March 7, 2024 17:04
@aaperis
Copy link
Contributor Author

aaperis commented Mar 7, 2024

Apparently merge_queue expects two tests for golang 1.20 to finish but these are now run as 1.21 , It seems that I don't have enough access to modify the relevant repository settings, at least atm.

@aaperis aaperis force-pushed the fix/device-login branch 2 times, most recently from f5cfa55 to e064f4d Compare March 7, 2024 17:45
@aaperis aaperis added this pull request to the merge queue Mar 11, 2024
Merged via the queue into main with commit cffe538 Mar 11, 2024
6 checks passed
@aaperis aaperis deleted the fix/device-login branch March 11, 2024 15:54
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.

Client login with sda-cli
8 participants