Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix auth scheme error from driver when auth is disabled + reflect auth status on :server connect frame #1103

Merged
merged 3 commits into from
May 26, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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
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 enabled for sure
oskarhane marked this conversation as resolved.
Show resolved Hide resolved
) {
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 @@ -587,7 +593,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
}