Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Catch auth channel update on channel deletion (#3024)
* wrap and catch error if deleting domain fails * migrate gcp auth api to apiv2 * add changelog * fix a word
- Loading branch information
Showing
3 changed files
with
47 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
- Catches errors while updating authorized domains when deleting channels, printing a warning instead of failing. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,34 @@ | ||
import * as api from "../api"; | ||
import { Client } from "../apiv2"; | ||
import { identityOrigin } from "../api"; | ||
|
||
const apiClient = new Client({ urlPrefix: identityOrigin, auth: true }); | ||
|
||
/** | ||
* Returns the list of authorized domains. | ||
* @param project project identifier. | ||
* @return authorized domains. | ||
*/ | ||
export async function getAuthDomains(project: string): Promise<string[]> { | ||
const res = await api.request("GET", `/admin/v2/projects/${project}/config`, { | ||
auth: true, | ||
origin: api.identityOrigin, | ||
}); | ||
return res?.body?.authorizedDomains; | ||
const res = await apiClient.get<{ authorizedDomains: string[] }>( | ||
`/admin/v2/projects/${project}/config` | ||
); | ||
return res.body.authorizedDomains; | ||
} | ||
|
||
/** | ||
* Updates the list of authorized domains. | ||
* @param project project identifier. | ||
* @param authDomains full list of authorized domains. | ||
* @return authorized domains. | ||
*/ | ||
export async function updateAuthDomains(project: string, authDomains: string[]): Promise<string[]> { | ||
const resp = await api.request( | ||
"PATCH", | ||
`/admin/v2/projects/${project}/config?update_mask=authorizedDomains`, | ||
{ | ||
auth: true, | ||
origin: api.identityOrigin, | ||
data: { | ||
authorizedDomains: authDomains, | ||
}, | ||
} | ||
const res = await apiClient.patch< | ||
{ authorizedDomains: string[] }, | ||
{ authorizedDomains: string[] } | ||
>( | ||
`/admin/v2/projects/${project}/config`, | ||
{ authorizedDomains: authDomains }, | ||
{ queryParams: { update_mask: "authorizedDomains" } } | ||
); | ||
return resp?.body?.authorizedDomains; | ||
return res.body.authorizedDomains; | ||
} |