trying to get ssl

This commit is contained in:
counter 2023-01-14 12:21:00 -08:00
parent 53e6fefb18
commit 94a1f74516
3 changed files with 7 additions and 6 deletions

7
app.js
View file

@ -17,11 +17,9 @@ const api = require('./api.js');
const validate = require('express-jsonschema').validate;
const constants = require('./constants.js');
const {google} = require('googleapis');
const {OAuth2Client} = require('google-auth-library');
const client = new OAuth2Client(process.env.CLIENT_ID, process.env.CLIENT_SECRET, `https://${process.env.HOSTNAME}/oauth-login`);
const client = new OAuth2Client(process.env.CLIENT_ID, process.env.CLIENT_SECRET, `https://${process.env.HOSTNAME}/oauth-login`);
function set_secure_headers(req, res) {
res.set("X-XSS-Protection", "mode=block");
@ -290,8 +288,9 @@ async function get_app_server() {
client.setCredentials(tokens);
const oauth2 = google.oauth2({version: 'v2', auth: client});
const email = await oauth2.userinfo.v2.me.get();
req.session.authenticated = true;
req.session.email = email.data.email;
res.send(`Hello ${email.data.email}!`);
} catch (error) {
console.log(`Error Occured: ${error}`);
res.status(500).send("Error Occured");

View file

@ -9,6 +9,8 @@ services:
# SSL will automatically be set up and
# renewed with LetsEncrypt.
- HOSTNAME=your.host.name
# THis hostname is where your JS is served out of
- XSS_HOSTNAME=your.xss.domain
# [REQUIRED] Email for SSL
- SSL_CONTACT_EMAIL=YourEmail@gmail.com
# Maximum XSS callback payload size

View file

@ -3,7 +3,7 @@ echo "Initializing SSL/TLS..."
# Set up Greenlock
# Test if --maintainer-email is required, we can set it via environment variables...
npx greenlock init --config-dir /app/greenlock.d --maintainer-email $SSL_CONTACT_EMAIL
npx greenlock add --subject $HOSTNAME --altnames "$HOSTNAME"
npx greenlock add --subject $HOSTNAME --altnames "*.$XSS_HOSTNAME"
echo "Starting server..."
node server.js
node server.js