Skip to content

Commit

Permalink
Merge pull request #1706 from posit-dev/mm-remove-unused-account-prov…
Browse files Browse the repository at this point in the history
…iders

Remove legacy account handlers and associated auth types
  • Loading branch information
mmarchetti authored May 24, 2024
2 parents a6cd872 + f6784ed commit b18c5a5
Show file tree
Hide file tree
Showing 10 changed files with 4 additions and 1,203 deletions.
7 changes: 0 additions & 7 deletions internal/accounts/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,11 @@ type Account struct {
Certificate string `json:"-"` // Root CA certificate, if server cert is signed by a private CA
AccountName string `json:"account_name"` // Username, if known
ApiKey string `json:"-"` // For Connect servers
Token string `json:"-"` // If IDE token auth is being used (requires secret or private key)
Secret string `json:"-"` // token auth for Connect
PrivateKey string `json:"-"` // token auth for shinyapps.io and Posit Cloud
}

func (acct *Account) InferAuthType() AccountAuthType {
if acct.ApiKey != "" {
return AuthTypeAPIKey
} else if acct.Token != "" && acct.Secret != "" {
return AuthTypeTokenSecret
} else if acct.Token != "" && acct.PrivateKey != "" {
return AuthTypeTokenKey
}
return AuthTypeNone
}
12 changes: 4 additions & 8 deletions internal/accounts/account_auth_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,13 @@ package accounts
type AccountAuthType string

const (
AuthTypeNone AccountAuthType = "none" // No saved credentials
AuthTypeAPIKey AccountAuthType = "api-key" // Connect API key
AuthTypeTokenKey AccountAuthType = "token-key" // rsconnect token & private key (Connect)
AuthTypeTokenSecret AccountAuthType = "token-secret" // rsconnect token & secret (Cloud, shinyapps.io)
AuthTypeNone AccountAuthType = "none" // No saved credentials
AuthTypeAPIKey AccountAuthType = "api-key" // Connect API key
)

var authTypeDescriptions = map[AccountAuthType]string{
AuthTypeNone: "No saved credentials",
AuthTypeAPIKey: "Connect API key",
AuthTypeTokenKey: "RStudio IDE/rsconnect token+key",
AuthTypeTokenSecret: "RStudio IDE/rsconnect token+secret",
AuthTypeNone: "No saved credentials",
AuthTypeAPIKey: "Connect API key",
}

func (auth AccountAuthType) Description() string {
Expand Down
2 changes: 0 additions & 2 deletions internal/accounts/account_auth_type_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,5 @@ func TestAccountAuthTypeSuite(t *testing.T) {
func (s *AccountAuthTypeSuite) TestDescription() {
s.Equal("No saved credentials", AuthTypeNone.Description())
s.Equal("Connect API key", AuthTypeAPIKey.Description())
s.Equal("RStudio IDE/rsconnect token+key", AuthTypeTokenKey.Description())
s.Equal("RStudio IDE/rsconnect token+secret", AuthTypeTokenSecret.Description())
s.Equal("hey", AccountAuthType("hey").Description())
}
18 changes: 0 additions & 18 deletions internal/accounts/account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,3 @@ func (s *AccountSuite) TestInferAuthTypeApiKey() {
auth := account.InferAuthType()
s.Equal(AuthTypeAPIKey, auth)
}

func (s *AccountSuite) TestInferAuthTypeTokenSecret() {
account := Account{
Token: "abc",
Secret: "def",
}
auth := account.InferAuthType()
s.Equal(AuthTypeTokenSecret, auth)
}

func (s *AccountSuite) TestInferAuthTypeTokenKey() {
account := Account{
Token: "abc",
PrivateKey: "def",
}
auth := account.InferAuthType()
s.Equal(AuthTypeTokenKey, auth)
}
205 changes: 0 additions & 205 deletions internal/accounts/provider_rsconnect.go

This file was deleted.

Loading

0 comments on commit b18c5a5

Please sign in to comment.