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

RESTful API for authentication #12

Merged
merged 20 commits into from
Aug 30, 2024
Merged

RESTful API for authentication #12

merged 20 commits into from
Aug 30, 2024

Conversation

stevapple
Copy link
Contributor

@stevapple stevapple commented Aug 24, 2024

This PR adds a new RESTful API for authentication and authorization. It is meant to be stateless and allows for customizing multi-round challenges for required information. It provides a path for sshmux to be a completely generic MitM without wiring Vlab system logic.

Closes #6

@stevapple
Copy link
Contributor Author

stevapple commented Aug 24, 2024

@iBug @taoky Request for an early review & try-out. The new API is in parity of the legacy one, but some functionalities are implemented in a slightly different way.

@taoky
Copy link
Member

taoky commented Aug 24, 2024

It looks like when logger is disabled, it would trigger a panic:

Aug 24 19:29:00 web sshmux-pr12[3869518]: panic: runtime error: invalid memory address or nil pointer dereference
Aug 24 19:29:00 web sshmux-pr12[3869518]: [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x6d1f4f]
Aug 24 19:29:00 web sshmux-pr12[3869518]: goroutine 8 [running]:
Aug 24 19:29:00 web sshmux-pr12[3869518]: log/slog.(*Logger).clone(...)
Aug 24 19:29:00 web sshmux-pr12[3869518]:         log/slog/logger.go:117
Aug 24 19:29:00 web sshmux-pr12[3869518]: log/slog.(*Logger).With(0x0, {0xc000109f40, 0x3, 0x3})
Aug 24 19:29:00 web sshmux-pr12[3869518]:         log/slog/logger.go:131 +0x4f
Aug 24 19:29:00 web sshmux-pr12[3869518]: main.(*Server).handler(0xc00011a2c0, {0x80d198, 0xc000052108})
Aug 24 19:29:00 web sshmux-pr12[3869518]:         github.com/USTC-vlab/sshmux/sshmux.go:155 +0x325
Aug 24 19:29:00 web sshmux-pr12[3869518]: created by main.(*Server).serve in goroutine 7
Aug 24 19:29:00 web sshmux-pr12[3869518]:         github.com/USTC-vlab/sshmux/sshmux.go:136 +0x125

@stevapple
Copy link
Contributor Author

It looks like when logger is disabled, it would trigger a panic:

Aug 24 19:29:00 web sshmux-pr12[3869518]: panic: runtime error: invalid memory address or nil pointer dereference

Aug 24 19:29:00 web sshmux-pr12[3869518]: [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x6d1f4f]

Aug 24 19:29:00 web sshmux-pr12[3869518]: goroutine 8 [running]:

Aug 24 19:29:00 web sshmux-pr12[3869518]: log/slog.(*Logger).clone(...)

Aug 24 19:29:00 web sshmux-pr12[3869518]:         log/slog/logger.go:117

Aug 24 19:29:00 web sshmux-pr12[3869518]: log/slog.(*Logger).With(0x0, {0xc000109f40, 0x3, 0x3})

Aug 24 19:29:00 web sshmux-pr12[3869518]:         log/slog/logger.go:131 +0x4f

Aug 24 19:29:00 web sshmux-pr12[3869518]: main.(*Server).handler(0xc00011a2c0, {0x80d198, 0xc000052108})

Aug 24 19:29:00 web sshmux-pr12[3869518]:         github.com/USTC-vlab/sshmux/sshmux.go:155 +0x325

Aug 24 19:29:00 web sshmux-pr12[3869518]: created by main.(*Server).serve in goroutine 7

Aug 24 19:29:00 web sshmux-pr12[3869518]:         github.com/USTC-vlab/sshmux/sshmux.go:136 +0x125

Is this problem dedicated to this PR?

@taoky
Copy link
Member

taoky commented Aug 24, 2024

Is this problem dedicated to this PR?

I don't think so... I could try workaround it locally and continue testing.

@taoky
Copy link
Member

taoky commented Aug 24, 2024

Tested with a debug server and the legacy auth works as intended.

@stevapple stevapple force-pushed the new-auth branch 2 times, most recently from 9180d4b to 3f3faf9 Compare August 24, 2024 14:51
@stevapple
Copy link
Contributor Author

Have verified that API server is working🎉 Now the only left piece is documentation.

@stevapple stevapple force-pushed the new-auth branch 3 times, most recently from 8a43dba to c3ab411 Compare August 26, 2024 19:21
@stevapple stevapple force-pushed the new-auth branch 2 times, most recently from 39c86b1 to e3536e7 Compare August 27, 2024 08:04
@stevapple stevapple changed the title New auth API RESTful API for authentication Aug 27, 2024
@stevapple stevapple marked this pull request as ready for review August 27, 2024 09:00
README.md Show resolved Hide resolved
@stevapple
Copy link
Contributor Author

Have you tested the V1 API against Vlab infrastructure? @taoky @iBug

@taoky
Copy link
Member

taoky commented Aug 28, 2024

Have you tested the V1 API against Vlab infrastructure? @taoky @iBug

Not yet, I would do that later today.

@taoky
Copy link
Member

taoky commented Aug 28, 2024

How does current v1 API handles recovery usernames? @stevapple

@stevapple
Copy link
Contributor Author

How does current v1 API handles recovery usernames? @stevapple

Recovery is handled by the API server (it returns recovery upstream information if it should). You can refer to legacy_auth.go, which is a compatibility layer for legacy API to v1.

@taoky
Copy link
Member

taoky commented Aug 28, 2024

I have implemented a v1 auth API server on vlab debug server and it also works as intended.

Copy link
Member

@iBug iBug left a comment

Choose a reason for hiding this comment

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

Apart from these minor issues, actually amazing work you've done!

README.md Outdated Show resolved Hide resolved
sshmux.go Outdated Show resolved Hide resolved
@stevapple stevapple requested a review from iBug August 28, 2024 16:35
@stevapple stevapple force-pushed the new-auth branch 2 times, most recently from b2e754b to 689e1c1 Compare August 28, 2024 16:58
@stevapple
Copy link
Contributor Author

stevapple commented Aug 28, 2024

If possible, I wish the PR can be merged as a single squash commit — despite that the commit history is clear, some of them doesn't make sense by themselves alone.

If you think it is too big, I can cherry-pick some commits as separate PRs to make it more dedicated.

@stevapple stevapple force-pushed the new-auth branch 2 times, most recently from 9f56f4a to 03f36b0 Compare August 28, 2024 17:34
@stevapple
Copy link
Contributor Author

Ping @iBug

@iBug iBug merged commit ad2cc3e into USTC-vlab:master Aug 30, 2024
2 checks passed
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.

Move authentication process into API server
3 participants