Skip to content

Commit

Permalink
Receiving changes from develop to experimental/city-theme (#10)
Browse files Browse the repository at this point in the history
* Fix double encoding City-of-Helsinki#524; with caveat axios/axios#2563

* Display all api results in react select components

* Fix event publisher field name for user rights check

* Fix City-of-Helsinki#530

* Do not try to update deleted subevents

* Do not try to edit past subevents

* Refactor editability check; allow deleting and canceling series that contain deleted, canceled or past subevents

* Remove unnecessary inlined sub_events at cancel to prevent API errors

* Add instructions for internet events

* Update snapshots

* Add remote participation keyword to all internet events

* Add notification about online events to cancel confirmation dialog

* Add postpone button and badge

* Mention postponing in cancel extra text

* Add postpone button to editor too

* Show postponed events in search instead of crashing

* Update user rights managers

* Add missing </p>

* Do not remove subevents at cancel after all; deleted items removed by API PR City-of-Helsinki/linkedevents#407

* Fix removed future time validation; fixes City-of-Helsinki#536, City-of-Helsinki#528

* Update snapshots

* Feature/oidc auth (#8)

* initial oidc integration commit

* Removed Passport from user authentication

Fixed Warning with History import and removed Passport authentications.

* fetchUser and comments for OIDC

Needs proper lifecycle methods.

* Added some missing oidc features and updated tests

* Added oidc settings to production build.

* Added tests for user actions and reducer.

* Updated readme by removing mentions to builtin auth server.

* Updated node-sass package, added more tests and gitignored coverage folder.

Co-authored-by: Ducky07 <[email protected]>

Co-authored-by: Riku Oja <[email protected]>
Co-authored-by: Aleksi Salonen <[email protected]>
Co-authored-by: Riku Oja <[email protected]>
Co-authored-by: aceViilee <[email protected]>
Co-authored-by: Santtu Alatalo <[email protected]>
  • Loading branch information
6 people authored May 13, 2020
1 parent f4ddeb0 commit a28c0f1
Show file tree
Hide file tree
Showing 28 changed files with 610 additions and 269 deletions.
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"parser": "babel-eslint",
"globals": {
"_": true,
"appSettings": true
"appSettings": true,
"oidcSettings": true
},
"rules": {
"no-console": "off",
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ server.config
yarn-error.log
config_dev.json
package-lock.json
/coverage/
40 changes: 0 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ The UI is now compatible with the `courses` extension for the Linked Events API.
If you wish to include the extra fields specified in the `courses` extension,
please change the `ui_mode` setting from `events` to `courses`.

Note that authentication server is not nicely configurable. If you wish to
use your own authentication server, you will need code changes in server/auth.js.

## Running development server

```
Expand All @@ -55,10 +52,6 @@ if you'd like to change the base address for Linkedevents API, you would:
export api_base="https://api.hel.fi/linkedevents/v1"
```

Note that the configuration is used in the different phases. Some settings
need to be defined during build and other settings for running the
authentication server (see below)

Most if not all build automation tools provide for setting environment
variables. Check the documentation for the one you are using. If you are
testing locally you can `source config_build_example.sh` to get started.
Expand All @@ -75,36 +68,3 @@ $ yarn build
You should now have the bundled javascript + some non-bundled assets in
`dist`. You can serve these using your favorite web server at whatever
address suits your fancy.

You will still need the source tree for the authentication server (below)

### Setting up the runtime

In addition to serving the files built in previous step, you will need to
run the built-in authentication server (or proxy really). Although
linkedevents-ui runs completely in client, it currently uses authentication
code based OAuth2 Authorization Code flow. This is a historical accident,
that will be remedied one day.

We recommend running the authentication server with some sort of process
manager, possibly one specialized in running Node applications. Your system
process manager, like systemd, is another good candidate

The authentication server will need configuration passed in through
environment variables (see Congiration). If you use a process manager to
run the server, it should provide for setting them.

The server is run by executing `npm run production`. If your process
manager wants to run node by itself, you can also run specify `server` as
the script (that will actually run server/index.js). In this case you will
also need to set environment variable `NODE_ENV=production` by yourself.

After you have the authentication server running, you will need to set up a
web server to serve the files in `dist` and forward authentication requests
to the authentication server. The table below shows what needs to served:
| URL | what is served |
| /auth | forward to authentication server |
| filename | serve from dist-directory |
| unknown files | serve index.html from dist-directory |

The last part is needed for deep linking into the application.
9 changes: 8 additions & 1 deletion config/webpack/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default {
{
loader: 'sass-loader',
options: {
data: "$ui-mode: " + ui_mode + " !global;",
data: '$ui-mode: ' + ui_mode + ' !global;',
},
},
],
Expand All @@ -72,6 +72,13 @@ export default {
jQuery: 'jquery',
'window.jQuery': 'jquery',
}),
new webpack.DefinePlugin({
oidcSettings: {
client_id: JSON.stringify(readConfig('client_id')),
openid_audience: JSON.stringify(readConfig('openid_audience')),
openid_authority: JSON.stringify(readConfig('openid_authority')),
},
}),
],
mode: 'development',
};
9 changes: 8 additions & 1 deletion config/webpack/prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const config = {
use: [
{loader: 'style-loader'},
{loader: 'css-loader'},
{loader: 'sass-loader', options: {data: "$ui-mode: " + ui_mode + " !global;"}},
{loader: 'sass-loader', options: {data: '$ui-mode: ' + ui_mode + ' !global;'}},
],
},
{test: /\.css$/, use: ['style-loader', 'css-loader']},
Expand All @@ -81,6 +81,13 @@ const config = {
inject: true,
templateContent: indexTemplate,
}),
new webpack.DefinePlugin({
oidcSettings: {
client_id: JSON.stringify(appConfig.readConfig('client_id')),
openid_audience: JSON.stringify(appConfig.readConfig('openid_audience')),
openid_authority: JSON.stringify(appConfig.readConfig('openid_authority')),
},
}),
],
};

Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@
"moment": "^2.24.0",
"moment-timezone": "^0.5.27",
"nconf": "^0.9.1",
"node-sass": "^4.14.1",
"object-assign": "^4.1.1",
"passport": "^0.3.2",
"passport-helsinki": "https://github.com/City-of-Helsinki/passport-helsinki.git",
"oidc-client": "^1.10.1",
"progress": "^1.1.8",
"prop-types": "^15.7.2",
"raven-js": "^2.3.0",
Expand All @@ -74,6 +74,7 @@
"reactstrap": "^8.4.1",
"redux": "4.0.4",
"redux-actions": "^0.9.0",
"redux-oidc": "^4.0.0-beta1",
"redux-thunk": "^2.3.0",
"typeahead.js": "^0.11.1"
},
Expand Down Expand Up @@ -106,7 +107,6 @@
"js-yaml": "^3.13.1",
"json-loader": "^0.5.4",
"morgan": "^1.6.1",
"node-sass": "^4.13.1",
"pug": "^2.0.3",
"pug-loader": "^2.4.0",
"react-transform-hmr": "^1.0.4",
Expand All @@ -126,6 +126,7 @@
"jest": {
"setupTestFrameworkScriptFile": "<rootDir>src/setupTests.js",
"testEnvironment": "jsdom",
"testURL": "http://localhost/",
"moduleFileExtensions": [
"js",
"jsx",
Expand All @@ -136,7 +137,7 @@
"node_modules"
],
"moduleNameMapper": {
"^.+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$": "identity-obj-proxy"
"^.+\\.(css|styl|less|sass|scss|png|jpg|svg|ttf|woff|woff2)$": "identity-obj-proxy"
},
"snapshotSerializers": [
"enzyme-to-json/serializer"
Expand Down
59 changes: 0 additions & 59 deletions server/auth.js

This file was deleted.

7 changes: 0 additions & 7 deletions server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import cookieSession from 'cookie-session'

import getSettings from './getSettings'
import express from 'express'
import {getPassport, addAuth} from './auth'

import webpack from 'webpack'
import webpackMiddleware from 'webpack-dev-middleware'
Expand All @@ -16,17 +15,11 @@ import config from '../config/webpack/dev.js'

const settings = getSettings()
const app = express()
const passport = getPassport(settings)


app.use(cookieParser());
app.use(bodyParser.urlencoded({extended: true}));
app.use(cookieSession({name: 's', secret: settings.sessionSecret, maxAge: 86400 * 1000}));

app.use(passport.initialize());
app.use(passport.session());
addAuth(app, passport, settings);

if(process.env.NODE_ENV !== 'development') {
app.use('/', express.static(path.resolve(__dirname, '..', 'dist')));
app.get('*', function (req, res) {
Expand Down
Loading

0 comments on commit a28c0f1

Please sign in to comment.