-- auth_oidc_method entries are the current oidc auth methods configured for
-- existing scopes.
createtableauth_oidc_method(
public_idwt_public_id
primarykey,
scope_idwt_scope_id
notnull,
namewt_name,
descriptionwt_description,
create_timewt_timestamp,
update_timewt_timestamp,
versionwt_version,
statetextnotnull
referencesauth_oidc_method_state_enm(name)
ondeleterestrict
onupdatecascade,
discovery_urlwt_urlnotnull,-- oidc discovery URL without any .well-known component
client_idtextnotnull-- oidc client identifier issued by the oidc provider.
constraintclient_id_not_empty
check(length(trim(client_id))>0),
client_secretbyteanotnull,-- encrypted oidc client secret issued by the oidc provider.
key_idwt_private_idnotnull-- key used to encrypt entries via wrapping wrapper.
referenceskms_oidc_key_version(private_id)
ondeleterestrict
onupdatecascade,
max_ageintnotnull-- the allowable elapsed time in secs since the last time the user was authenticated. zero is allowed and should force the user to be re-authenticated.
constraintmax_age_equal_or_greater_than_zero
check(max_age>=0),
foreignkey(scope_id,public_id)
referencesauth_method(scope_id,public_id)
ondeletecascade
onupdatecascade,
unique(scope_id,name),
unique(scope_id,public_id),
unique(scope_id,discovery_url,client_id)-- a client_id must be unique for a provider within a scope.
);
-- auth_oidc_signing_alg entries are the signing algorithms allowed for an oidc
-- auth method. There must be at least one allowed alg for each oidc auth method.
createtableauth_oidc_signing_alg(
oidc_method_idwt_public_id
referencesauth_oidc_method(public_id)
ondeletecascade
onupdatecascade,
signing_alg_nametext
referencesauth_oidc_signing_alg_enm(name)
ondeleterestrict
onupdatecascade,
primarykey(oidc_method_id,signing_alg_name)
);
-- auth_oidc_callback_url entries are the callback URLs allowed for a specific
-- oidc auth method. There must be at least one callback url for each oidc auth
-- method.
createtableauth_oidc_callback_url(
oidc_method_idwt_public_id
referencesauth_oidc_method(public_id)
ondeletecascade
onupdatecascade,
callback_urlwt_urlnotnull
);
-- auth_oidc_aud_claim entries are the audience claims for a specific oidc auth
-- method. There can be 0 or more for each parent oidc auth method. If an auth
-- method has any aud claims, an ID token must contain one of them to be valid.
createtableauth_oidc_aud_claim(
oidc_method_idwt_public_id
referencesauth_oidc_method(public_id)
ondeletecascade
onupdatecascade,
aud_claimtextnotnull
constraintaud_claim_must_not_be_empty
check(length(trim(aud_claim))>0)
constraintaud_claim_must_be_less_than_1024_chars
check(length(trim(aud_claim))<1024),
primarykey(oidc_method_id,aud_claim)
);
-- auth_oidc_certificate entries are optional PEM encoded x509 certificates.
-- Each entry is a single certificate. An oidc auth method may have 0 or more
-- of these optional x509s. If an auth method has any cert entries, they are
-- used as trust anchors when connecting to the auth method's oidc provider
-- (instead of the host system's cert chain).
createtableauth_oidc_certificate(
oidc_method_idwt_public_id
referencesauth_oidc_method(public_id)
ondeletecascade
onupdatecascade,
certificatebyteanotnull,
primarykey(oidc_method_id,certificate)
);
createtableauth_oidc_account(
public_idwt_public_id
primarykey,
auth_method_idwt_public_id
notnull,
-- NOTE(mgaffney): The scope_id type is not wt_scope_id because the domain
-- check is executed before the insert trigger which retrieves the scope_id
-- causing an insert to fail.
scope_idtextnotnull,
namewt_name,
descriptionwt_description,
create_timewt_timestamp,
update_timewt_timestamp,
versionwt_version,
issuer_idwt_urlnotnull,-- case-sensitive URL that maps to an id_token's iss claim
subject_idtextnotnull-- case-senstive string that maps to an id_token's sub claim
constraintsubject_id_must_not_be_empty
check(
length(trim(subject_id))>0
)
constraintsubject_id_must_be_less_than_256_chars
check(
length(trim(subject_id))<=255-- length limit per OIDC spec
),
full_namewt_full_name,-- may be null and maps to an id_token's name claim
emailwt_email,-- may be null and maps to the id_token's email claim