Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/core/src/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
* limitations under the License.
*/

import { newError } from './error'
import { stringify } from './json'

/**
* @property {function(username: string, password: string, realm: ?string)} basic the function to create a
* basic authentication token.
Expand Down Expand Up @@ -74,6 +77,11 @@ const auth = {
output.realm = realm
}
if (isNotEmpty(parameters)) {
try {
stringify(parameters)
} catch (e) {
throw newError('Circular references in custom auth token parameters', undefined, e)
}
output.parameters = parameters
}
return output
Expand Down
6 changes: 6 additions & 0 deletions packages/core/test/auth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
import auth from '../src/auth'

describe('auth', () => {
test('.custom() should crash with circular references in parameters', () => {
const params = { a: '', b: {} }
params.b = params
expect(() => auth.custom('test', 'pass', 'realm', 'scheme', params)).toThrow('Circular references in custom auth token parameters')
})

test('.bearer()', () => {
expect(auth.bearer('==Qyahiadakkda')).toEqual({ scheme: 'bearer', credentials: '==Qyahiadakkda' })
})
Expand Down
8 changes: 8 additions & 0 deletions packages/neo4j-driver-deno/lib/core/auth.ts

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