Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,8 @@ it('creates a new relying party via UI', async () => {
await screen.findByText(
'To finalize this new RP, a couple more steps are needed'
);
await screen.findByText(
'gcloud pubsub topics create rpQueue-new-id --message-retention-duration=2678400s'
);
await screen.findByText('eventbroker_endpoint_subscription_config');
await screen.findByText('fxa-legacy/tf/stage/locals.tf');
await screen.findByText('client_secret: SECRET123');
fireEvent.click(screen.getByText('Got it!'));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ import { AdminPanelFeature } from '@fxa/shared/guards';
import { Guard } from '../Guard';
import { useGuardContext } from '../../hooks/GuardContext';
import { useUserContext } from '../../hooks/UserContext';
import { getFormattedDate, getWafTfPath } from '../../lib/utils';
import {
getEventBrokerTfPath,
getFormattedDate,
getWafTfPath,
} from '../../lib/utils';
import { TableRowYHeader, TableYHeaders } from '../TableYHeaders';
import { adminApi } from '../../lib/api';

Expand Down Expand Up @@ -194,21 +198,8 @@ const CreateRelyingParty = ({ onExit }: { onExit: () => void }) => {
const [rpId, setRpId] = useState<string>('');
const [rpSecret, setRpSecret] = useState<string>('');

// Note, these are v1 projects. We need to migrate queues over to V2.
const gcpTerminalLink =
window.location.host === 'fxa-admin-panel.prod.mozaws.net'
? `https://console.cloud.google.com/welcome?cloudshell=true&project=moz-fx-fxa-prod-375e`
: `https://console.cloud.google.com/welcome?cloudshell=true&project=moz-fx-fxa-nonprod-375e`;

const oauthClientConfig =
window.location.host === 'fxa-admin-panel.prod.mozaws.net'
? `https://github.com/mozilla/webservices-infra/blob/main/fxa/k8s/fxa/values-prod.yaml`
: `https://github.com/mozilla/webservices-infra/blob/main/fxa/k8s/fxa/values-stage.yaml`;

const eventBrokerTfConfig =
window.location.host === 'fxa-admin-panel.prod.mozaws.net'
? `https://github.com/mozilla-services/cloudops-infra/blob/master/projects/fxa/tf/prod/envs/prod/resources/eventbroker.tf`
: `https://github.com/mozilla-services/cloudops-infra/blob/master/projects/fxa/tf/nonprod/envs/stage/resources/eventbroker.tf`;
const eventBrokerTfPath = getEventBrokerTfPath();
const eventBrokerTfUrl = `https://github.com/mozilla/webservices-infra/blob/main/${eventBrokerTfPath}`;

const resetState = () => {
setStatus('');
Expand Down Expand Up @@ -246,49 +237,29 @@ const CreateRelyingParty = ({ onExit }: { onExit: () => void }) => {
To finalize this new RP, a couple more steps are needed
</h3>
<p className="mb-2">
<b>Step 1:</b> Create a pubsub queue. In order to do this click{' '}
<a
href={gcpTerminalLink}
target="_blank"
className="underline text-blue-700"
>
here
</a>{' '}
to open a gcp terminal, and issue the following command:
<pre className="p-2">
gcloud pubsub topics create rpQueue-{rpId}{' '}
--message-retention-duration=2678400s
</pre>
</p>

<p className="mb-2">
<b>Step 2:</b> Next, update this{' '}
<b>Step 1:</b> Add the client id to the{' '}
<code>eventbroker_endpoint_subscription_config</code> map in{' '}
<a
href={eventBrokerTfConfig}
href={eventBrokerTfUrl}
target="_blank"
rel="noreferrer"
className="underline text-blue-700"
>
file
{eventBrokerTfPath}
</a>{' '}
accordingly. This registers the webhook used for message delivery.
</p>

<p className="mb-2">
<b>Step 3:</b> Next, update the OAUTH_CLIENT_IDS mappings{' '}
<a
href={oauthClientConfig}
target="_blank"
className="underline text-blue-700"
>
here
</a>
. This is used to map client-ids to a known name for legacy
amplitude events. This is considered optional, and may be RP
dependant.
(webservices-infra). One entry provisions the topic, the push
subscription, and the Firestore webhook document.
<pre className="p-2">{`"${rpId}" = {

@vpomerleau vpomerleau Aug 12, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

issue (blocking): Missing # pragma: allowlist secret — without it detect-secrets flags the client id as a HexHighEntropyString and the operator's first commit fails pre-commit.

Suggested change
<pre className="p-2">{`"${rpId}" = {
<pre className="p-2">{`"${rpId}" = { # pragma: allowlist secret

endpoint = "<webhook url>",
resource_server = <bool>,
},`}</pre>
Both attributes are optional. <code>resource_server</code> defaults
to <code>false</code>. Omit <code>endpoint</code> entirely for a
topic with no webhook.
</p>

<p className="mb-2">
<b>Step 4:</b> Provide the following secret in secure manner to the
<b>Step 2:</b> Provide the following secret in secure manner to the
relying party. This secret cannot be displayed again! If it is lost
or compromised, the RP's secret must be rotated.
<br />
Expand Down
38 changes: 37 additions & 1 deletion packages/fxa-admin-panel/src/lib/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

import { getFormattedDuration } from './utils';
import { getEventBrokerTfPath, getFormattedDuration } from './utils';

const setHost = (host: string) => {
Object.defineProperty(window, 'location', {
value: { host },
writable: true,
});
};

describe('utils', () => {
describe('formatDuration', () => {
Expand All @@ -24,4 +31,33 @@ describe('utils', () => {
);
});
});

describe('getEventBrokerTfPath', () => {
const originalLocation = window.location;

afterEach(() => {
Object.defineProperty(window, 'location', {
value: originalLocation,
writable: true,
});
});

it.each([
{
host: 'fxa-admin-panel.prod.mozaws.net',
expected: 'fxa-legacy/tf/prod/locals.tf',
},
{
host: 'fxa-admin-panel.prod.mozgcp.net',
expected: 'fxa-legacy/tf/prod/locals.tf',
},
{
host: 'fxa-admin-panel.stage.mozaws.net',
expected: 'fxa-legacy/tf/stage/locals.tf',
},
])('should return $expected on $host', ({ host, expected }) => {
setHost(host);
expect(getEventBrokerTfPath()).toBe(expected);
});
});
});
5 changes: 5 additions & 0 deletions packages/fxa-admin-panel/src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,8 @@ export const getWafTfPath = () =>
window.location.host.startsWith('fxa-admin-panel.prod.')
? 'fxa/tf/prod/waf.tf'
: 'fxa/tf/stage/waf.tf';

export const getEventBrokerTfPath = () =>
window.location.host.startsWith('fxa-admin-panel.prod.')
? 'fxa-legacy/tf/prod/locals.tf'
: 'fxa-legacy/tf/stage/locals.tf';