Skip to content

Commit

Permalink
Support for prompt option to authenticate.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredhanson committed Nov 29, 2021
1 parent e11a373 commit c473aa2
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Added
- Support for `prompt` option to `authenticate()`.

## [0.1.0] - 2021-11-17
### Added
Expand Down
2 changes: 1 addition & 1 deletion lib/strategy.js
Expand Up @@ -297,7 +297,7 @@ Strategy.prototype.authenticate = function(req, options) {
params.scope = 'openid';
}

var prompt = this._prompt;
var prompt = options.prompt || this._prompt;
if (prompt) {
params.prompt = prompt;
}
Expand Down
31 changes: 31 additions & 0 deletions test/strategy.authenticate.test.js
Expand Up @@ -100,6 +100,37 @@ describe('Strategy', function() {
.authenticate({ scope: 'profile email' });
}); // should redirect with scope as string

it('should redirect with prompt parameter', function(done) {
var strategy = new Strategy({
issuer: 'https://server.example.com',
authorizationURL: 'https://server.example.com/authorize',
tokenURL: 'https://server.example.com/token',
clientID: 's6BhdRkqt3',
clientSecret: 'some_secret12345',
callbackURL: 'https://client.example.org/cb'
}, function() {});

chai.passport.use(strategy)
.request(function(req) {
req.session = {};
})
.redirect(function(url) {
var l = uri.parse(url, true);
var state = l.query.state;

expect(url).to.equal('https://server.example.com/authorize?response_type=code&client_id=s6BhdRkqt3&redirect_uri=https%3A%2F%2Fclient.example.org%2Fcb&scope=openid&prompt=login&state=' + encodeURIComponent(state));
expect(state).to.have.length(24);
expect(this.session['openidconnect:server.example.com']).to.deep.equal({
state: {
handle: state
}
});
done();
})
.error(done)
.authenticate({ prompt: 'login' });
}); // should redirect with prompt parameter

it('should redirect with display parameter', function(done) {
var strategy = new Strategy({
issuer: 'https://server.example.com',
Expand Down

0 comments on commit c473aa2

Please sign in to comment.