Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
b8cac86
feat(trust-relationships): Add API Access tab with trust relationship…
khvn26 Jul 18, 2026
16f4adf
fix(OIDC): Provider selection cards are not keyboard accessible
khvn26 Jul 20, 2026
17c95c4
fix(OIDC): Trust relationship role changes ignore API failures
khvn26 Jul 20, 2026
38721de
refactor(OIDC): Give each trust relationship component its own folder
khvn26 Jul 20, 2026
bf9c703
fix(OIDC): Freeform trust relationship modal ignores role API failures
khvn26 Jul 22, 2026
f582d31
fix(OIDC): Trust relationship issuer is hidden behind its provider icon
khvn26 Aug 14, 2026
965894c
refactor(OIDC): Use the design system Icon to remove a claim rule
khvn26 Aug 14, 2026
4d5913a
refactor(OIDC): Use InputGroup for the GitHub audience field
khvn26 Aug 14, 2026
3d1af53
fix(OIDC): Trust relationship form banner renders unreadable error bo…
khvn26 Aug 14, 2026
55eb84f
refactor(OIDC): Read trust relationship roles through RTK Query
khvn26 Aug 14, 2026
8dfc35a
refactor(OIDC): Use FieldLabel for the claim rules label
khvn26 Aug 14, 2026
1671d07
fix(API keys): A failed key fetch disables key creation permanently
khvn26 Aug 14, 2026
9033fc6
test(OIDC): Name the pending roles update type
khvn26 Aug 14, 2026
f7672e4
fix(OIDC): Detached roles reappear after switching a trust relationsh…
khvn26 Aug 14, 2026
09da768
fix(OIDC): Workflow snippet omits the environment for a padded claim …
khvn26 Aug 14, 2026
0799c1a
fix(OIDC): Role chips cannot be removed with a keyboard
khvn26 Aug 14, 2026
5feae08
fix(OIDC): Editing a GitHub trust relationship drops claim rules it c…
khvn26 Aug 14, 2026
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 @@ -30,13 +30,13 @@ export const masterAPIKeyWithMasterAPIKeyRoleService = service
}),
}),
getRolesMasterAPIKeyWithMasterAPIKeyRoles: builder.query<
Res['masterAPIKeyWithMasterAPIKeyRoles'],
Req['getMasterAPIKeyWithMasterAPIKeyRoles']
Res['rolesMasterAPIKeyWithMasterAPIKeyRoles'],
Req['getRolesMasterAPIKeyWithMasterAPIKeyRoles']
>({
providesTags: (res) => [
{ id: res?.id, type: 'MasterAPIKeyWithMasterAPIKeyRole' },
providesTags: (_res, _error, query) => [
{ id: query.prefix, type: 'MasterAPIKeyWithMasterAPIKeyRole' },
],
query: (query: Req['getMasterAPIKeyWithMasterAPIKeyRoles']) => ({
query: (query: Req['getRolesMasterAPIKeyWithMasterAPIKeyRoles']) => ({
url: `organisations/${query.org_id}/master-api-keys/${query.prefix}/roles/`,
}),
}),
Expand Down Expand Up @@ -87,7 +87,7 @@ export async function getRolesMasterAPIKeyWithMasterAPIKeyRoles(

export async function deleteMasterAPIKeyWithMasterAPIKeyRoles(
store: any,
data: Req['getMasterAPIKeyWithMasterAPIKeyRoles'],
data: Req['deleteMasterAPIKeyWithMasterAPIKeyRoles'],
options?: Parameters<
typeof masterAPIKeyWithMasterAPIKeyRoleService.endpoints.deleteMasterAPIKeyWithMasterAPIKeyRoles.initiate
>[1],
Expand Down
90 changes: 90 additions & 0 deletions frontend/common/services/useTrustRelationship.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import { Res } from 'common/types/responses'
import { Req } from 'common/types/requests'
import { service } from 'common/service'

export const trustRelationshipService = service
.enhanceEndpoints({
addTagTypes: ['TrustRelationship', 'MasterAPIKeyWithMasterAPIKeyRole'],
})
.injectEndpoints({
endpoints: (builder) => ({
createTrustRelationship: builder.mutation<
Res['trustRelationship'],
Req['createTrustRelationship']
>({
invalidatesTags: [{ id: 'LIST', type: 'TrustRelationship' }],
query: (query: Req['createTrustRelationship']) => ({
body: query.body,
method: 'POST',
url: `organisations/${query.organisation_id}/trust-relationships/`,
}),
}),
deleteTrustRelationship: builder.mutation<
void,
Req['deleteTrustRelationship']
>({
invalidatesTags: [{ id: 'LIST', type: 'TrustRelationship' }],
query: (query: Req['deleteTrustRelationship']) => ({
method: 'DELETE',
url: `organisations/${query.organisation_id}/trust-relationships/${query.id}/`,
}),
}),
getTrustRelationships: builder.query<
Res['trustRelationships'],
Req['getTrustRelationships']
>({
providesTags: [{ id: 'LIST', type: 'TrustRelationship' }],
query: (query: Req['getTrustRelationships']) => ({
url: `organisations/${query.organisation_id}/trust-relationships/`,
}),
}),
updateTrustRelationship: builder.mutation<
Res['trustRelationship'],
Req['updateTrustRelationship']
>({
// Turning `is_admin` on detaches the backing key's roles server-side,
// so the cached role list has to go with it.
invalidatesTags: (res) => [
{ id: 'LIST', type: 'TrustRelationship' },
{ id: res?.id, type: 'TrustRelationship' },
'MasterAPIKeyWithMasterAPIKeyRole',
],
query: (query: Req['updateTrustRelationship']) => ({
body: query.body,
method: 'PUT',
url: `organisations/${query.organisation_id}/trust-relationships/${query.id}/`,
}),
}),
// END OF ENDPOINTS
}),
})

export async function getTrustRelationships(
store: any,
data: Req['getTrustRelationships'],
options?: Parameters<
typeof trustRelationshipService.endpoints.getTrustRelationships.initiate
>[1],
) {
return store.dispatch(
trustRelationshipService.endpoints.getTrustRelationships.initiate(
data,
options,
),
)
}
// END OF FUNCTION_EXPORTS

export const {
useCreateTrustRelationshipMutation,
useDeleteTrustRelationshipMutation,
useGetTrustRelationshipsQuery,
useUpdateTrustRelationshipMutation,
// END OF EXPORTS
} = trustRelationshipService

/* Usage examples:
const { data, isLoading } = useGetTrustRelationshipsQuery({ organisation_id: 2 }) //get hook
const [createTrustRelationship, { isLoading, data, isSuccess }] = useCreateTrustRelationshipMutation() //create hook
trustRelationshipService.endpoints.getTrustRelationships.select({organisation_id: 2})(store.getState()) //access data from any function
*/
30 changes: 29 additions & 1 deletion frontend/common/types/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
TagStrategy,
FeatureType,
LifecycleStage,
TrustRelationshipClaimRule,
} from './responses'
import { UtmsType } from './utms'

Expand Down Expand Up @@ -496,14 +497,41 @@ export type Req = {
getRoleMasterApiKey: { org_id: number; role_id: number; id: string }
updateRoleMasterApiKey: { org_id: number; role_id: number; id: string }
deleteRoleMasterApiKey: { org_id: number; role_id: number; id: string }
createRoleMasterApiKey: { org_id: number; role_id: number }
createRoleMasterApiKey: {
org_id: number
role_id: number
body: { master_api_key: string }
}
getMasterAPIKeyWithMasterAPIKeyRoles: { org_id: number; prefix: string }
deleteMasterAPIKeyWithMasterAPIKeyRoles: {
org_id: number
prefix: string
role_id: number
}
getRolesMasterAPIKeyWithMasterAPIKeyRoles: { org_id: number; prefix: string }
getTrustRelationships: { organisation_id: number }
createTrustRelationship: {
organisation_id: number
body: {
name: string
issuer: string
audience: string
claim_rules: TrustRelationshipClaimRule[]
is_admin: boolean
}
}
updateTrustRelationship: {
organisation_id: number
id: number
body: {
name: string
issuer: string
audience: string
claim_rules: TrustRelationshipClaimRule[]
is_admin: boolean
}
}
deleteTrustRelationship: { organisation_id: number; id: number }
createLaunchDarklyProjectImport: {
project_id: number
body: {
Expand Down
21 changes: 21 additions & 0 deletions frontend/common/types/responses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1302,6 +1302,24 @@ export type WarehouseConnection = {
unique_events_count: number | null
}

export type TrustRelationshipClaimRule = {
claim: string
values: string[]
}

export type TrustRelationship = {
id: number
name: string
issuer: string
audience: string
claim_rules: TrustRelationshipClaimRule[]
is_admin: boolean
master_api_key_id: string
master_api_key_prefix: string
created_at: string
created_by: number | null
}

export type Res = {
segments: PagedResponse<Segment>
segment: Segment
Expand Down Expand Up @@ -1392,11 +1410,14 @@ export type Res = {
launchDarklyProjectImport: LaunchDarklyProjectImport
launchDarklyProjectsImport: LaunchDarklyProjectImport[]
roleMasterApiKey: { id: number; master_api_key: string; role: number }
trustRelationship: TrustRelationship
trustRelationships: PagedResponse<TrustRelationship>
masterAPIKeyWithMasterAPIKeyRoles: {
id: string
prefix: string
roles: RolePermissionUser[]
}
rolesMasterAPIKeyWithMasterAPIKeyRoles: PagedResponse<Role>
userWithRoles: PagedResponse<Role>
groupWithRole: PagedResponse<Role>
changeRequests: PagedResponse<ChangeRequestSummary>
Expand Down
41 changes: 28 additions & 13 deletions frontend/web/components/AdminAPIKeys.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import OrganisationStore from 'common/stores/organisation-store'
import getUserDisplayName from 'common/utils/getUserDisplayName'
import Token from './Token'
import JSONReference from './JSONReference'
import PageTitle from './PageTitle'
import PlanBasedBanner from './PlanBasedAccess'
import Button from './base/forms/Button'
import DateSelect from './DateSelect'
import Icon from './icons/Icon'
Expand Down Expand Up @@ -201,8 +203,8 @@ export class CreateAPIKey extends PureComponent {
/>
</Flex>
<>
<Row className='mb-3 mt-4'>
<label className='mr-2'>Is admin</label>
<Row className='mb-3 mt-4 gap-2'>
<label className='mb-0'>Is admin</label>
<Switch
onChange={() => {
this.setState({
Expand All @@ -212,7 +214,13 @@ export class CreateAPIKey extends PureComponent {
checked={is_admin}
disabled={!Utils.getPlansPermission('RBAC') && is_admin}
/>
<PlanBasedBanner feature='RBAC' theme='badge' />
</Row>
<PlanBasedBanner
feature='RBAC'
theme='description'
className='mb-4'
/>
{!is_admin && (
<>
<Row className='mb-3 mt-4'>
Expand Down Expand Up @@ -405,6 +413,9 @@ export default class AdminAPIKeys extends PureComponent {
isLoading: false,
})
})
.catch(() => {
this.setState({ isLoading: false })
})
Comment thread
khvn26 marked this conversation as resolved.
}

remove = (v) => {
Expand Down Expand Up @@ -439,12 +450,19 @@ export default class AdminAPIKeys extends PureComponent {
title={'API Keys'}
json={apiKeys}
/>
<Column className='my-4 ml-0 col-md-6'>
<h5 className='mb-1'>{`${'Manage'} API Keys`}</h5>
<p className='mb-0 fs-small lh-sm'>
{`API keys are used to authenticate with the Admin API.`}
</p>
<div className='mb-4 fs-small lh-sm'>
<div className='mt-4'>
<PageTitle
title='API keys'
cta={
<Button
onClick={this.createAPIKey}
disabled={this.state.isLoading}
>
{`Create API Key`}
</Button>
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
>
{`API keys are used to authenticate with the Admin API. `}
<Button
theme='text'
href='https://docs.flagsmith.com/integrations/terraform#terraform-api-key'
Expand All @@ -453,11 +471,8 @@ export default class AdminAPIKeys extends PureComponent {
>
{`Learn about API Keys.`}
</Button>
</div>
<Button onClick={this.createAPIKey} disabled={this.state.isLoading}>
{`Create API Key`}
</Button>
</Column>
</PageTitle>
</div>
{(this.state.isLoading || !OrganisationStore.model?.users) && (
<div className='text-center'>
<Loader />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,20 @@ const OrganisationSettingsPage: FC = () => {
API.trackPage(Constants.pages.ORGANISATION_SETTINGS)
}, [])

// Back-compat: the SAML tab was renamed to SSO. Existing bookmarks and
// links pointing at ?tab=saml redirect to ?tab=sso so users land in the
// right place.
// Back-compat: renamed tabs redirect so existing bookmarks and links land
// in the right place (SAML became SSO; the API Keys tab became API Access
// with the `keys` slug).
const history = useHistory()
const location = useLocation()
useEffect(() => {
const legacyTabs: Record<string, string> = {
'api-keys': 'keys',
'saml': 'sso',
}
const params = new URLSearchParams(location.search)
if (params.get('tab') === 'saml') {
params.set('tab', 'sso')
const redirectTo = legacyTabs[params.get('tab') || '']
if (redirectTo) {
params.set('tab', redirectTo)
history.replace(`${location.pathname}?${params.toString()}`)
}
}, [history, location])
Expand Down Expand Up @@ -116,7 +121,7 @@ const OrganisationSettingsPage: FC = () => {
component: <APIKeysTab organisationId={organisation.id} />,
isVisible: true,
key: 'keys',
label: 'API Keys',
label: 'API Access',
},
{
component: <WebhooksTab organisationId={organisation.id} />,
Expand All @@ -137,7 +142,12 @@ const OrganisationSettingsPage: FC = () => {
<PageTitle title='Organisation Settings' />
<Tabs urlParam='tab' className='mt-0' uncontrolled hideNavOnSingleTab>
{tabs.map(({ component, key, label }) => (
<TabItem key={key} tabLabel={label} data-test={key}>
<TabItem
key={key}
tabLabel={label}
tabLabelString={key}
data-test={key}
>
{component}
</TabItem>
))}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
import React from 'react'
import AdminAPIKeys from 'components/AdminAPIKeys'
import Utils from 'common/utils/utils'
import TrustRelationships from './trust-relationships'

type APIKeysTabProps = {
organisationId: number
}

export const APIKeysTab = ({ organisationId }: APIKeysTabProps) => {
return <AdminAPIKeys organisationId={organisationId} />
return (
<>
<AdminAPIKeys organisationId={organisationId} />
{Utils.getFlagsmithHasFeature('trust_relationships') && (
<TrustRelationships organisationId={organisationId} />
)}
</>
)
}
Loading
Loading