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

Preview of SSO for browser #1478

Merged
merged 50 commits into from
Aug 10, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
ed477f3
Initial implementation
OskarDamkjaer Jul 20, 2021
2d864d0
Remove dep on querystring
OskarDamkjaer Jul 20, 2021
2aff3dc
Restore search params properly
OskarDamkjaer Jul 20, 2021
e881ae7
Remove unneeded changes
OskarDamkjaer Jul 20, 2021
e6546ae
Touch up connect frame and update licenses
OskarDamkjaer Jul 20, 2021
f7494a8
Cleanup discovery duck
OskarDamkjaer Jul 20, 2021
0a9a929
Add helper fns to discovery duck
OskarDamkjaer Jul 20, 2021
023cf7b
cleanup
OskarDamkjaer Jul 20, 2021
3bdccf8
Touch up connect frame
OskarDamkjaer Jul 20, 2021
f1e574e
Respect discoveryURL param
OskarDamkjaer Jul 20, 2021
007dd5c
Borrow bloom auth debugger fn
OskarDamkjaer Jul 20, 2021
972c5be
Updated auth code from bloom
OskarDamkjaer Jul 24, 2021
60b1e79
Fix keycloak implicit flow
OskarDamkjaer Jul 24, 2021
b35996c
cleanup
OskarDamkjaer Jul 26, 2021
2fb5590
Add bloom updates
OskarDamkjaer Jul 26, 2021
673b96e
Fix crashes
OskarDamkjaer Jul 26, 2021
e80fd11
mellan
OskarDamkjaer Jul 26, 2021
123d4ce
Update tests
OskarDamkjaer Jul 26, 2021
d291114
fix styling
OskarDamkjaer Jul 26, 2021
984cac6
Add better logging
OskarDamkjaer Jul 27, 2021
015a73a
mel
OskarDamkjaer Jul 27, 2021
3ebc1c7
Show error messages from SSO
OskarDamkjaer Jul 27, 2021
7c8fcc8
Self review
OskarDamkjaer Jul 27, 2021
413bcfc
Fix normal discovery
OskarDamkjaer Jul 27, 2021
25eb2c6
Downloadable logs
OskarDamkjaer Jul 28, 2021
b81a87b
Update naming as per review comments
OskarDamkjaer Jul 30, 2021
41fe35b
comments
OskarDamkjaer Aug 1, 2021
d03a887
Fix comment around logging
OskarDamkjaer Aug 1, 2021
ac2abd0
Add rejections per review comments
OskarDamkjaer Aug 1, 2021
25aca12
Fix comment about history.replace
OskarDamkjaer Aug 1, 2021
29f1bca
More throws
OskarDamkjaer Aug 1, 2021
a928eea
List missing keys on invalid sso provider
OskarDamkjaer Aug 1, 2021
130f20e
Update log message about principal and secure context
OskarDamkjaer Aug 1, 2021
7d07f8a
Use constant for url param
OskarDamkjaer Aug 1, 2021
c9183d7
Stop log and throwing
OskarDamkjaer Aug 1, 2021
3070bc3
Improve error handling
OskarDamkjaer Aug 1, 2021
87d107c
Add better types
OskarDamkjaer Aug 2, 2021
7555dc1
Helper fn for getting valid sso providers
OskarDamkjaer Aug 2, 2021
f5483aa
Handle connectURL and multiple discovery endpoints properly
OskarDamkjaer Aug 2, 2021
49afb59
Update from jons review comments
OskarDamkjaer Aug 2, 2021
106686a
Add discovery logs to :debug frame
OskarDamkjaer Aug 2, 2021
62977ea
Update styling as per lizas comments
OskarDamkjaer Aug 2, 2021
7c46548
Fix typo
OskarDamkjaer Aug 2, 2021
e2e4fba
Rename provider id
OskarDamkjaer Aug 2, 2021
16f0e40
remove extra newline in :debug logs
OskarDamkjaer Aug 2, 2021
7d9ebae
Move code to styled comp
OskarDamkjaer Aug 2, 2021
261556d
Cleanup comment
OskarDamkjaer Aug 2, 2021
e9261ed
Fix unit tests
OskarDamkjaer Aug 10, 2021
cd4f55a
Merge branch 'master' into sso
OskarDamkjaer Aug 10, 2021
757d15a
Merge master
OskarDamkjaer Aug 10, 2021
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
27 changes: 19 additions & 8 deletions src/shared/modules/auth/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ export const getInitialisationParameters = () => {

export const checkAndMergeSSOProviders = (
discoveredSSOProviders,
isLocalhostOrigin
updateExistingProviders
) => {
if (!discoveredSSOProviders || !discoveredSSOProviders.length) {
authLog('Invalid discovered SSO providers')
authLog('Invalid discovered SSO providers', 'warn')
return
}

Expand All @@ -48,12 +48,15 @@ export const checkAndMergeSSOProviders = (
}

discoveredSSOProviders.forEach(provider => {
if (!provider) return
if (!provider) {
authlog(`Found invalid discoved sso provider`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo

return
}
if (
!mandatoryKeysForSSOProviders.every(key => provider.hasOwnProperty(key))
) {
authLog(
`Dropping invalid discovered SSO provider with id: "${provider.id}", missing key`
authlog(
`dropping invalid discovered sso provider with id: "${provider.id}", missing key`
)
return
}
Expand All @@ -70,7 +73,7 @@ export const checkAndMergeSSOProviders = (
if (
currentSSOProviders.find(crntProvider => crntProvider.id === provider.id)
) {
if (isLocalhostOrigin) {
if (updateExistingProviders) {
const idx = currentSSOProviders.findIndex(
crntProvider => crntProvider.id === provider.id
)
Expand Down Expand Up @@ -161,9 +164,17 @@ export const getCredentialsFromAuthResult = (result, idpId) => {
parsedJWT[principal] || parsedJWT.email || parsedJWT.sub
authLog(`Credentials assembly with username: ${credsPrincipal}`)

const configuredTokenType =
selectedSSOProvider.config?.['token_type_authentication']
const tokenTypeAuthentication =
selectedSSOProvider.config?.['token_type_authentication'] ||
defaultTokenTypeAuthentication
configuredTokenType || defaultTokenTypeAuthentication

if (!configuredTokenType) {
authLog(
OskarDamkjaer marked this conversation as resolved.
Show resolved Hide resolved
`token_type_authentication not configured, using default token type "${defaultTokenTypeAuthentication}".`
)
}

authLog(
`Credentials assembled with token type "${tokenTypeAuthentication}" as password. If connection still does not succeed, make sure neo4j.conf is set up correctly`
OskarDamkjaer marked this conversation as resolved.
Show resolved Hide resolved
)
Expand Down
6 changes: 4 additions & 2 deletions src/shared/modules/auth/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@ import { AUTH_LOGGING_PREFIX, AUTH_STORAGE_LOGS } from './constants'
import { isAuthLoggingEnabled, isAuthDebuggingEnabled } from './settings'
import { saveAs } from 'file-saver'

const MAX_LOG_LINES = 200
export const authLog = (msg, type = 'log') => {
if (!isAuthLoggingEnabled) return
if (!['log', 'error', 'warn'].includes(type)) return
const log = `${AUTH_LOGGING_PREFIX} [${new Date().toISOString()}] ${msg}`
const messageNoNewlines = msg.replace('\n', ' ')
OskarDamkjaer marked this conversation as resolved.
Show resolved Hide resolved
const log = `${AUTH_LOGGING_PREFIX} [${new Date().toISOString()}] ${messageNoNewlines}`
const logs = sessionStorage.getItem(AUTH_STORAGE_LOGS) || ''
const logsLines = logs.split('\n')
OskarDamkjaer marked this conversation as resolved.
Show resolved Hide resolved

const truncatedOldLogs =
logsLines.length > 200 ? logsLines.slice(-199).join('\n') : logs
logsLines.length > MAX_LOG_LINES ? logsLines.slice(-199).join('\n') : logs
OskarDamkjaer marked this conversation as resolved.
Show resolved Hide resolved

sessionStorage.setItem(AUTH_STORAGE_LOGS, `${truncatedOldLogs}${log}\n`)
}
Expand Down
2 changes: 1 addition & 1 deletion src/shared/modules/auth/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
export const authRequestForSSO = idpId => {
OskarDamkjaer marked this conversation as resolved.
Show resolved Hide resolved
const selectedSSOProvider = getSSOProviderByIdpId(idpId)
if (!selectedSSOProvider) {
const error = `Invalid OAuth2 endpoint: "${oauth2Endpoint}"`
const error = `Could not find any SSO provider with idpId: "${idpId}"`
authLog(error)
return error
}
Expand Down