-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
throw boomified aggregate error, prevent logging of server errors, li…
…nt test and example files
- Loading branch information
1 parent
c98c24d
commit faf305e
Showing
8 changed files
with
100 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
const hapi = require('@hapi/hapi'); | ||
const anyAuth = require('hapi-auth-any'); | ||
const basic = require('@hapi/basic') | ||
const basic = require('@hapi/basic'); | ||
|
||
const init = async () => { | ||
const server = hapi.server(); | ||
await server.initialize(); | ||
|
||
await server.register([ | ||
anyAuth, | ||
basic | ||
basic, | ||
]); | ||
server.auth.strategy('simple', 'basic', { /* content omitted */ }); | ||
|
||
server.auth.strategy('simple', 'basic', { /* content omitted */ }); | ||
server.auth.strategy('not-so-simple', 'basic', { /* content omitted */ }); | ||
|
||
server.auth.strategy('any', 'any', { | ||
strategies: ['simple', 'not-so-simple'] | ||
strategies: ['simple', 'not-so-simple'], | ||
}); | ||
server.auth.default('any'); | ||
} | ||
}; | ||
|
||
init() | ||
init(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,51 @@ | ||
/** | ||
* Example of how to use hapi-auth-any to wrap [hapi-auth-keycloak](https://github.com/felixheck/hapi-auth-keycloak), so it is configurable with multiple realmURLs | ||
* | ||
* | ||
* It accepts all the options that `hapi-auth-keycloak` does, plus a `realms` option. | ||
* | ||
* | ||
* Example: | ||
* | ||
* | ||
* ```javaScript | ||
* { | ||
* realms: [ | ||
* { | ||
* name: 'foo', | ||
* url: 'https://example.com/auth/realms/foo' | ||
* url: 'https://example.com/auth/realms/foo' | ||
* }, | ||
* { | ||
* name: 'bar', | ||
* url: 'https://example.com/auth/realms/bar' | ||
* url: 'https://example.com/auth/realms/bar' | ||
* } | ||
* ], | ||
* clientId: 'foobar' | ||
* } | ||
* ``` | ||
*/ | ||
|
||
const hapiKeycloak = require('hapi-auth-keycloak') | ||
const anyAuth = require('hapi-auth-any') | ||
const hapiKeycloak = require('hapi-auth-keycloak'); | ||
const anyAuth = require('hapi-auth-any'); | ||
|
||
const register = async (server, opts) => { | ||
const { realms, ...hapiKeycloakOptions } = opts | ||
const { realms, ...hapiKeycloakOptions } = opts; | ||
|
||
await server.register([ | ||
{ | ||
plugin: hapiKeycloak, | ||
options: hapiKeycloakOptions | ||
options: hapiKeycloakOptions, | ||
}, | ||
anyAuth | ||
]) | ||
anyAuth, | ||
]); | ||
|
||
const strategies = realms.map(({ name, url }) => { | ||
server.auth.strategy(name, 'keycloak-jwt', { name, realmUrl: url }) | ||
return name | ||
}) | ||
server.auth.strategy(name, 'keycloak-jwt', { name, realmUrl: url }); | ||
return name; | ||
}); | ||
|
||
server.auth.strategy('keycloak', 'any', { strategies }) | ||
server.auth.default('keycloak') | ||
} | ||
server.auth.strategy('keycloak', 'any', { strategies }); | ||
server.auth.default('keycloak'); | ||
}; | ||
|
||
module.exports = { | ||
register, | ||
name: 'auth' | ||
} | ||
name: 'auth', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters