mirror of
https://github.com/rustfs/console.git
synced 2026-08-28 19:47:21 +08:00
feat: add Other Audiences to OIDC form (#101)
This commit is contained in:
committed by
GitHub
parent
d99e02f129
commit
192cbd515c
@@ -33,6 +33,7 @@ function providerToFormValues(provider: OidcConfigProvider): OidcProviderFormVal
|
||||
client_id: provider.client_id,
|
||||
client_secret: "",
|
||||
scopes: provider.scopes.join(","),
|
||||
other_audiences: provider.other_audiences.join(","),
|
||||
redirect_uri: provider.redirect_uri,
|
||||
redirect_uri_dynamic: provider.redirect_uri_dynamic,
|
||||
claim_name: provider.claim_name,
|
||||
@@ -49,8 +50,8 @@ function trimOrEmpty(value: string) {
|
||||
return value.trim()
|
||||
}
|
||||
|
||||
function parseScopes(scopes: string) {
|
||||
return scopes
|
||||
function parseList(values: string) {
|
||||
return values
|
||||
.split(",")
|
||||
.map((item) => item.trim())
|
||||
.filter(Boolean)
|
||||
@@ -79,7 +80,7 @@ function validateForm(
|
||||
const clientId = trimOrEmpty(values.client_id)
|
||||
const clientSecret = trimOrEmpty(values.client_secret)
|
||||
const redirectUri = trimOrEmpty(values.redirect_uri)
|
||||
const scopes = parseScopes(values.scopes)
|
||||
const scopes = parseList(values.scopes)
|
||||
|
||||
if (options.requireProviderId) {
|
||||
if (!providerId) {
|
||||
@@ -124,7 +125,8 @@ function buildSavePayload(values: OidcProviderFormValues): SaveOidcConfigPayload
|
||||
display_name: trimOrEmpty(values.display_name),
|
||||
config_url: trimOrEmpty(values.config_url),
|
||||
client_id: trimOrEmpty(values.client_id),
|
||||
scopes: parseScopes(values.scopes),
|
||||
scopes: parseList(values.scopes),
|
||||
other_audiences: parseList(values.other_audiences),
|
||||
redirect_uri: trimOrEmpty(values.redirect_uri),
|
||||
redirect_uri_dynamic: values.redirect_uri_dynamic,
|
||||
claim_name: trimOrEmpty(values.claim_name),
|
||||
@@ -150,7 +152,8 @@ function buildValidatePayload(values: OidcProviderFormValues): ValidateOidcConfi
|
||||
config_url: trimOrEmpty(values.config_url),
|
||||
client_id: trimOrEmpty(values.client_id),
|
||||
client_secret: trimOrEmpty(values.client_secret),
|
||||
scopes: parseScopes(values.scopes),
|
||||
scopes: parseList(values.scopes),
|
||||
other_audiences: parseList(values.other_audiences),
|
||||
redirect_uri: trimOrEmpty(values.redirect_uri),
|
||||
redirect_uri_dynamic: values.redirect_uri_dynamic,
|
||||
}
|
||||
|
||||
@@ -244,6 +244,21 @@ export function OidcForm({
|
||||
<FieldError>{errors.scopes}</FieldError>
|
||||
</Field>
|
||||
|
||||
<Field className="md:col-span-2">
|
||||
<FieldLabel htmlFor="other_audiences">{t("Other Audiences")}</FieldLabel>
|
||||
<FieldContent>
|
||||
<Input
|
||||
id="other_audiences"
|
||||
value={values.other_audiences}
|
||||
onChange={(event) => onChange("other_audiences", event.target.value)}
|
||||
placeholder=""
|
||||
disabled={isReadOnly}
|
||||
/>
|
||||
</FieldContent>
|
||||
<FieldDescription>{t("Comma-separated audience IDs.")}</FieldDescription>
|
||||
<FieldError>{errors.other_audiences}</FieldError>
|
||||
</Field>
|
||||
|
||||
<Field orientation="responsive" className="items-start gap-3 rounded-md border p-3">
|
||||
<FieldLabel htmlFor="redirect_uri_dynamic">{t("Use Dynamic Redirect URI")}</FieldLabel>
|
||||
<FieldContent className="gap-2">
|
||||
|
||||
@@ -10,6 +10,7 @@ export interface OidcConfigProvider {
|
||||
client_id: string
|
||||
client_secret_configured: boolean
|
||||
scopes: string[]
|
||||
other_audiences: string[]
|
||||
redirect_uri: string
|
||||
redirect_uri_dynamic: boolean
|
||||
claim_name: string
|
||||
@@ -34,6 +35,7 @@ export interface SaveOidcConfigPayload {
|
||||
client_id: string
|
||||
client_secret?: string
|
||||
scopes: string[]
|
||||
other_audiences: string[]
|
||||
redirect_uri: string
|
||||
redirect_uri_dynamic: boolean
|
||||
claim_name: string
|
||||
@@ -63,6 +65,7 @@ export interface ValidateOidcConfigPayload {
|
||||
client_id: string
|
||||
client_secret: string
|
||||
scopes: string[]
|
||||
other_audiences: string[]
|
||||
redirect_uri: string
|
||||
redirect_uri_dynamic: boolean
|
||||
}
|
||||
@@ -83,6 +86,7 @@ export interface OidcProviderFormValues {
|
||||
client_id: string
|
||||
client_secret: string
|
||||
scopes: string
|
||||
other_audiences: string
|
||||
redirect_uri: string
|
||||
redirect_uri_dynamic: boolean
|
||||
claim_name: string
|
||||
@@ -104,6 +108,7 @@ export const DEFAULT_OIDC_FORM_VALUES: OidcProviderFormValues = {
|
||||
client_id: "",
|
||||
client_secret: "",
|
||||
scopes: "openid,profile,email",
|
||||
other_audiences: "",
|
||||
redirect_uri: "",
|
||||
redirect_uri_dynamic: false,
|
||||
claim_name: "groups",
|
||||
|
||||
Reference in New Issue
Block a user