fix lint
This commit is contained in:
parent
3138ddab5f
commit
c647d8b008
2 changed files with 16 additions and 6 deletions
|
|
@ -15,8 +15,8 @@ import (
|
|||
|
||||
type authClient struct {
|
||||
Config struct {
|
||||
TenantId string `long:"challenger-azdevicecode-tenantid" description:"Azure AD tenant id" env:"SSHPIPERD_CHALLENGER_AZDEVICECODE_TENANTID" ini-name:"challenger-azdevicecode-tenantid"`
|
||||
ClientId string `long:"challenger-azdevicecode-clientid" description:"Azure AD client id" env:"SSHPIPERD_CHALLENGER_AZDEVICECODE_CLIENTID" ini-name:"challenger-azdevicecode-clientid"`
|
||||
TenantID string `long:"challenger-azdevicecode-tenantid" description:"Azure AD tenant id" env:"SSHPIPERD_CHALLENGER_AZDEVICECODE_TENANTID" ini-name:"challenger-azdevicecode-tenantid"`
|
||||
ClientID string `long:"challenger-azdevicecode-clientid" description:"Azure AD client id" env:"SSHPIPERD_CHALLENGER_AZDEVICECODE_CLIENTID" ini-name:"challenger-azdevicecode-clientid"`
|
||||
Env string `long:"challenger-azdevicecode-env" default:"AzurePublicCloud" description:"Azure AD Cloud to request" env:"SSHPIPERD_CHALLENGER_AZDEVICECODE_ENV" ini-name:"challenger-azdevicecode-env" choice:"AzureChinaCloud" choice:"AzureGermanCloud" choice:"AzurePublicCloud" choice:"AzureUSGovernmentCloud"`
|
||||
Resource string `long:"challenger-azdevicecode-resource" default:"https://graph.windows.net/" description:"Resource URI to access, default is Graph API" env:"SSHPIPERD_CHALLENGER_AZDEVICECODE_RESOURCE" ini-name:"challenger-azdevicecode-resource"`
|
||||
NoReadGraph bool `long:"challenger-azdevicecode-noreadgraph" description:"disable query user info from user graph" env:"SSHPIPERD_CHALLENGER_AZDEVICECODE_NOREADGRAPH" ini-name:"challenger-azdevicecode-noreadgraph"`
|
||||
|
|
@ -34,7 +34,7 @@ func (c *authClient) Init(logger *log.Logger) error {
|
|||
return err
|
||||
}
|
||||
|
||||
oauthConfig, err := adal.NewOAuthConfig(env.ActiveDirectoryEndpoint, c.Config.TenantId)
|
||||
oauthConfig, err := adal.NewOAuthConfig(env.ActiveDirectoryEndpoint, c.Config.TenantID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -62,7 +62,7 @@ func (a *aadUser) ChallengedUsername() string {
|
|||
|
||||
func (c *authClient) challenge(conn ssh.ConnMetadata, client ssh.KeyboardInteractiveChallenge) (ssh.AdditionalChallengeContext, error) {
|
||||
oauthClient := &http.Client{}
|
||||
deviceCode, err := adal.InitiateDeviceAuth(oauthClient, c.oauthConfig, c.Config.ClientId, c.Config.Resource)
|
||||
deviceCode, err := adal.InitiateDeviceAuth(oauthClient, c.oauthConfig, c.Config.ClientID, c.Config.Resource)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
@ -83,12 +83,12 @@ func (c *authClient) challenge(conn ssh.ConnMetadata, client ssh.KeyboardInterac
|
|||
return nil, nil
|
||||
}
|
||||
|
||||
spt, err := adal.NewServicePrincipalTokenFromManualToken(c.oauthConfig, c.Config.ClientId, c.Config.Resource, *token)
|
||||
spt, err := adal.NewServicePrincipalTokenFromManualToken(c.oauthConfig, c.Config.ClientID, c.Config.Resource, *token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
signedInUserClient := graphrbac.NewSignedInUserClient(c.Config.TenantId)
|
||||
signedInUserClient := graphrbac.NewSignedInUserClient(c.Config.TenantID)
|
||||
signedInUserClient.Authorizer = autorest.NewBearerAuthorizer(spt)
|
||||
|
||||
result, err := signedInUserClient.Get(context.TODO())
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import (
|
|||
// e.g. map downstream public key to another upstream private key
|
||||
type Handler func(conn ssh.ConnMetadata, challengeContext ssh.AdditionalChallengeContext) (net.Conn, *ssh.AuthPipe, error)
|
||||
|
||||
// Options for creating a pipe to upstream
|
||||
type CreatePipeOption struct {
|
||||
Username string
|
||||
UpstreamUsername string
|
||||
|
|
@ -23,6 +24,8 @@ type CreatePipeOption struct {
|
|||
Port int
|
||||
}
|
||||
|
||||
// A pipe is a connection which linked downstream and upstream
|
||||
// SSHPiper searches pipe base on username
|
||||
type Pipe struct {
|
||||
Username string
|
||||
UpstreamUsername string
|
||||
|
|
@ -30,11 +33,17 @@ type Pipe struct {
|
|||
Port int
|
||||
}
|
||||
|
||||
|
||||
// Manage pipe inside upstream
|
||||
type PipeManager interface {
|
||||
|
||||
// Return All pipes inside upstream
|
||||
ListPipe() ([]Pipe, error)
|
||||
|
||||
// Create a pipe inside upstream
|
||||
CreatePipe(opt CreatePipeOption) error
|
||||
|
||||
// Remove a pipe from upstream
|
||||
RemovePipe(name string) error
|
||||
}
|
||||
|
||||
|
|
@ -70,6 +79,7 @@ func Get(name string) Provider {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Modified version of net.SplitHostPort but return port 22 is no port is specified
|
||||
func SplitHostPortForSSH(addr string) (host string, port int, err error) {
|
||||
host = addr
|
||||
h, p, err := net.SplitHostPort(host)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue