Skip to content
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

[v15] Fix Machine ID GitHub Discover flow #47709

Open
wants to merge 6 commits into
base: branch/v15
Choose a base branch
from
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 @@ -118,6 +118,8 @@ describe('configureBot Component', () => {

const botNameInput = screen.getByPlaceholderText('github-actions-cd');
await userEvent.type(botNameInput, 'bot-name');
const sshUserInput = screen.getByPlaceholderText('ubuntu');
await userEvent.type(sshUserInput, 'ssh-user');
await userEvent.click(screen.getByTestId('button-next'));
expect(
screen.getByText(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import Validation, { Validator } from 'shared/components/Validation';
import Text from 'design/Text';

import FieldInput from 'shared/components/FieldInput';
import { requiredField } from 'shared/components/Validation/rules';

import Alert from 'design/Alert';

Expand Down Expand Up @@ -162,7 +163,7 @@ export function ConfigureBot({ nextStep, prevStep }: FlowStepProps) {
fontWeight="lighter"
fontSize="1"
>
(optional)
(required field)
</Text>
</Text>
<FieldInput
Expand All @@ -175,6 +176,7 @@ export function ConfigureBot({ nextStep, prevStep }: FlowStepProps) {
login: e.target.value,
})
}
rule={requiredField('SSH user is required')}
/>
</FormItem>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ describe('gitHub component', () => {
// step 1: Configure Bot Access
const botNameInput = screen.getByPlaceholderText('github-actions-cd');
await userEvent.type(botNameInput, 'bot-name');
const sshUserInput = screen.getByPlaceholderText('ubuntu');
await userEvent.type(sshUserInput, 'ssh-user');
await userEvent.click(screen.getByTestId('button-next'));
// step 2: Connect GitHub
expect(
Expand Down
34 changes: 4 additions & 30 deletions web/packages/teleport/src/Bots/Add/GitHubActions/useGitHubFlow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,9 @@ function getRoleYaml(
labels: ResourceLabel[],
login: string
): string {
const nodeLabelsStanza = labels.map(
label => `'${label.name}': '${label.value}'\n`
);
const nodeLabels = labels
.map(label => `'${label.name}': '${label.value}'`)
.join('\n ');

return `kind: role
metadata:
Expand All @@ -240,38 +240,12 @@ metadata:
${GITHUB_ACTIONS_LABEL_KEY}: ${GITHUB_ACTIONS_LABEL_VAL}
spec:
allow:
# List of Kubernetes cluster users can access the k8s API
kubernetes_labels:
${nodeLabelsStanza}
kubernetes_groups:
- '{{internal.kubernetes_groups}}'
kubernetes_users:
- '{{internal.kubernetes_users}}'

kubernetes_resources:
- kind: '*'
namespace: '*'
name: '*'
verbs: ['*']

# List of allowed SSH logins
logins: [${login}]

# List of node labels that users can SSH into
node_labels:
${nodeLabelsStanza}
rules:
- resources:
- event
verbs:
- list
- read
- resources:
- session
verbs:
- read
- list
where: contains(session.participants, user.metadata.name)
${nodeLabels}
options:
max_session_ttl: 8h0m0s
version: v7
Expand Down
Loading