-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(authentication-service): added the logic for rotation of keys wi…
…th database 2034
- Loading branch information
1 parent
ad24682
commit ee0c517
Showing
34 changed files
with
974 additions
and
215 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -61,4 +61,6 @@ AZURE_AUTH_COOKIE_KEY= | |
|
||
#iv is 12 bit | ||
|
||
AZURE_AUTH_COOKIE_IV= | ||
AZURE_AUTH_COOKIE_IV= | ||
|
||
MAX_JWT_KEYS=2 |
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 |
---|---|---|
|
@@ -83,3 +83,5 @@ AUTH0_DOMAIN= | |
AUTH0_CLIENT_ID= | ||
AUTH0_CLIENT_SECRET= | ||
AUTH0_CALLBACK_URL= | ||
|
||
MAX_JWT_KEYS= |
59 changes: 59 additions & 0 deletions
59
.../authentication-service/migrations/mysql/migrations/20241105074844-add-jwt-keys-schema.js
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,59 @@ | ||
'use strict'; | ||
|
||
var dbm; | ||
var type; | ||
var seed; | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var Promise; | ||
|
||
/** | ||
* We receive the dbmigrate dependency from dbmigrate initially. | ||
* This enables us to not have to rely on NODE_PATH. | ||
*/ | ||
exports.setup = function (options, seedLink) { | ||
dbm = options.dbmigrate; | ||
type = dbm.dataType; | ||
seed = seedLink; | ||
Promise = options.Promise; | ||
}; | ||
|
||
exports.up = function (db) { | ||
var filePath = path.join( | ||
__dirname, | ||
'sqls', | ||
'20241105074844-add-jwt-keys-schema-up.sql', | ||
); | ||
return new Promise(function (resolve, reject) { | ||
fs.readFile(filePath, {encoding: 'utf-8'}, function (err, data) { | ||
if (err) return reject(err); | ||
console.log('received data: ' + data); | ||
|
||
resolve(data); | ||
}); | ||
}).then(function (data) { | ||
return db.runSql(data); | ||
}); | ||
}; | ||
|
||
exports.down = function (db) { | ||
var filePath = path.join( | ||
__dirname, | ||
'sqls', | ||
'20241105074844-add-jwt-keys-schema-down.sql', | ||
); | ||
return new Promise(function (resolve, reject) { | ||
fs.readFile(filePath, {encoding: 'utf-8'}, function (err, data) { | ||
if (err) return reject(err); | ||
console.log('received data: ' + data); | ||
|
||
resolve(data); | ||
}); | ||
}).then(function (data) { | ||
return db.runSql(data); | ||
}); | ||
}; | ||
|
||
exports._meta = { | ||
version: 1, | ||
}; |
1 change: 1 addition & 0 deletions
1
...tion-service/migrations/mysql/migrations/sqls/20241105074844-add-jwt-keys-schema-down.sql
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 @@ | ||
DROP TABLE main.jwt_keys; |
7 changes: 7 additions & 0 deletions
7
...cation-service/migrations/mysql/migrations/sqls/20241105074844-add-jwt-keys-schema-up.sql
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,7 @@ | ||
CREATE TABLE main.jwt_keys ( | ||
id INT AUTO_INCREMENT PRIMARY KEY, | ||
key_id VARCHAR(100) UNIQUE NOT NULL, | ||
public_key TEXT NOT NULL, -- Public key in PEM format | ||
private_key TEXT NOT NULL, -- Private key in PEM format | ||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP | ||
); |
59 changes: 59 additions & 0 deletions
59
...ces/authentication-service/migrations/pg/migrations/20241105074844-add-jwt-keys-schema.js
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,59 @@ | ||
'use strict'; | ||
|
||
var dbm; | ||
var type; | ||
var seed; | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var Promise; | ||
|
||
/** | ||
* We receive the dbmigrate dependency from dbmigrate initially. | ||
* This enables us to not have to rely on NODE_PATH. | ||
*/ | ||
exports.setup = function (options, seedLink) { | ||
dbm = options.dbmigrate; | ||
type = dbm.dataType; | ||
seed = seedLink; | ||
Promise = options.Promise; | ||
}; | ||
|
||
exports.up = function (db) { | ||
var filePath = path.join( | ||
__dirname, | ||
'sqls', | ||
'20241105074844-add-jwt-keys-schema-up.sql', | ||
); | ||
return new Promise(function (resolve, reject) { | ||
fs.readFile(filePath, {encoding: 'utf-8'}, function (err, data) { | ||
if (err) return reject(err); | ||
console.log('received data: ' + data); | ||
|
||
resolve(data); | ||
}); | ||
}).then(function (data) { | ||
return db.runSql(data); | ||
}); | ||
}; | ||
|
||
exports.down = function (db) { | ||
var filePath = path.join( | ||
__dirname, | ||
'sqls', | ||
'20241105074844-add-jwt-keys-schema-down.sql', | ||
); | ||
return new Promise(function (resolve, reject) { | ||
fs.readFile(filePath, {encoding: 'utf-8'}, function (err, data) { | ||
if (err) return reject(err); | ||
console.log('received data: ' + data); | ||
|
||
resolve(data); | ||
}); | ||
}).then(function (data) { | ||
return db.runSql(data); | ||
}); | ||
}; | ||
|
||
exports._meta = { | ||
version: 1, | ||
}; |
1 change: 1 addition & 0 deletions
1
...ication-service/migrations/pg/migrations/sqls/20241105074844-add-jwt-keys-schema-down.sql
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 @@ | ||
DROP TABLE main.jwt_keys; |
7 changes: 7 additions & 0 deletions
7
...ntication-service/migrations/pg/migrations/sqls/20241105074844-add-jwt-keys-schema-up.sql
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,7 @@ | ||
CREATE TABLE main.jwt_keys ( | ||
id SERIAL PRIMARY KEY, | ||
key_id VARCHAR(100) UNIQUE NOT NULL, | ||
public_key TEXT NOT NULL, -- Public key in PEM format | ||
private_key TEXT NOT NULL, -- Private key in PEM format | ||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, | ||
); |
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.