mirror of
https://github.com/tailscale/tailscale.git
synced 2025-04-20 13:41:41 +00:00
cmd/ssh-auth-none-demo: add banner as part of the demo
Send two banners with a second in between, this demonstrates the case where all banners are shown after auth completes and not during. Signed-off-by: Maisem Ali <maisem@tailscale.com>
This commit is contained in:
parent
718914b697
commit
7df85c6031
@ -62,10 +62,25 @@ func main() {
|
|||||||
Version: "Tailscale",
|
Version: "Tailscale",
|
||||||
Handler: handleSessionPostSSHAuth,
|
Handler: handleSessionPostSSHAuth,
|
||||||
ServerConfigCallback: func(ctx ssh.Context) *gossh.ServerConfig {
|
ServerConfigCallback: func(ctx ssh.Context) *gossh.ServerConfig {
|
||||||
|
start := time.Now()
|
||||||
return &gossh.ServerConfig{
|
return &gossh.ServerConfig{
|
||||||
ImplicitAuthMethod: "tailscale",
|
ImplicitAuthMethod: "tailscale",
|
||||||
NoClientAuth: true, // required for the NoClientAuthCallback to run
|
NoClientAuth: true, // required for the NoClientAuthCallback to run
|
||||||
NoClientAuthCallback: func(gossh.ConnMetadata) (*gossh.Permissions, error) {
|
NoClientAuthCallback: func(cm gossh.ConnMetadata) (*gossh.Permissions, error) {
|
||||||
|
cm.SendAuthBanner(fmt.Sprintf("# Banner: doing none auth at %v\r\n", time.Since(start)))
|
||||||
|
|
||||||
|
totalBanners := 2
|
||||||
|
if cm.User() == "banners" {
|
||||||
|
totalBanners = 5
|
||||||
|
}
|
||||||
|
for banner := 2; banner <= totalBanners; banner++ {
|
||||||
|
time.Sleep(time.Second)
|
||||||
|
if banner == totalBanners {
|
||||||
|
cm.SendAuthBanner(fmt.Sprintf("# Banner%d: access granted at %v\r\n", banner, time.Since(start)))
|
||||||
|
} else {
|
||||||
|
cm.SendAuthBanner(fmt.Sprintf("# Banner%d at %v\r\n", banner, time.Since(start)))
|
||||||
|
}
|
||||||
|
}
|
||||||
return nil, nil
|
return nil, nil
|
||||||
},
|
},
|
||||||
BannerCallback: func(cm gossh.ConnMetadata) string {
|
BannerCallback: func(cm gossh.ConnMetadata) string {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user