(config *codersdk.ExternalAuthConfig)
| 1161 | } |
| 1162 | |
| 1163 | func jfrogArtifactoryDefaults(config *codersdk.ExternalAuthConfig) codersdk.ExternalAuthConfig { |
| 1164 | defaults := codersdk.ExternalAuthConfig{ |
| 1165 | DisplayName: "JFrog Artifactory", |
| 1166 | Scopes: []string{"applied-permissions/user"}, |
| 1167 | DisplayIcon: "/icon/jfrog.svg", |
| 1168 | // TODO: Investigate if 'S256' is accepted and PKCE is supported |
| 1169 | CodeChallengeMethodsSupported: []string{string(promoauth.PKCEChallengeMethodNone)}, |
| 1170 | } |
| 1171 | // Artifactory servers will have some base url, e.g. https://jfrog.coder.com. |
| 1172 | // We will grab this from the Auth URL. This choice is not arbitrary. It is a |
| 1173 | // static string for all integrations on the same artifactory. |
| 1174 | if config.AuthURL == "" { |
| 1175 | // No auth url, means we cannot guess the urls. |
| 1176 | return defaults |
| 1177 | } |
| 1178 | |
| 1179 | auth, err := url.Parse(config.AuthURL) |
| 1180 | if err != nil { |
| 1181 | // We need a valid URL to continue with. |
| 1182 | return defaults |
| 1183 | } |
| 1184 | |
| 1185 | if config.ClientID == "" { |
| 1186 | return defaults |
| 1187 | } |
| 1188 | |
| 1189 | tokenURL := auth.ResolveReference(&url.URL{Path: fmt.Sprintf("/access/api/v1/integrations/%s/token", config.ClientID)}) |
| 1190 | defaults.TokenURL = tokenURL.String() |
| 1191 | |
| 1192 | // validate needs to return a 200 when logged in and a 401 when unauthenticated. |
| 1193 | validate := auth.ResolveReference(&url.URL{Path: "/access/api/v1/system/ping"}) |
| 1194 | defaults.ValidateURL = validate.String() |
| 1195 | |
| 1196 | // Some options omitted: |
| 1197 | // - Regex: Artifactory can span pretty much all domains (git, docker, etc). |
| 1198 | // I do not think we can intelligently guess this as a default. |
| 1199 | |
| 1200 | return defaults |
| 1201 | } |
| 1202 | |
| 1203 | func giteaDefaults(config *codersdk.ExternalAuthConfig) codersdk.ExternalAuthConfig { |
| 1204 | defaults := codersdk.ExternalAuthConfig{ |
no test coverage detected