Commit 03c2d51d authored by Eric Betts's avatar Eric Betts

WIP

parent 1a893dbe
......@@ -36,11 +36,19 @@ const server = awsServerlessExpress.createServer(app)
exports.handler = (event, context) => {
const { succeed } = context;
// Inspecting the result to debug multiple cookie set problem
// Move cookies into multiValueHeaders
context.succeed = (result) => {
const { headers } = result;
console.log('succeed', {headers});
return succeed(result);
const cookies = Object.keys(headers).filter(key => key.toLowerCase() == "set-cookie");
if (cookies.length > 0) {
const multiValueHeaders = {
"Set-Cookie": cookies.map(key => headers[key]),
};
cookies.forEach(key => delete headers[key]);
return succeed({...result, multiValueHeaders});
} else {
return succeed(result);
}
}
awsServerlessExpress.proxy(server, event, context)
}
......
import React, {Component} from 'react';
import Amplify from 'aws-amplify';
import {Authenticator} from 'aws-amplify-react';
import awsconfig from './aws-exports';
import Authenticate from 'react-openidconnect';
import OidcSettings from './oidcsettings';
import AppContainer from './AppContainer';
Amplify.configure(awsconfig);
export default class AppWithAuth extends Component {
constructor(props) {
super(props);
this.userLoaded = this.userLoaded.bind(this);
this.userUnLoaded = this.userUnLoaded.bind(this);
this.state = { user: undefined };
}
userLoaded(user) {
if (user)
this.setState({ "user": user });
}
userUnLoaded() {
this.setState({ "user": undefined });
}
NotAuthenticated() {
return <div>You are not authenticated, please click here to authenticate.</div>;
}
render() {
return (
<div>
<Authenticator>
<Authenticate OidcSettings={OidcSettings} userLoaded={this.userLoaded} userunLoaded={this.userUnLoaded} renderNotAuthenticated={this.NotAuthenticated}>
<AppContainer />
</Authenticator>
</Authenticate>
</div>
);
}
......
......@@ -3,7 +3,8 @@ import ReactDOM from 'react-dom';
import {Provider} from 'react-redux';
import configureStore from './store/configureStore';
import AppContainer from './AppContainer';
// import AppContainer from './AppContainer';
import AppWithAuth from './AppWithAuth';
import * as serviceWorker from './serviceWorker';
import client from './graphql/client';
......@@ -14,7 +15,7 @@ const store = configureStore();
ReactDOM.render(
<ApolloProvider client={client}>
<Provider store={store}>
<AppContainer />
<AppWithAuth />
</Provider>
</ApolloProvider>,
document.getElementById('root'),
......
const { location } = window;
const { protocol, host } = location;
const OidcSettings = {
authority: `/.netlify/functions/oidc`,
client_id: 'pawprices',
//response_type: 'id_token token',
response_type: 'code',
redirect_uri: `${protocol}//${host}`,
post_logout_redirect_uri: '/',
};
export default OidcSettings;
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment