Skip to content

Commit

Permalink
Simplify API
Browse files Browse the repository at this point in the history
  • Loading branch information
stevapple committed Aug 16, 2024
1 parent b0ee126 commit 928eb12
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 12 deletions.
2 changes: 1 addition & 1 deletion auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (auth Authenticator) AuthUser(request any, username string) (*UpstreamInfor
var upstream UpstreamInformation
// FIXME: Can this be handled in API server?
if slices.Contains(auth.Recovery.Usernames, username) {
upstream.Host = auth.Recovery.Server
upstream.Host = auth.Recovery.Address
password := fmt.Sprintf("%d %s", response.Id, auth.Recovery.Token)
upstream.Password = &password
} else {
Expand Down
8 changes: 2 additions & 6 deletions config.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
package main

type ServerConfig struct {
Address string `toml:"address"`
}

type SSHConfig struct {
Banner string `toml:"banner"`
HostKeys []string `toml:"host-keys"`
Expand All @@ -30,13 +26,13 @@ type ProxyProtocolConfig struct {
}

type RecoveryConfig struct {
Server string `toml:"server"`
Address string `toml:"address"`
Usernames []string `toml:"usernames"`
Token string `toml:"token"`
}

type Config struct {
Server ServerConfig `toml:"server"`
Address string `toml:"address"`
SSH SSHConfig `toml:"ssh"`
Auth AuthConfig `toml:"auth"`
Logger LoggerConfig `toml:"logger"`
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func sshmuxServer(configFile string) {
if err != nil {
log.Fatal(err)
}
sshmux.ListenAddr(config.Server.Address)
sshmux.ListenAddr(config.Address)
} else {
var legacyConfig LegacyConfig
configFileBytes, err := os.ReadFile(configFile)
Expand Down
6 changes: 2 additions & 4 deletions sshmux.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@ func makeLegacyServer(config LegacyConfig) (*Server, error) {
config.RecoveryToken = config.Token
}
return makeServer(Config{
Server: ServerConfig{
Address: config.Address,
},
Address: config.Address,
SSH: SSHConfig{
Banner: config.Banner,
HostKeys: config.HostKeys,
Expand All @@ -100,7 +98,7 @@ func makeLegacyServer(config LegacyConfig) (*Server, error) {
Networks: config.ProxyCIDRs,
},
Recovery: RecoveryConfig{
Server: config.RecoveryServer,
Address: config.RecoveryServer,
Usernames: config.RecoveryUsername,
Token: config.RecoveryToken,
},
Expand Down

0 comments on commit 928eb12

Please sign in to comment.