Skip to content

Commit

Permalink
upd backend for my access update signed jwt data
Browse files Browse the repository at this point in the history
  • Loading branch information
ikethecoder committed May 12, 2023
1 parent 8d463de commit 0343014
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

query GetMyServiceAccesses {
myServiceAccesses(where: { productEnvironment_is_null: false }) {
id
name
active
credentialReference
application {
name
}
productEnvironment {
id
name
flow
product {
id
name
}
credentialIssuer {
clientAuthenticator
}
}
}
myAccessRequests(
where: { productEnvironment_is_null: false, serviceAccess_is_null: true }
) {
id
application {
name
}
productEnvironment {
id
name
product {
id
name
}
}
isComplete
isApproved
isIssued
}
}
60 changes: 39 additions & 21 deletions src/nextapp/components/access-list/access-list-row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ const AccessListRow: React.FC<AccessListRowProps> = ({
},
[onRevoke]
);
const controls = data?.controls ? JSON.parse(data.controls) : {};
const controls = data?.credentialReference
? JSON.parse(data.credentialReference)
: {};

return (
<Tr>
Expand All @@ -67,7 +69,7 @@ const AccessListRow: React.FC<AccessListRowProps> = ({
</Tag>
</Td>
<Td>{data.application?.name}</Td>
<Td color="bc-blue">{data.productEnvironment.clientId}</Td>
<Td color="bc-blue">{data.name}</Td>
<Td isNumeric data-testid={`access-generate-credentials-${index}`}>
{(has(data, 'isApproved') ||
has(data, 'isIssued') ||
Expand All @@ -80,8 +82,18 @@ const AccessListRow: React.FC<AccessListRowProps> = ({
isOpen={isOpen}
onClose={onClose}
/>
<JwksDialog id={data.id} isOpen={jwksDialog.isOpen} onClose={jwksDialog.onClose}/>
<PublicKeyDialog id={data.id} isOpen={publicKeyDialog.isOpen} onClose={publicKeyDialog.onClose}/>
<JwksDialog
id={data.id}
jwksUrl={controls.jwksUrl}
isOpen={jwksDialog.isOpen}
onClose={jwksDialog.onClose}
/>
<PublicKeyDialog
id={data.id}
clientCertificate={controls.clientCertificate}
isOpen={publicKeyDialog.isOpen}
onClose={publicKeyDialog.onClose}
/>
<Menu placement="bottom-end">
<MenuButton
as={IconButton}
Expand All @@ -95,30 +107,36 @@ const AccessListRow: React.FC<AccessListRowProps> = ({
'kong-api-key-only',
'kong-api-key-acl',
'client-credentials',
].includes(data.productEnvironment.flow) && (
].includes(data.productEnvironment.flow) ||
(data.productEnvironment?.credentialIssuer
?.clientAuthenticator === 'client-secret' && (
<MenuItem
data-testid="regenerate-credentials-btn"
onClick={onOpen}
>
Regenerate Credentials
</MenuItem>
))}
{data.productEnvironment?.credentialIssuer?.clientAuthenticator ===
'client-jwt-jwks-url' &&
controls.jwksUrl && (
<MenuItem
data-testid="update-jwksurl-btn"
onClick={jwksDialog.onOpen}
>
Update JWKS URL
</MenuItem>
)}
{data.productEnvironment?.credentialIssuer?.clientAuthenticator ===
'client-jwt-jwks-url' &&
controls.clientCertificate && (
<MenuItem
data-testid="update-pubkey-btn"
onClick={publicKeyDialog.onOpen}
>
Update Public Key
</MenuItem>
)}
{data.productEnvironment?.flow === 'client-jwt-jwks-url' && controls.jwksUrl && (
<MenuItem
data-testid="regenerate-credentials-btn"
onClick={jwksDialog.onOpen}
>
Update JWKS URL
</MenuItem>
)}
{data.productEnvironment?.flow === 'client-jwt-jwks-url' && controls.publicKey && (
<MenuItem
data-testid="regenerate-credentials-btn"
onClick={publicKeyDialog.onOpen}
>
Update Public Key
</MenuItem>
)}
<MenuItem
color="bc-error"
onClick={handleRevoke(data.id, has(data, 'isIssued'))}
Expand Down
14 changes: 11 additions & 3 deletions src/nextapp/components/access-request-form/jwks-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,17 @@ import CopyButton from '../copy-button/copy-button.tsx';

interface JwksDialogProps {
id: string;
jwksUrl: string;
isOpen: boolean;
onClose: () => void;
}

const JwksDialog: React.FC<JwksDialogProps> = ({ id, isOpen, onClose }) => {
const JwksDialog: React.FC<JwksDialogProps> = ({
id,
jwksUrl,
isOpen,
onClose,
}) => {
return (
<>
<Modal
Expand Down Expand Up @@ -51,7 +57,7 @@ const JwksDialog: React.FC<JwksDialogProps> = ({ id, isOpen, onClose }) => {
name="jwksUrl"
variant="bc-input"
type="url"
value="https://example.com/.well-known/jwks.json"
value={jwksUrl}
/>
</FormControl>
<FormControl mb={4}>
Expand Down Expand Up @@ -104,7 +110,9 @@ const JwksDialog: React.FC<JwksDialogProps> = ({ id, isOpen, onClose }) => {
</ModalBody>
<ModalFooter>
<ButtonGroup>
<Button variant="secondary" onClick={onClose}>Cancel</Button>
<Button variant="secondary" onClick={onClose}>
Cancel
</Button>
<Button onClick={onClose} data-testid="jwks-update-button">
Update
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ import CopyButton from '../copy-button/copy-button';

interface PublicKeyDialogProps {
id: string;
clientCertificate: string;
isOpen: boolean;
onClose: () => void;
}

const PublicKeyDialog: React.FC<PublicKeyDialogProps> = ({
id,
clientCertificate,
isOpen,
onClose,
}) => {
Expand Down Expand Up @@ -55,6 +57,7 @@ const PublicKeyDialog: React.FC<PublicKeyDialogProps> = ({
height="64px"
name="publicKey"
variant="bc-input"
value={clientCertificate}
/>
<CopyButton value="alskdfjalsjfalskdfjlsdkj" />
</Flex>
Expand Down
4 changes: 4 additions & 0 deletions src/nextapp/pages/devportal/access/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ const query = gql`
id
name
active
credentialReference
application {
name
}
Expand All @@ -99,6 +100,9 @@ const query = gql`
id
name
}
credentialIssuer {
clientAuthenticator
}
}
}
myAccessRequests(
Expand Down
4 changes: 3 additions & 1 deletion src/services/workflow/generate-credential.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,11 @@ export const generateCredential = async (
consumer.id
);

const credentialReference = {
const credentialReference: CredentialReference = {
id: newClient.client.id,
clientId: newClient.client.clientId,
clientCertificate: controls.clientCertificate,
jwksUrl: controls.jwksUrl,
};
// Create a ServiceAccess record
const consumerType = 'client';
Expand Down
3 changes: 3 additions & 0 deletions src/services/workflow/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ export interface NewCredential {
}

export interface CredentialReference {
id?: string;
keyAuthPK?: string;
clientId?: string;
clientCertificate?: string;
jwksUrl?: string;
}

// Subject Identity when a Product is requested using the Authentication Code Flow
Expand Down

0 comments on commit 0343014

Please sign in to comment.