Skip to content

Commit e9f5ec8

Browse files
authored
RHCLOUD-38449 Implements remaining security schemes (#462)
1 parent 968139b commit e9f5ec8

File tree

1 file changed

+42
-1
lines changed

1 file changed

+42
-1
lines changed

src/components/APIDoc/SecurityScheme.tsx

+42-1
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,54 @@ export const SecurityScheme: React.FunctionComponent<SecuritySchemesProps> = (pr
1313
case 'http':
1414
return <SecuritySchemeHttp {...props.securityScheme} />;
1515
case 'oauth2':
16+
return <SecuritySchemeOauth {...props.securityScheme} />;
1617
case 'openIdConnect':
17-
throw new Error('Unimplemented scheme');
18+
return <SecuritySchemeOpenId {...props.securityScheme} />;
1819
default:
1920
throw new Error(`Unknown security scheme found: ${JSON.stringify(props.securityScheme)}`);
2021
}
2122
};
2223

24+
const SecuritySchemeOpenId: React.FunctionComponent<OpenAPIV3.OpenIdSecurityScheme> = (openid) => {
25+
return (
26+
<>
27+
<span>OpenId Authentication, connect url: {openid.openIdConnectUrl}</span>
28+
<br />
29+
{openid.description && (
30+
<span>
31+
<ReactMarkdown>{openid.description}</ReactMarkdown>
32+
</span>
33+
)}
34+
</>
35+
);
36+
};
37+
38+
const SecuritySchemeOauth: React.FunctionComponent<OpenAPIV3.OAuth2SecurityScheme> = (oauth) => {
39+
return (
40+
<>
41+
<span>OAuth2</span>
42+
{oauth.flows && Object.keys(oauth.flows).length > 0 && (
43+
<>
44+
<span>Supported flows</span>
45+
<br />
46+
<ul>
47+
{oauth.flows.authorizationCode && <li>Authorization code</li>}
48+
{oauth.flows.clientCredentials && <li>Client credentials</li>}
49+
{oauth.flows.implicit && <li>Implicit</li>}
50+
{oauth.flows.password && <li>Password</li>}
51+
</ul>
52+
</>
53+
)}
54+
<br />
55+
{oauth.description && (
56+
<span>
57+
<ReactMarkdown>{oauth.description}</ReactMarkdown>
58+
</span>
59+
)}
60+
</>
61+
);
62+
};
63+
2364
const SecuritySchemeHttp: React.FunctionComponent<OpenAPIV3.HttpSecurityScheme> = (http) => {
2465
return (
2566
<>

0 commit comments

Comments
 (0)