Skip to content

Commit

Permalink
chore: update saml application configs table schema
Browse files Browse the repository at this point in the history
  • Loading branch information
darcyYe committed Nov 20, 2024
1 parent 9c545f3 commit 5554cf6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ const alteration: AlterationScript = {
tenant_id varchar(21) not null
references tenants (id) on update cascade on delete cascade,
attribute_mapping jsonb /* @use SamlAttributeMapping */ not null default '{}'::jsonb,
sp_metadata jsonb /* @use SamlSpMetadata */ not null,
entity_id varchar(128) not null,
acs_url jsonb /* @use SamlAcsUrl */ not null,
primary key (tenant_id, application_id),
constraint application_type
check (check_application_type(application_id, 'SAML'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,17 @@ export const samlAttributeMappingGuard = z.record(
z.string()
) satisfies z.ZodType<SamlAttributeMapping>;

// Only support SP HTTP-POST binding for now.
export enum BindingType {
POST = 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST',
REDIRECT = 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
}

export type SamlSpMetadata = {
entityId: string;
acsUrl: {
binding: BindingType;
url: string;
};
export type SamlAcsUrl = {
binding?: BindingType;
url: string;
};

export const samlSpMetadataGuard = z.object({
entityId: z.string(),
acsUrl: z.object({
binding: z.nativeEnum(BindingType),
url: z.string(),
}),
}) satisfies ToZodObject<SamlSpMetadata>;
export const samlAcsUrlGuard = z.object({
binding: z.nativeEnum(BindingType).optional().default(BindingType.POST),
url: z.string(),
}) satisfies ToZodObject<SamlAcsUrl>;
3 changes: 2 additions & 1 deletion packages/schemas/tables/saml_application_configs.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ create table saml_application_configs (
tenant_id varchar(21) not null
references tenants (id) on update cascade on delete cascade,
attribute_mapping jsonb /* @use SamlAttributeMapping */ not null default '{}'::jsonb,
sp_metadata jsonb /* @use SamlSpMetadata */ not null,
entity_id varchar(128) not null,
acs_url jsonb /* @use SamlAcsUrl */ not null,
primary key (tenant_id, application_id),
constraint application_type
check (check_application_type(application_id, 'SAML'))
Expand Down

0 comments on commit 5554cf6

Please sign in to comment.