Skip to content

mito: allow use of Basic Authentication and OAuth2 in command#23

Merged
efd6 merged 2 commits intodevfrom
auth
May 4, 2023
Merged

mito: allow use of Basic Authentication and OAuth2 in command#23
efd6 merged 2 commits intodevfrom
auth

Conversation

@efd6
Copy link
Collaborator

@efd6 efd6 commented Apr 26, 2023

This allows use of the configuration options available in the Filebeat input to improve parity for development playground purposes. The implementation is simpler here and does not make use of the go-ucfg package, so there are some differences in config behaviour. Only limited validation of the config is performed.

Configuration is in the YAML exposed via the cfg option. The options available are similarly interpreted as the config in Filebeat with the options corresponding to the following structs:

type config struct {
	Globals map[string]interface{} `yaml:"globals"`
	Regexps map[string]string      `yaml:"regexp"`
	Auth    *authConfig            `yaml:"auth"`
}

type authConfig struct {
	Basic  *lib.BasicAuth `yaml:"basic"`
	OAuth2 *oAuth2        `yaml:"oauth2"`
}

type oAuth2 struct {
	Provider string `yaml:"provider"`

	ClientID       string     `yaml:"client.id"`
	ClientSecret   *string    `yaml:"client.secret"`
	EndpointParams url.Values `yaml:"endpoint_params"`
	Password       string     `yaml:"password"`
	Scopes         []string   `yaml:"scopes"`
	TokenURL       string     `yaml:"token_url"`
	User           string     `yaml:"user"`

	GoogleCredentialsFile  string `yaml:"google.credentials_file"`
	GoogleCredentialsJSON  string `yaml:"google.credentials_json"`
	GoogleJWTFile          string `yaml:"google.jwt_file"`
	GoogleJWTJSON          string `yaml:"google.jwt_json"`
	GoogleDelegatedAccount string `yaml:"google.delegated_account"`

	AzureTenantID string `yaml:"azure.tenant_id"`
	AzureResource string `yaml:"azure.resource"`
}

Please take a look.

@efd6 efd6 requested a review from a team April 26, 2023 05:49
@efd6 efd6 self-assigned this Apr 26, 2023
@efd6 efd6 added the Team:Security-External Integrations Label for the Security External Integrations team label Apr 26, 2023
Configuration is in the YAML exposed via the cfg option. The options
available are similarly interpreted as the config in Filebeat with the
options corresponding to the following structs:

type config struct {
	Globals map[string]interface{} `yaml:"globals"`
	Regexps map[string]string      `yaml:"regexp"`
	Auth    *authConfig            `yaml:"auth"`
}

type authConfig struct {
	Basic  *lib.BasicAuth `yaml:"basic"`
	OAuth2 *oAuth2        `yaml:"oauth2"`
}

type oAuth2 struct {
	Provider string `yaml:"provider"`

	ClientID       string     `yaml:"client.id"`
	ClientSecret   *string    `yaml:"client.secret"`
	EndpointParams url.Values `yaml:"endpoint_params"`
	Password       string     `yaml:"password"`
	Scopes         []string   `yaml:"scopes"`
	TokenURL       string     `yaml:"token_url"`
	User           string     `yaml:"user"`

	GoogleCredentialsFile  string `yaml:"google.credentials_file"`
	GoogleCredentialsJSON  string `yaml:"google.credentials_json"`
	GoogleJWTFile          string `yaml:"google.jwt_file"`
	GoogleJWTJSON          string `yaml:"google.jwt_json"`
	GoogleDelegatedAccount string `yaml:"google.delegated_account"`

	AzureTenantID string `yaml:"azure.tenant_id"`
	AzureResource string `yaml:"azure.resource"`
}
Copy link
Member

@andrewkroh andrewkroh left a comment

Choose a reason for hiding this comment

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

Consider adding a test case to check that basic auth is being passed though in requests.

@efd6
Copy link
Collaborator Author

efd6 commented May 3, 2023

That was a little tricky, but done. The OAuth2 case could also be tested, but will require significant additional complexity to be added to the test supports.

@efd6 efd6 requested a review from andrewkroh May 3, 2023 23:52
@efd6 efd6 force-pushed the auth branch 2 times, most recently from b68a6e4 to b7cba83 Compare May 4, 2023 03:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Team:Security-External Integrations Label for the Security External Integrations team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments