-
Notifications
You must be signed in to change notification settings - Fork 372
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
505 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
declare module 'passport-openidconnect' { | ||
import { Strategy as PassportStrategy } from 'passport-strategy'; | ||
import express = require('express'); | ||
|
||
interface IStrategyOptions { | ||
issuer: string; | ||
authorizationURL: string; | ||
tokenURL: string; | ||
userInfoURL: string; | ||
clientID: string; | ||
clientSecret: string; | ||
callbackURL: string; | ||
scope?: string; | ||
passReqToCallback?: false | undefined; | ||
} | ||
|
||
interface IStrategyOptionsWithRequest { | ||
issuer: string; | ||
authorizationURL: string; | ||
tokenURL: string; | ||
clientID: string; | ||
userInfoURL: string; | ||
clientSecret: string; | ||
callbackURL: string; | ||
scope?: string; | ||
passReqToCallback: true; | ||
} | ||
|
||
interface IVerifyOptions { | ||
message: string; | ||
} | ||
|
||
interface VerifyFunctionWithRequest { | ||
( | ||
req: express.Request, | ||
issuer: string, | ||
profile: any, | ||
done: (error: any, user?: any, options?: IVerifyOptions) => void, | ||
): void; | ||
} | ||
|
||
interface VerifyFunction { | ||
( | ||
issuer: string, | ||
profile: any, | ||
done: (error: any, user?: any, options?: IVerifyOptions) => void, | ||
): void; | ||
} | ||
export declare class Strategy extends PassportStrategy { | ||
constructor( | ||
options: IStrategyOptionsWithRequest, | ||
verify: VerifyFunctionWithRequest, | ||
); | ||
constructor(options: IStrategyOptions, verify: VerifyFunction); | ||
constructor(verify: VerifyFunction); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
packages/backend/src/database/migrations/20220727122405_drop_issuer_fk.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { Knex } from 'knex'; | ||
|
||
export async function up(knex: Knex): Promise<void> { | ||
if (await knex.schema.hasTable('openid_identities')) { | ||
await knex.schema.alterTable('openid_identities', (tableBuilder) => { | ||
tableBuilder.dropForeign('issuer'); | ||
tableBuilder | ||
.string('issuer_type') | ||
.notNullable() | ||
.defaultTo('google'); | ||
}); | ||
await knex.schema.alterTable('openid_identities', (tableBuilder) => { | ||
tableBuilder.string('issuer_type').notNullable().alter(); // drop default | ||
}); | ||
} | ||
await knex.schema.dropTableIfExists('openid_issuers'); | ||
} | ||
|
||
export async function down(knex: Knex): Promise<void> { | ||
if (!(await knex.schema.hasTable('openid_issuers'))) { | ||
await knex.schema.createTable('openid_issuers', (tableBuilder) => { | ||
tableBuilder.text('issuer').primary(); | ||
}); | ||
await knex('openid_issuers').insert({ | ||
issuer: 'https://accounts.google.com', | ||
}); | ||
} | ||
if (await knex.schema.hasTable('openid_identities')) { | ||
await knex('openid_identities') | ||
.delete() | ||
.whereNot('issuer', 'https://accounts.google.com'); | ||
await knex.schema.alterTable('openid_identities', (tableBuilder) => { | ||
tableBuilder.dropPrimary(); | ||
tableBuilder.dropColumn('issuer_type'); | ||
}); | ||
await knex.schema.alterTable('openid_identities', (tableBuilder) => { | ||
tableBuilder | ||
.text('issuer') | ||
.notNullable() | ||
.references('issuer') | ||
.inTable('openid_issuers') | ||
.alter(); | ||
tableBuilder.primary(['issuer', 'subject']); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.