Skip to content

chore: implement yaml parsing for external auth configs #11268

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Dec 19, 2023

Conversation

Emyrk
Copy link
Member

@Emyrk Emyrk commented Dec 18, 2023

What this does

Allows user to configure external auths from a yaml file.

@Emyrk Emyrk marked this pull request as ready for review December 18, 2023 23:05
@Emyrk Emyrk changed the title chore: yaml parsing for external auth configs chore: implement yaml parsing for external auth configs Dec 18, 2023
@Emyrk Emyrk requested review from ammario and johnstcn December 19, 2023 15:32
Comment on lines +295 to +313
githubCfg := codersdk.ExternalAuthConfig{
Type: "github",
ClientID: "client_id",
ClientSecret: "client_secret",
ID: "id",
AuthURL: "https://example.com/auth",
TokenURL: "https://example.com/token",
ValidateURL: "https://example.com/validate",
AppInstallURL: "https://example.com/install",
AppInstallationsURL: "https://example.com/installations",
NoRefresh: true,
Scopes: []string{"user:email", "read:org"},
ExtraTokenKeys: []string{"extra", "token"},
DeviceFlow: true,
DeviceCodeURL: "https://example.com/device",
Regex: "^https://example.com/.*$",
DisplayName: "GitHub",
DisplayIcon: "/static/icons/github.svg",
}
Copy link
Member

Choose a reason for hiding this comment

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

Instead of hard-coding this and having to keep it in sync with the golden file, how about marshalling and unmarshalling the config to/from YAML and asserting that the two are the same byte-for-byte?

Copy link
Member Author

Choose a reason for hiding this comment

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

I can do both, but I should still have the golden file imo. The actual struct is clibase.Struct[[]ExternalAuthConfig]. So it might unmarshal/marshal, but the nested key structure could be messed up. We want to make sure the actual Go slice type is at the right yaml level (top level) imo.

Copy link
Member

@johnstcn johnstcn left a comment

Choose a reason for hiding this comment

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

This looks OK to me, but I'm by no means the authority on using YAML config.

@Emyrk Emyrk enabled auto-merge (squash) December 19, 2023 16:56
@Emyrk Emyrk merged commit c1451ca into main Dec 19, 2023
@Emyrk Emyrk deleted the stevenmasley/yaml_ext_auth branch December 19, 2023 18:09
@github-actions github-actions bot locked and limited conversation to collaborators Dec 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants