Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(IAM-170): adding slack to whoami #9

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
230 changes: 140 additions & 90 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ oauth2 = "2.0.0-beta.3"
url = "1.7"
base64 = "0.10.1"
rand = "0.7"
actix-web = { version = "1.0", features = ["ssl"] }
actix-web = { version = "1.0", features = ["rust-tls"] }
actix-cors = "0.1"
actix-session = "0.2"
failure = "0.1.5"
Expand All @@ -27,4 +27,4 @@ futures = "0.1"
chrono = "0.4.6"
env_logger = "0.6.1"
log = "0.4.6"
ttl_cache = "0.5.1"
ttl_cache = "0.5.1"
24 changes: 13 additions & 11 deletions proxy/proxy.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
const fs = require('fs');
const fs = require('fs');
const httpProxy = require('http-proxy');

//
// Create the HTTPS proxy server listening on port 8000
//
httpProxy.createServer({
target: {
host: '127.0.0.1',
port: 8084,
},
ssl: {
key: fs.readFileSync(process.env["DP_HTTPS_KEY"], 'utf8'),
cert: fs.readFileSync(process.env["DP_HTTPS_CERT"], 'utf8')
}
}).listen(443);
httpProxy
.createServer({
target: {
host: '127.0.0.1',
port: 8084,
},
ssl: {
key: fs.readFileSync(process.env['DP_HTTPS_KEY'], 'utf8'),
cert: fs.readFileSync(process.env['DP_HTTPS_CERT'], 'utf8'),
},
})
.listen(443);
14 changes: 11 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,23 @@ mod bugzilla;
mod github;
mod healthz;
mod settings;
mod slack;
mod update;
mod userid;

use crate::bugzilla::app::bugzilla_app;
use crate::github::app::github_app;
use crate::slack::app::slack_app;
use actix_web::middleware::Logger;
use actix_web::web;
use actix_web::App;
use actix_web::HttpServer;
use failure::Error;
use log::info;
use std::sync::Arc;
use std::sync::RwLock;
use ttl_cache::TtlCache;

use actix_web::HttpServer;
use failure::Error;

fn main() -> Result<(), Error> {
std::env::set_var("RUST_LOG", "info");
env_logger::init();
Expand All @@ -30,6 +31,7 @@ fn main() -> Result<(), Error> {
info!("initialized cis_client");
LeoMcA marked this conversation as resolved.
Show resolved Hide resolved
let secret = base64::decode(&s.whoami.secret)?;
let ttl_cache = Arc::new(RwLock::new(TtlCache::<String, String>::new(2000)));

HttpServer::new(move || {
App::new()
.wrap(Logger::default().exclude("/healthz"))
Expand All @@ -47,6 +49,12 @@ fn main() -> Result<(), Error> {
&s.whoami,
&secret,
client.clone(),
))
.service(slack_app(
&s.providers.slack,
&s.whoami,
&secret,
client.clone(),
)),
)
.service(healthz::healthz_app())
Expand Down
12 changes: 12 additions & 0 deletions src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,22 @@ pub struct GitHub {
pub client_secret: String,
}

#[derive(Debug, Deserialize, Clone)]
pub struct Slack {
pub client_id: String,
pub client_secret: String,
pub identity_scope: String,
pub im_scope: String,
pub identity_redirect_uri: String,
pub im_redirect_uri: String,
pub direct_message_uri: String,
}

#[derive(Debug, Deserialize, Clone)]
pub struct Providers {
pub github: GitHub,
pub bugzilla: BugZilla,
pub slack: Slack,
}

#[derive(Debug, Deserialize, Clone)]
Expand Down
Loading