mirror of
https://github.com/logto-io/logto.git
synced 2024-12-30 20:33:54 -05:00
refactor: remove oidc_client_id
This commit is contained in:
parent
89cf297eff
commit
a86f57a466
4 changed files with 7 additions and 18 deletions
|
@ -7,17 +7,14 @@ import {
|
|||
revokeInstanceByGrantId,
|
||||
upsertInstance,
|
||||
} from '@/queries/oidc-model-instance';
|
||||
import { findApplicationByClientId } from '@/queries/application';
|
||||
import { findApplicationById } from '@/queries/application';
|
||||
import { ApplicationDBEntry } from '@logto/schemas';
|
||||
|
||||
export default function postgresAdapter(modelName: string): ReturnType<AdapterFactory> {
|
||||
if (modelName === 'Client') {
|
||||
const reject = async () => Promise.reject(new Error('Not implemented'));
|
||||
const tranpileClient = ({
|
||||
oidcClientId,
|
||||
oidcClientMetadata,
|
||||
}: ApplicationDBEntry): AllClientMetadata => ({
|
||||
client_id: oidcClientId,
|
||||
const tranpileClient = ({ id, oidcClientMetadata }: ApplicationDBEntry): AllClientMetadata => ({
|
||||
client_id: id,
|
||||
grant_types: ['authorization_code', 'refresh_token'],
|
||||
token_endpoint_auth_method: 'none',
|
||||
...oidcClientMetadata,
|
||||
|
@ -25,7 +22,7 @@ export default function postgresAdapter(modelName: string): ReturnType<AdapterFa
|
|||
|
||||
return {
|
||||
upsert: reject,
|
||||
find: async (id) => tranpileClient(await findApplicationByClientId(id)),
|
||||
find: async (id) => tranpileClient(await findApplicationById(id)),
|
||||
findByUserCode: reject,
|
||||
findByUid: reject,
|
||||
consume: reject,
|
||||
|
|
|
@ -5,9 +5,9 @@ import { sql } from 'slonik';
|
|||
|
||||
const { table, fields } = convertToIdentifiers(Applications);
|
||||
|
||||
export const findApplicationByClientId = async (clientId: string) =>
|
||||
export const findApplicationById = async (id: string) =>
|
||||
pool.one<ApplicationDBEntry>(sql`
|
||||
select ${sql.join(Object.values(fields), sql`, `)}
|
||||
from ${table}
|
||||
where ${fields.oidcClientId}=${clientId}
|
||||
where ${fields.id}=${id}
|
||||
`);
|
||||
|
|
|
@ -8,7 +8,6 @@ export type ApplicationDBEntry = {
|
|||
id: string;
|
||||
name: string;
|
||||
type: ApplicationType;
|
||||
oidcClientId: string;
|
||||
oidcClientMetadata: OidcClientMetadata;
|
||||
createdAt: number;
|
||||
};
|
||||
|
@ -19,9 +18,8 @@ export const Applications = Object.freeze({
|
|||
id: 'id',
|
||||
name: 'name',
|
||||
type: 'type',
|
||||
oidcClientId: 'oidc_client_id',
|
||||
oidcClientMetadata: 'oidc_client_metadata',
|
||||
createdAt: 'created_at',
|
||||
},
|
||||
fieldKeys: ['id', 'name', 'type', 'oidcClientId', 'oidcClientMetadata', 'createdAt'],
|
||||
fieldKeys: ['id', 'name', 'type', 'oidcClientMetadata', 'createdAt'],
|
||||
} as const);
|
||||
|
|
|
@ -4,13 +4,7 @@ create table applications (
|
|||
id varchar(128) not null,
|
||||
name varchar(256) not null,
|
||||
type application_type not null,
|
||||
oidc_client_id varchar(128) not null,
|
||||
oidc_client_metadata jsonb /* @use OidcClientMetadata */ not null,
|
||||
created_at bigint not null default(extract(epoch from now())),
|
||||
primary key (id)
|
||||
);
|
||||
|
||||
create index applications__oidc_client_id
|
||||
on applications (
|
||||
oidc_client_id
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue