Skip to content

Commit

Permalink
Replace semistandard with standard
Browse files Browse the repository at this point in the history
  • Loading branch information
jonkoops authored and abstractj committed May 24, 2022
1 parent 5e86a00 commit dd1c20f
Show file tree
Hide file tree
Showing 39 changed files with 2,848 additions and 2,779 deletions.
2 changes: 1 addition & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"asi" : false,
"asi" : true,
"esversion": 6,
"node": true
}
44 changes: 22 additions & 22 deletions example/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,41 +14,41 @@
* the License.
*/

const Keycloak = require('keycloak-connect');
const hogan = require('hogan-express');
const express = require('express');
const session = require('express-session');
const Keycloak = require('keycloak-connect')
const hogan = require('hogan-express')
const express = require('express')
const session = require('express-session')

const app = express();
const app = express()

const server = app.listen(3000, function () {
const host = server.address().address;
const port = server.address().port;
console.log('Example app listening at http://%s:%s', host, port);
});
const host = server.address().address
const port = server.address().port
console.log('Example app listening at http://%s:%s', host, port)
})

// Register '.mustache' extension with The Mustache Express
app.set('view engine', 'html');
app.set('views', require('path').join(__dirname, '/view'));
app.engine('html', hogan);
app.set('view engine', 'html')
app.set('views', require('path').join(__dirname, '/view'))
app.engine('html', hogan)

// A normal un-protected public URL.

app.get('/', function (req, res) {
res.render('index');
});
res.render('index')
})

// Create a session-store to be used by both the express-session
// middleware and the keycloak middleware.

const memoryStore = new session.MemoryStore();
const memoryStore = new session.MemoryStore()

app.use(session({
secret: 'mySecret',
resave: false,
saveUninitialized: true,
store: memoryStore
}));
}))

// Provide the session store to the Keycloak so that sessions
// can be invalidated from the Keycloak console callback.
Expand All @@ -58,7 +58,7 @@ app.use(session({

const keycloak = new Keycloak({
store: memoryStore
});
})

// Install the Keycloak middleware.
//
Expand All @@ -73,20 +73,20 @@ app.use(keycloak.middleware({
logout: '/logout',
admin: '/',
protected: '/protected/resource'
}));
}))

app.get('/login', keycloak.protect(), function (req, res) {
res.render('index', {
result: JSON.stringify(JSON.parse(req.session['keycloak-token']), null, 4),
event: '1. Authentication\n2. Login'
});
});
})
})

app.get('/protected/resource', keycloak.enforcer(['resource:view', 'resource:write'], {
resource_server_id: 'nodejs-apiserver'
}), function (req, res) {
res.render('index', {
result: JSON.stringify(JSON.parse(req.session['keycloak-token']), null, 4),
event: '1. Access granted to Default Resource\n'
});
});
})
})
Loading

0 comments on commit dd1c20f

Please sign in to comment.