Skip to content
Open
2 changes: 1 addition & 1 deletion config/env/integrationtest.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ module.exports = {
},
userInfoSource: 'tokenset_claims',
opts: {
issuer: 'http://keycloak:8080/realms/redbox/',
issuer: 'http://keycloak:8080/realms/redbox',
client: {
client_id: 'redbox',
client_secret: 'w2snramgGaqehPiujV695iUfKmZAJ147',
Expand Down
21 changes: 21 additions & 0 deletions config/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,26 @@ module.exports.http = {
next();
},

oidcMiddleware: function(req, res, next) {
// Check if this is an OIDC initiation request
if (req.path === '/user/begin_oidc' || req.path.startsWith('/user/begin_oidc/')) {
sails.log.verbose(`OIDC middleware: At OIDC begin flow, redirecting...`);

let passportIdentifier = 'oidc';
// Extract ID from path if present (e.g., /user/begin_oidc/123)
const pathParts = req.path.split('/');
if (pathParts.length >= 4 && pathParts[3]) {
passportIdentifier = `oidc-${pathParts[3]}`;
}

// Use passport.authenticate as middleware with next function
sails.config.passport.authenticate(passportIdentifier)(req, res, next);
} else {
// Not an OIDC request, continue to next middleware
next();
}
},

order: [
'cacheControl',
'redirectNoCacheHeaders',
Expand All @@ -100,6 +120,7 @@ module.exports.http = {
'compress',
'methodOverride',
'poweredBy',
'oidcMiddleware',
'router',
'translate',
'brandingAndPortalAwareStaticRouter',
Expand Down
10 changes: 0 additions & 10 deletions config/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,16 +144,6 @@ module.exports.routes = {
'HEAD /user/begin_oidc': {
policy: 'disallowedHeadRequestHandler'
},
'get /user/begin_oidc': {
controller: 'UserController',
action: 'beginOidc',
csrf: false
},
// 'post /user/begin_oidc': {
// controller: 'UserController',
// action: 'beginOidc',
// csrf: false
// },
'get /user/info': 'UserController.info',
'get /:branding/:portal/user/info': 'UserController.info',
'get /:branding/:portal/user/login': 'UserController.login',
Expand Down
77 changes: 21 additions & 56 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"nodemailer": "^7.0.6",
"numeral": "^2.0.6",
"nyc": "^17.1.0",
"openid-client": "^5.7.0",
"openid-client": "^6.7.1",
"passport": "^0.7.0",
"passport-http-bearer": "^1.0.1",
"passport-jwt": "^4.0.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,22 @@ headers {
Authorization: Bearer {{token}}
}

script:pre-request {
// Generate unique username/email once per run and store in env vars
var suffix = Date.now().toString().slice(-6) + Math.floor(Math.random()*100).toString().padStart(2,'0');
var username = 'apiresearcher' + suffix;
var email = username + '@redboxresearchdata.com.au';
bru.setEnvVar('apiTestUsername', username);
bru.setEnvVar('apiTestEmail', email);
}

body:json {
{
"username": "apiresearcher34",
"name": "researcher created via API",
"email": "apiresearcher34@redboxresearchdata.com.au",
"password": "a12345672A!",
"roles": ["Admin","Researcher","Librarian"]
"username": "{{apiTestUsername}}",
"name": "researcher created via API",
"email": "{{apiTestEmail}}",
"password": "a12345672A!",
"roles": ["Admin","Researcher","Librarian"]
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ body:json {
{
"id": "{{apiUserId}}",
"name": "researcher created via API - modified",
"email": "apiresearcher@redboxresearchdata.com.au",
"email": "{{apiTestEmail}}",
"password": "a12345672A!"
}
}
Expand Down
14 changes: 11 additions & 3 deletions test/bruno/1 - REST API/3 - Search/Search Mint Internal Solr.bru
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,17 @@ tests {

test("Test response format", function () {
var jsonData = res.getBody();
expect(jsonData[0]).to.have.property('fullName');
expect(jsonData[0]).to.have.property('email');
expect(jsonData[0]).to.have.property('orcid');
// Bruno v2 may already parse JSON; if not, attempt parsing
if (typeof jsonData === 'string') {
try { jsonData = JSON.parse(jsonData); } catch(e) {}
}
expect(jsonData).to.be.an('array');
if (jsonData.length > 0) {
expect(jsonData[0]).to.be.an('object');
expect(jsonData[0]).to.have.property('fullName');
expect(jsonData[0]).to.have.property('email');
expect(jsonData[0]).to.have.property('orcid');
}
});

}
Loading