Commit 2e328578 authored by Varun Srivastava's avatar Varun Srivastava
Browse files

Merge branch 'testing' into 'devel_varun'

Testing

See merge request !67
parents 68f76bef 496b8571
pages-testing:
deploy-testing:
stage: deploy
script:
- cat $configfiledev > ./config/config.js
- cat $cert > ./routes/cert/cert.pem
- cat $certidp > ./routes/cert/cert_idp.pem
- cat $key > ./routes/cert/key.pem
- npm install
- "pm2 delete --silent account || :"
- pm2 start ./app.js --name=account
......@@ -9,4 +13,19 @@ pages-testing:
- testing
only:
- testing
- test_logoutbutton
\ No newline at end of file
deploy-master:
stage: deploy
script:
- cat $configfileprod > ./config/config.js
- cat $cert > ./routes/cert/cert.pem
- cat $certidp > ./routes/cert/cert_idp.pem
- cat $key > ./routes/cert/key.pem
- npm install
- "pm2 delete --silent account || :"
- pm2 start ./app.js --name=account
- pm2 save
tags:
- production
only:
- master
\ No newline at end of file
......@@ -9,28 +9,31 @@ module.exports = {
strategy: 'saml',
saml: {
path: process.env.SAML_PATH || '/saml/SSO',
entryPoint: process.env.SAML_ENTRY_POINT || 'https://m4lab.hft-stuttgart.de/idp/saml2/idp/SSOService.php',
issuer: 'sp-account.m4lab.hft-stuttgart.de', //local metadata
logoutUrl: 'https://m4lab.hft-stuttgart.de/idp/saml2/idp/SingleLogoutService.php'
entryPoint: process.env.SAML_ENTRY_POINT || 'Saml Entry Point',
issuer: 'SAML issuer', //local metadata
logoutUrl: 'SAML logout URL'
}
},
database: {
host: 'localhost', // DB host
user: 'DBManager', // DB username
password: 'Stuttgart2019', // DB password
user: 'usernamedb', // DB username
password: 'passworddb', // DB password
port: 3306, // MySQL port
dbUser: 'userdb', // User DB
host_project: 'localhost', // DB host project db
dbProject: 'projectDB' // Project DB
dbProject: 'projectdb' // Project DB
},
mailer: {
host: 'mail.hft-stuttgart.de', // hostname
host: 'mailhost', // hostname
secureConnection: false, // TLS requires secureConnection to be false
port: 587, // port for secure SMTP
authUser: 'ad\\support-transfer',
authPass: '6laumri2',
authUser: 'mailuser',
authPass: 'mailpass',
tlsCiphers: 'SSLv3',
from: 'support-transfer@hft-stuttgart.de',
from: 'mailfrom',
},
gitlab: {
token_readWriteProjects: 'token-goes-here'
}
},
testing: {
......@@ -43,30 +46,31 @@ module.exports = {
strategy: 'saml',
saml: {
path: process.env.SAML_PATH || '/saml/SSO',
entryPoint: process.env.SAML_ENTRY_POINT || 'https://m4lab.hft-stuttgart.de/idp/saml2/idp/SSOService.php',
//issuer: 'sp-account.m4lab.hft-stuttgart.de', //local metadata
issuer: 'sp-account-testing.m4lab.hft-stuttgart.de', //testing metadata
//issuer: 'sp-account-prod.m4lab.hft-stuttgart.de', //production metadata
logoutUrl: 'https://m4lab.hft-stuttgart.de/idp/saml2/idp/SingleLogoutService.php'
entryPoint: process.env.SAML_ENTRY_POINT || 'saml entry point',
issuer: 'SAML issuer', //testing metadata
logoutUrl: 'SAML logout URL'
}
},
database: {
host: 'transfer.hft-stuttgart.de', // DB host
user: 'DBManager', // DB username
password: 'Stuttgart2019', // DB password
host: 'dbhost', // DB host
user: 'dbuser', // DB username
password: 'dbpass', // DB password
port: 3306, // MySQL port
dbUser: 'userdb', // User DB
host_project: 'm4lab.hft-stuttgart.de', // DB host project db
dbProject: 'projectDB' // Project DB
host_project: 'dbhost', // DB host project db
dbProject: 'projectdb' // Project DB
},
mailer: {
host: 'mail.hft-stuttgart.de', // hostname
host: 'mailhost', // hostname
secureConnection: false, // TLS requires secureConnection to be false
port: 587, // port for secure SMTP
authUser: 'ad\\support-transfer',
authPass: '6laumri2',
authUser: 'mailuser',
authPass: 'mailpass',
tlsCiphers: 'SSLv3',
from: 'support-transfer@hft-stuttgart.de',
from: 'mailfrom',
},
gitlab: {
token_readWriteProjects: 'token-goes-here'
}
}
}
\ No newline at end of file
This diff is collapsed.
......@@ -39,8 +39,9 @@
"nodemailer": "^6.3.1",
"nodemon": "^2.0.1",
"passport": "0.3.2",
"passport-saml": "^1.2.0",
"pug": "^2.0.4"
"passport-saml": "^1.4.2",
"pug": "^2.0.4",
"superagent": "^6.1.0"
},
"devDependencies": {},
"engines": {
......
......@@ -69,7 +69,7 @@ var methods = {
})
},
getUserByEmail: function(email, callback) {
dbconn.user.query('SELECT verificationStatus, salutation, title, firstname, lastname, industry, organisation, speciality, m4lab_idp FROM user WHERE email = "' +email+'"', function (err, rows, fields) {
dbconn.user.query('SELECT id, verificationStatus, salutation, title, firstname, lastname, industry, organisation, speciality, m4lab_idp FROM user WHERE email = "' +email+'"', function (err, rows, fields) {
if (err) {
throw err;
}
......@@ -212,6 +212,25 @@ var methods = {
})
callback(err)
})
},
/* ===== GitLab ===== */
getGitlabId: function(userId, callback){
let gitlabUserId
dbconn.user.query('SELECT gu.gitlab_userId FROM user_gitlab gu, user u WHERE u.id = "' +userId+'" and gu.user_id = u.id', function (err, rows) {
if (err) {
throw err
}
else if(rows[0]) {
gitlabUserId = rows[0].gitlab_userId
}
callback(gitlabUserId, err)
})
},
addGitlabUser: function(data, callback){
dbconn.user.query('INSERT INTO user_gitlab SET ?', data, function (err) {
if (err) throw err
callback(err)
})
}
};
......
......@@ -10,6 +10,7 @@ const salt = 64; // salt length
const async = require('async')
const crypto = require('crypto')
const mailer = require('./mailer')
const superagent = require('superagent')
module.exports = function (app, config, passport, i18n) {
......@@ -180,6 +181,34 @@ module.exports = function (app, config, passport, i18n) {
methods.getUserByEmail(req.user.email, function(data, err){
if (!err) {
if (data.verificationStatus == 1) {
// start =============== RS: MLAB-183
let userId = data.id
methods.getGitlabId(userId, function(data, err){
if (!err) {
if (data) {
console.log("TODO: GitLab is already activated for this user. Allow project creation.")
}
else {
superagent.get('https://transfer.hft-stuttgart.de/gitlab/api/v4/users?private_token='+config.gitlab.token_readWriteProjects+'&search='+req.user.email)
.then(res => {
if (res.body.length > 0) {
let gitlabActivationData = {
user_id: userId,
gitlab_userId: res.body[0].id
}
methods.addGitlabUser(gitlabActivationData, function(err){})
}
else {
console.log('TODO: Show gitlab activation button: transfer.hft-stuttgart.de/gitlab')
}
})
.catch(err => {
console.log(err.message)
});
}
}
})
// end =============== RS: MLAB-183
res.render(lang+'/account/services', {
user: data
});
......
Supports Markdown
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