Skip to content

Commit

Permalink
Drop domains, multi-connections. Closes #3572. Closes #3573. Closes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
hueniverse committed Sep 15, 2017
1 parent e4b2780 commit 6447554
Show file tree
Hide file tree
Showing 38 changed files with 1,002 additions and 4,027 deletions.
2 changes: 1 addition & 1 deletion API.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 16.6.x API Reference
# 17.0.x API Reference

- [Server](#server)
- [`new Server([options])`](#new-serveroptions)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Lead Maintainer: [Eran Hammer](https://github.com/hueniverse)
authentication, and other essential facilities for building web and services applications. **hapi** enables
developers to focus on writing reusable application logic in a highly modular and prescriptive approach.

Development version: **16.6.x** ([release notes](https://github.com/hapijs/hapi/issues?labels=release+notes&page=1&state=closed))
Development version: **17.0.x** ([release notes](https://github.com/hapijs/hapi/issues?labels=release+notes&page=1&state=closed))
[![Build Status](https://secure.travis-ci.org/hapijs/hapi.svg?branch=master)](http://travis-ci.org/hapijs/hapi)

For the latest updates, [change log](http://hapijs.com/updates), and release information visit [hapijs.com](http://hapijs.com) and follow [@hapijs](https://twitter.com/hapijs) on twitter. If you have questions, please open an issue in the
Expand Down
39 changes: 14 additions & 25 deletions lib/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ const Schema = require('./schema');
const internals = {};


exports = module.exports = internals.Auth = function (connection) {
exports = module.exports = internals.Auth = function (server) {

this.connection = connection;
this.server = server;
this._schemes = {};
this._strategies = {};
this.settings = {
Expand Down Expand Up @@ -47,7 +47,7 @@ internals.Auth.prototype.strategy = function (name, scheme /*, mode, options */)
Hoek.assert(scheme, 'Authentication strategy', name, 'missing scheme');
Hoek.assert(this._schemes[scheme], 'Authentication strategy', name, 'uses unknown scheme:', scheme);

const server = this.connection.server._clone([this.connection], '');
const server = this.server._clone('');
const strategy = this._schemes[scheme](server, options);

Hoek.assert(strategy.authenticate, 'Invalid scheme:', name, 'missing authenticate() method');
Expand Down Expand Up @@ -193,14 +193,14 @@ internals.Auth.prototype.lookup = function (route) {

internals.Auth.authenticate = function (request, next) {

const auth = request.connection.auth;
const auth = request.server.auth;
return auth._authenticate(request, next);
};


internals.Auth.access = function (request, route) {

const auth = request.connection.auth;
const auth = request.server.auth;
const config = auth.lookup(route);
if (!config) {
return true;
Expand Down Expand Up @@ -235,7 +235,7 @@ internals.Auth.payload = function (request, next) {
return next();
}

const auth = request.connection.auth;
const auth = request.server.auth;
const strategy = auth._strategies[request.auth.strategy];

if (!strategy.methods.payload) {
Expand All @@ -260,17 +260,14 @@ internals.Auth.payload = function (request, next) {
return next(response);
};

request._protect.run(finalize, (exit) => {

const reply = request.server._replier.interface(request, strategy.realm, {}, exit);
strategy.methods.payload(request, reply);
});
const reply = request.server._replier.interface(request, strategy.realm, {}, finalize);
strategy.methods.payload(request, reply);
};


internals.Auth.response = function (request, next) {

const auth = request.connection.auth;
const auth = request.server.auth;
const config = auth.lookup(request.route);
if (!config ||
!request.auth.isAuthenticated ||
Expand All @@ -284,11 +281,8 @@ internals.Auth.response = function (request, next) {
return next();
}

request._protect.run(next, (exit) => {

const reply = request.server._replier.interface(request, strategy.realm, {}, exit);
strategy.methods.response(request, reply);
});
const reply = request.server._replier.interface(request, strategy.realm, {}, next);
strategy.methods.response(request, reply);
};


Expand Down Expand Up @@ -329,14 +323,9 @@ internals.Authenticator = class {
if (this.current < config.strategies.length) {
const name = config.strategies[this.current];
const after = (err, data) => this.validate(err, data, next);
request._protect.run(after, (exit) => {

const strategy = this.manager._strategies[name];
const reply = request.server._replier.interface(request, strategy.realm, { data: true }, (err) => exit(err, reply._data));
strategy.methods.authenticate(request, reply);
});

return;
const strategy = this.manager._strategies[name];
const reply = request.server._replier.interface(request, strategy.realm, { data: true }, (err) => after(err, reply._data));
return strategy.methods.authenticate(request, reply);
}

// No more strategies
Expand Down
2 changes: 1 addition & 1 deletion lib/compression.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ internals.Compression.prototype.accept = function (request) {
internals.Compression.prototype.encoding = function (response) {

const request = response.request;
if (!request.connection.settings.compression) {
if (!request.server.settings.compression) {
return null;
}

Expand Down
Loading

0 comments on commit 6447554

Please sign in to comment.