-
Notifications
You must be signed in to change notification settings - Fork 2.1k
feat(join-tokens): [44794] Add Join Token form for GitHub #54308
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
nicholasmarais1158
merged 37 commits into
master
from
nickmarais/feat/44794-github-join-tokens
May 1, 2025
Merged
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
67af202
Fix/silence lint issues
nicholasmarais1158 3645dd7
Fix spacing on side panel
nicholasmarais1158 f197c29
Return github-specific config from `GET /webapi/tokens`
nicholasmarais1158 c7805d2
Add github form for create/edit
nicholasmarais1158 bb2bf9a
Handle unsupported fields during edit
nicholasmarais1158 1ad2db8
Add js docs for check functions
nicholasmarais1158 8d0d848
Add js docs for github check function
nicholasmarais1158 0353e4b
Fix casing in test mocks
nicholasmarais1158 54fa824
Fix missing `readonly` prop
nicholasmarais1158 99e97b3
Merge branch 'master' into nickmarais/feat/44794-github-join-tokens
nicholasmarais1158 c2a4dbb
Remove unused import
nicholasmarais1158 2277a4e
Merge branch 'master' into nickmarais/feat/44794-github-join-tokens
nicholasmarais1158 26ebb15
Retain metadata (inc expiry) on token edit
nicholasmarais1158 93a2247
Remove mutual-exclusivity on repo/owner fields
nicholasmarais1158 c2d0292
Improve supported fields readability
nicholasmarais1158 e1f827b
Hide GHES config
nicholasmarais1158 6eb7de0
Merge branch 'master' into nickmarais/feat/44794-github-join-tokens
nicholasmarais1158 e8232a8
Ignore token not found errors when creating
nicholasmarais1158 5234b8a
Lock GHES fields when using OSS
nicholasmarais1158 f7865f2
Lint fix
nicholasmarais1158 984a1fa
Merge branch 'master' into nickmarais/feat/44794-github-join-tokens
nicholasmarais1158 05de19a
Return github-specific config from `GET /webapi/tokens`
nicholasmarais1158 0943a83
Support "token" in `/webapi/yaml/parse/:kind`
nicholasmarais1158 413cde5
Use empty time.Time for token expiry (`POST /webapi/tokens`)
nicholasmarais1158 a751430
Merge branch 'nickmarais/feat/44794-github-join-tokens-api' into nick…
nicholasmarais1158 f985715
Revert createTokenForDiscoveryHandle changes
nicholasmarais1158 928c83e
Fix acronym casing
nicholasmarais1158 2b90f08
Cover enterprise token types in tests
nicholasmarais1158 e7fd9a5
Cover github tokens in existing tests
nicholasmarais1158 98c1c72
Tweak handling of `tokenId`
nicholasmarais1158 1311d91
Check expiry is not overwritten
nicholasmarais1158 7696729
Merge branch 'master' into nickmarais/feat/44794-github-join-tokens-api
nicholasmarais1158 f0254a6
Revert removing tokenId check
nicholasmarais1158 0209744
Merge branch 'nickmarais/feat/44794-github-join-tokens-api' into nick…
nicholasmarais1158 521b629
Refactor supported fields
nicholasmarais1158 c4aa6ec
Merge branch 'master' into nickmarais/feat/44794-github-join-tokens
nicholasmarais1158 0c27883
Remove use of `X-Teleport-TokenName`
nicholasmarais1158 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,97 @@ | ||
| /** | ||
| * Teleport | ||
| * Copyright (C) 2025 Gravitational, Inc. | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU Affero General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU Affero General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Affero General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| import { collectKeys } from './collectKeys'; | ||
|
|
||
| describe('collectKeys', () => { | ||
| it.each` | ||
| value | ||
| ${undefined} | ||
| ${null} | ||
| ${1} | ||
| ${true} | ||
| ${() => {}} | ||
| `('supports non object values ($value)', ({ value }) => { | ||
| const actual = collectKeys(value); | ||
| expect(actual).toBeNull(); | ||
| }); | ||
|
|
||
| it('supports empty object values', () => { | ||
| const actual = collectKeys({}); | ||
| expect(actual).toEqual([]); | ||
| }); | ||
|
|
||
| it('supports empty array values', () => { | ||
| const actual = collectKeys([]); | ||
| expect(actual).toEqual([]); | ||
| }); | ||
|
|
||
| it('supports simple object values', () => { | ||
| const actual = collectKeys({ | ||
| number: 1, | ||
| boolean: true, | ||
| string: 'string', | ||
| function: () => {}, | ||
| null: null, | ||
| undefined: undefined, | ||
| }); | ||
| expect(actual).toEqual([ | ||
| '.number', | ||
| '.boolean', | ||
| '.string', | ||
| '.function', | ||
| '.null', | ||
| '.undefined', | ||
| ]); | ||
| }); | ||
|
|
||
| it('supports simple array values', () => { | ||
| const actual = collectKeys([ | ||
| { alpha: true }, | ||
| { alpha: true }, | ||
| { beta: true }, | ||
| ]); | ||
| expect(actual).toEqual(['.alpha', '.alpha', '.beta']); | ||
| }); | ||
|
|
||
| it('supports nested object values', () => { | ||
| const actual = collectKeys([ | ||
| { | ||
| inner: { | ||
| foo: 'bar', | ||
| }, | ||
| }, | ||
| ]); | ||
| expect(actual).toEqual(['.inner.foo']); | ||
| }); | ||
|
|
||
| it('supports nested array values', () => { | ||
| const actual = collectKeys([[{ foo: 'bar' }], { bar: 'foo' }]); | ||
| expect(actual).toEqual(['.foo', '.bar']); | ||
| }); | ||
|
|
||
| it('allows a custom key prefix', () => { | ||
| const actual = collectKeys( | ||
| { | ||
| foo: 1, | ||
| }, | ||
| 'root' | ||
| ); | ||
| expect(actual).toEqual(['root.foo']); | ||
| }); | ||
| }); |
This file contains hidden or 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,42 @@ | ||
| /** | ||
| * Teleport | ||
| * Copyright (C) 2025 Gravitational, Inc. | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU Affero General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU Affero General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Affero General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| /** | ||
| * `collectKeys` gathers object keys recursively and returns them. Arrays are | ||
| * traversed, but are transparent. Returns null if the value is not an object | ||
| * or array of objects, and an empty array of no keys are present. | ||
| * | ||
| * @param value Value from which keys will be collected | ||
| * @param prefix An optional value to be prepended to all keys returned | ||
| * @returns An array of the keys collected (if any) or null | ||
| */ | ||
| export const collectKeys = (value: unknown, prefix: string = '') => { | ||
| if (typeof value !== 'object' || value === null) { | ||
| return prefix ? [prefix] : null; | ||
| } | ||
|
|
||
| if (Array.isArray(value)) { | ||
| return value.flatMap(val => { | ||
| return collectKeys(val, prefix); | ||
| }); | ||
| } | ||
|
|
||
| return Object.entries(value).flatMap(([k, v]) => { | ||
| return collectKeys(v, `${prefix}.${k}`); | ||
| }); | ||
| }; |
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when would
readonlybe true for IAM forms?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When it's data includes configuration other than
.aws_accountand.aws_arn. In which case editing the fields is prevented for all join methods and the submit button is disabled.Does that behaviour feel ok?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah sounds good!