Skip to content

Commit e1d69cf

Browse files
committed
fix: extend interactionDetails to allow (req, res)
fixes #517
1 parent e928920 commit e1d69cf

File tree

6 files changed

+21
-17
lines changed

6 files changed

+21
-17
lines changed

certification/configuration.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ module.exports = {
6363
features: {
6464
backchannelLogout: { enabled: true },
6565
devInteractions: { enabled: false },
66-
ietfJWTAccessTokenProfile: { enabled: true },
6766
mTLS: {
6867
enabled: true,
6968
certificateBoundAccessTokens: true,

docs/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,17 +185,17 @@ packing the results. See them used in the [step-by-step](https://github.com/panv
185185
or [in-repo](/example) examples.
186186

187187

188-
**`#provider.interactionDetails(req)`**
188+
**`#provider.interactionDetails(req, res)`**
189189
```js
190190
// with express
191191
expressApp.get('/interaction/:uid', async (req, res) => {
192-
const details = await provider.interactionDetails(req);
192+
const details = await provider.interactionDetails(req, res);
193193
// ...
194194
});
195195

196196
// with koa
197197
router.get('/interaction/:uid', async (ctx, next) => {
198-
const details = await provider.interactionDetails(ctx.req);
198+
const details = await provider.interactionDetails(ctx.req, ctx.res);
199199
// ...
200200
});
201201
```

example/routes/express.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ module.exports = (app, provider) => {
4848
try {
4949
const {
5050
uid, prompt, params, session,
51-
} = await provider.interactionDetails(req);
51+
} = await provider.interactionDetails(req, res);
5252

5353
const client = await provider.Client.find(params.client_id);
5454

@@ -113,7 +113,7 @@ module.exports = (app, provider) => {
113113

114114
app.post('/interaction/:uid/login', setNoCache, body, async (req, res, next) => {
115115
try {
116-
const { prompt: { name } } = await provider.interactionDetails(req);
116+
const { prompt: { name } } = await provider.interactionDetails(req, res);
117117
assert.equal(name, 'login');
118118
const account = await Account.findByLogin(req.body.login);
119119

@@ -133,7 +133,7 @@ module.exports = (app, provider) => {
133133

134134
app.post('/interaction/:uid/continue', setNoCache, body, async (req, res, next) => {
135135
try {
136-
const interaction = await provider.interactionDetails(req);
136+
const interaction = await provider.interactionDetails(req, res);
137137
const { prompt: { name, details } } = interaction;
138138
assert.equal(name, 'select_account');
139139

@@ -157,7 +157,7 @@ module.exports = (app, provider) => {
157157

158158
app.post('/interaction/:uid/confirm', setNoCache, body, async (req, res, next) => {
159159
try {
160-
const { prompt: { name, details } } = await provider.interactionDetails(req);
160+
const { prompt: { name, details } } = await provider.interactionDetails(req, res);
161161
assert.equal(name, 'consent');
162162

163163
const consent = {};

example/routes/koa.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ module.exports = (provider) => {
4444
router.get('/interaction/:uid', async (ctx, next) => {
4545
const {
4646
uid, prompt, params, session,
47-
} = await provider.interactionDetails(ctx.req);
47+
} = await provider.interactionDetails(ctx.req, ctx.res);
4848
const client = await provider.Client.find(params.client_id);
4949

5050
switch (prompt.name) {
@@ -113,7 +113,7 @@ module.exports = (provider) => {
113113
router.get('/interaction/callback/google', (ctx) => ctx.render('repost', { provider: 'google', layout: false }));
114114

115115
router.post('/interaction/:uid/login', body, async (ctx) => {
116-
const { prompt: { name } } = await provider.interactionDetails(ctx.req);
116+
const { prompt: { name } } = await provider.interactionDetails(ctx.req, ctx.res);
117117
assert.equal(name, 'login');
118118

119119
const account = await Account.findByLogin(ctx.request.body.login);
@@ -132,7 +132,7 @@ module.exports = (provider) => {
132132
});
133133

134134
router.post('/interaction/:uid/federated', body, async (ctx) => {
135-
const { prompt: { name } } = await provider.interactionDetails(ctx.req);
135+
const { prompt: { name } } = await provider.interactionDetails(ctx.req, ctx.res);
136136
assert.equal(name, 'login');
137137

138138
const path = `/interaction/${ctx.params.uid}/federated`;
@@ -177,7 +177,7 @@ module.exports = (provider) => {
177177
});
178178

179179
router.post('/interaction/:uid/continue', body, async (ctx) => {
180-
const interaction = await provider.interactionDetails(ctx.req);
180+
const interaction = await provider.interactionDetails(ctx.req, ctx.res);
181181
const { prompt: { name, details } } = interaction;
182182
assert.equal(name, 'select_account');
183183

@@ -199,7 +199,7 @@ module.exports = (provider) => {
199199
});
200200

201201
router.post('/interaction/:uid/confirm', body, async (ctx) => {
202-
const { prompt: { name, details } } = await provider.interactionDetails(ctx.req);
202+
const { prompt: { name, details } } = await provider.interactionDetails(ctx.req, ctx.res);
203203
assert.equal(name, 'consent');
204204

205205
const consent = {};

lib/actions/interaction.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ your configuration is not in effect');
4343
async function interactionRender(ctx, next) {
4444
const {
4545
uid, prompt, params, session,
46-
} = await provider.interactionDetails(ctx.req);
46+
} = await provider.interactionDetails(ctx.req, ctx.res);
4747
const client = await provider.Client.find(params.client_id);
4848

4949
let view;
@@ -102,7 +102,7 @@ your configuration is not in effect');
102102
parseBody,
103103
async function interactionSubmit(ctx, next) {
104104
ctx.oidc.uid = ctx.params.uid;
105-
const { prompt: { name } } = await provider.interactionDetails(ctx.req);
105+
const { prompt: { name } } = await provider.interactionDetails(ctx.req, ctx.res);
106106
switch (ctx.oidc.body.prompt) { // eslint-disable-line default-case
107107
case 'login': {
108108
assert.equal(name, 'login');

lib/provider.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,13 @@ class Provider extends events.EventEmitter {
206206
* @name interactionDetails
207207
* @api public
208208
*/
209-
async interactionDetails(req) {
210-
return getInteraction.call(this, req);
209+
async interactionDetails(req, res) {
210+
/* istanbul ignore if */
211+
if (typeof res === 'undefined') { // TODO: in v7.x deprecate only req
212+
return getInteraction.call(this, req);
213+
}
214+
215+
return getInteraction.call(this, req, res);
211216
}
212217

213218
/**

0 commit comments

Comments
 (0)