Skip to content

Commit

Permalink
Merge pull request #1103 from oskarhane/auth-scheme-error
Browse files Browse the repository at this point in the history
Fix auth scheme error from driver when auth is disabled + reflect auth status on `:server connect` frame`
  • Loading branch information
oskarhane authored May 26, 2020
2 parents 475000d + 7f4615f commit 54fa792
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 8 deletions.
19 changes: 17 additions & 2 deletions src/browser/modules/Stream/Auth/ConnectionForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import {
toggleSchemeRouting,
isNonSupportedRoutingSchemeError
} from 'services/boltscheme.utils'
import { StyledConnectionBody } from './styled'

export class ConnectionForm extends Component {
constructor(props) {
Expand Down Expand Up @@ -260,15 +261,29 @@ export class ConnectionForm extends Component {
{this.props.children}
</ChangePasswordForm>
)
} else if (this.props.isConnected) {
} else if (
this.props.isConnected &&
this.props.activeConnectionData &&
this.props.activeConnectionData.authEnabled !== false // falsy value indicates (except false) we don't know yet, so see that as enabled.
) {
view = (
<ConnectedView
host={this.state.host}
username={this.state.username}
username={this.props.activeConnectionData.username}
storeCredentials={this.props.storeCredentials}
hideStoreCredentials={this.state.authenticationMethod === NO_AUTH}
/>
)
} else if (
this.props.isConnected &&
this.props.activeConnectionData &&
this.props.activeConnectionData.authEnabled === false // excplicit false = auth disabled for sure
) {
view = (
<StyledConnectionBody>
You have a working connection and server auth is disabled.
</StyledConnectionBody>
)
} else if (!this.props.isConnected && !this.state.passwordChangeNeeded) {
view = (
<ConnectForm
Expand Down
3 changes: 2 additions & 1 deletion src/browser/modules/Stream/Auth/ConnectionForm.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ test('should print correct state for retaining credentials', async () => {
activeConnection = true
activeConnectionData = {
username,
host
host,
authEnabled: true
}
rerender(
<ConnectionForm
Expand Down
10 changes: 8 additions & 2 deletions src/shared/modules/connections/connectionsDuck.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,12 @@ const updateAuthEnabledHelper = (state, authEnabled) => {
...state.connectionsById[connectionId],
authEnabled
}

if (!authEnabled) {
updatedConnection.username = ''
updatedConnection.password = ''
}

const updatedConnectionByIds = {
...state.connectionsById
}
Expand Down Expand Up @@ -341,7 +347,7 @@ export const connectEpic = (action$, store) => {
.openConnection(action, {
connectionTimeout: getConnectionTimeout(store.getState())
})
.then(res => ({ type: action.$$responseChannel, success: true }))
.then(() => ({ type: action.$$responseChannel, success: true }))
.catch(e => {
if (!action.noResetConnectionOnFail) {
store.dispatch(setActiveConnection(null))
Expand Down Expand Up @@ -585,7 +591,7 @@ export const switchConnectionEpic = (action$, store) => {
{ encrypted: action.encrypted },
onLostConnection(store.dispatch)
)
.then(connection => {
.then(() => {
store.dispatch(setActiveConnection(discovery.CONNECTION_ID))
resolve({ type: SWITCH_CONNECTION_SUCCESS })
})
Expand Down
4 changes: 2 additions & 2 deletions src/shared/services/bolt/bolt.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ function openConnection(props, opts = {}, onLostConnection) {
return new Promise((resolve, reject) => {
boltConnection
.openConnection(props, opts, onLostConnection)
.then(r => {
.then(() => {
connectionProperties = {
authenticationMethod: props.authenticationMethod || NATIVE,
username: props.username,
password: props.password,
host: props.host,
opts
}
resolve(r)
resolve()
})
.catch(e => {
connectionProperties = null
Expand Down
2 changes: 1 addition & 1 deletion src/shared/services/bolt/globalDrivers.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export const buildAuthObj = props => {
) {
auth = neo4j.auth.basic(props.username, props.password)
} else {
auth = null
auth = neo4j.auth.basic('', '')
}
return auth
}

0 comments on commit 54fa792

Please sign in to comment.