Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #SB-21181 fix: Added offline token verification call before server gets started #229

Open
wants to merge 4 commits into
base: release-3.6.0
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ var configUtil = require('sb-config-util')
var _ = require('lodash')
var logger = require('sb_logger_util_v2')

const { loadTokenPublicKeys } = require('sb_api_interceptor')

const contentProvider = require('sb_content_provider_util')
var contentMetaProvider = require('./contentMetaFilter')
// TODO below configuration should to be refactored in a seperate file
Expand Down Expand Up @@ -58,7 +60,9 @@ const isHealthCheckEnabled = process.env.sunbird_health_check_enable || 'true'
const contentServiceLocalBaseUrl = process.env.sunbird_content_service_local_base_url ? process.env.sunbird_content_service_local_base_url : 'http://knowledge-mw-service:5000'
const sunbirdGzipEnable = process.env.sunbird_gzip_enable || 'true'

configUtil.setContentProviderApi(contentProviderApiConfig.API)
const kidTokenPublicKeyBasePath = process.env.sunbird_kid_public_key_base_path || '/keys/'

configUtil.setContentProviderApi(contentProviderApiConfig.API)
configUtil.setConfig('CONTENT_SERVICE_BASE_URL', contentServiceBaseUrl)
configUtil.setConfig('CONTENT_SERVICE_AUTH_TOKEN', contentServiceAuthToken)
configUtil.setConfig('ASSESSMENT_SERVICE_BASE_URL', assessmentServiceBaseUrl)
Expand Down Expand Up @@ -178,7 +182,8 @@ require('./routes/lockRoutes')(app)
// this middleware route add after all the routes
require('./middlewares/proxy.middleware')(app)

function startServer () {
async function startServer () {
await loadTokenPublicKeys(path.join(__dirname, kidTokenPublicKeyBasePath));
this.server = http.createServer(app).listen(port, function () {
logger.info({ msg: `server running at PORT ${port}` })
logger.debug({ msg: `server started at ${new Date()}` })
Expand Down