-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #379 from EBISPOT/develop
Develop
- Loading branch information
Showing
10 changed files
with
95 additions
and
15,394 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 was deleted.
Oops, something went wrong.
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
Binary file not shown.
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,5 +1,4 @@ | ||
import React, { Component } from 'react'; | ||
import lsri_login_button from '../LS.png'; | ||
|
||
import Grid from '@material-ui/core/Grid'; | ||
import ElixirAuthService from '../ElixirAuthService'; | ||
|
@@ -8,17 +7,11 @@ import { AuthConsumer } from '../auth-context'; | |
|
||
import history from "../history"; | ||
import { Typography } from '@material-ui/core'; | ||
import Link from '@material-ui/core/Link'; | ||
|
||
import PropTypes from 'prop-types'; | ||
import { withStyles } from '@material-ui/core/styles'; | ||
|
||
|
||
const AAP_URL = process.env.REACT_APP_AAPURL; | ||
|
||
const LSRegistrationLink = "https://signup.aai.lifescience-ri.eu/fed/registrar/?vo=lifescience"; | ||
|
||
const LSLoginContact = <a href="mailto:[email protected]">[email protected]</a>; | ||
const gwasContact = <a href="mailto:[email protected]">[email protected]</a>; | ||
|
||
const styles = theme => ({ | ||
linkColor: { | ||
|
@@ -73,7 +66,9 @@ class Login extends Component { | |
} | ||
|
||
// Store JWT in local storage | ||
const token = event.data; | ||
const token = event.newValue; | ||
localStorage.removeItem("tokenEvent"); | ||
|
||
this.ElixirAuthService.setToken(token); | ||
|
||
// Set Auth Context | ||
|
@@ -106,19 +101,19 @@ class Login extends Component { | |
} | ||
|
||
componentDidMount() { | ||
window.addEventListener("message", this.handleLogin); | ||
window.addEventListener('storage', this.handleLogin); | ||
} | ||
|
||
componentWillUnmount() { | ||
window.removeEventListener('message', this.handleLogin); | ||
window.removeEventListener('storage', this.handleLogin); | ||
} | ||
|
||
/** | ||
* Check if the message is coming from the same domain we use to generate | ||
* the SSO URL, otherwise it's iffy and shouldn't trust it. | ||
*/ | ||
messageIsAcceptable(event) { | ||
return event.origin === AAP_URL; | ||
return event.key === 'tokenEvent' && event.newValue; | ||
} | ||
|
||
render() { | ||
|
@@ -132,31 +127,37 @@ class Login extends Component { | |
spacing={3}> | ||
<Grid item xs={12} sm={6}> | ||
<Typography> | ||
Single Sign On using your LS Login identity! | ||
Log in using your institution! | ||
</Typography> | ||
</Grid> | ||
|
||
<Grid item xs={12} sm={6}> | ||
<button onClick={this.ElixirAuthService.login} className={classes.button}> | ||
< span > | ||
<img src={lsri_login_button} alt="login" style={{ height: '1.7em', width: '3em', verticalAlign: 'middle', paddingRight: '2px' }} /> | ||
LOGIN | ||
</span> | ||
</button> | ||
<div | ||
style={{ | ||
display: 'inline-block', | ||
boxShadow: '3px 5px 3px rgba(0, 0, 0, 0.2)', | ||
overflow: 'hidden', transition: 'transform 0.3s, box-shadow 0.3s' | ||
}} | ||
> | ||
<img onClick={this.ElixirAuthService.login} alt="CILogon" | ||
src="https://cilogon.org/images/cilogon-ci-32-g.png" style={{ | ||
cursor: 'pointer', width: '100%', | ||
height: '100%', | ||
display: 'block', | ||
}}/> | ||
</div> | ||
</Grid> | ||
|
||
<Grid item xs={12} sm={6}> | ||
<Grid item xs={12} sm={8}> | ||
<Typography> | ||
You can use the Life Science Login identity service and other Life Science services with the freely available | ||
LS Login identity, which integrates with Google, ORCID and most academic institutions. | ||
|
||
Obtain your LS Login identity <Link href={LSRegistrationLink} className={classes.linkColor}>here</Link>. | ||
The GWAS Submission system uses CILogon to allow you to log in, which integrates with Google, | ||
ORCID and most academic institutions. | ||
</Typography> | ||
</Grid> | ||
|
||
<Grid item xs={12} sm={6}> | ||
<Typography> | ||
If you have problems logging in please contact {LSLoginContact}. | ||
If you have problems logging in please contact {gwasContact}. | ||
</Typography> | ||
</Grid> | ||
</Grid > | ||
|
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React, { useEffect } from "react"; | ||
|
||
// This was written to mimic the behaviour of AAP which used to post message events, I used storage events | ||
// As message events didn't work after a redirect to the idp, as it fails to reference the opener (null) | ||
const PopupCallback = () => { | ||
useEffect(() => { | ||
// Function to parse URL hash parameters | ||
const parseHashParams = (hash) => { | ||
const params = {}; | ||
hash.substring(1).split("&").forEach((pair) => { | ||
const [key, value] = pair.split("="); | ||
params[key] = decodeURIComponent(value); | ||
}); | ||
return params; | ||
}; | ||
|
||
// Handle the callback | ||
const handleCallback = () => { | ||
if (window.location.hash) { | ||
const hashParams = parseHashParams(window.location.hash); | ||
const token = hashParams.access_token; | ||
if (token) { | ||
// Send tokens to the parent window | ||
localStorage.setItem("tokenEvent", token); | ||
} else { | ||
localStorage.setItem("tokenEvent", undefined); | ||
} | ||
|
||
// Close the popup | ||
window.close(); | ||
} | ||
}; | ||
|
||
handleCallback(); | ||
}, []); | ||
|
||
return <div style={{marginTop: '300px'}}>Processing login...</div>; | ||
}; | ||
|
||
export default PopupCallback; |
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
Binary file not shown.
Binary file not shown.