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

Conversation

andrew-sunada
Copy link

Adding slack confirmation and handling to whoami application

Jira Story: https://jira.mozilla.com/browse/IAM-170

Copy link
Contributor

@fiji-flo fiji-flo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please run cargo clippy https://github.com/rust-lang/rust-clippy#step-2-install-clippy
and cargo fmt before I take a deeper look?

src/main.rs Outdated
)),
)
.service(healthz::healthz_app())
})
.bind("0.0.0.0:8084")?
.bind("127.0.0.1:8084")?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Must be 0.0.0.0 again.

@andrew-sunada
Copy link
Author

cargo clippy and cargo fmt have both been run

Copy link
Contributor

@fiji-flo fiji-flo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall good. Just some cleanup.

src/slack/app.rs Outdated
slack: &Slack,
whoami: &WhoAmI,
secret: &[u8],
ttl_cache: Arc<RwLock<TtlCache<String, String>>>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not used in here. We only use it in the GitHub app to cache usernames.

src/slack/app.rs Outdated
);
let slack_uri_data: SlackUriData = SlackUriData {
slack_auth_params,
direct_message_uri: slack.direct_message_uri.to_string(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that should be a .clone() instead of .to_string() to make it more clear what's happening.

src/slack/app.rs Outdated
update_slack(
format!(
"{}{}",
slack_uri_data.direct_message_uri.to_string(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.to_string() is not needed here.

src/slack/app.rs Outdated
let slack_token_url = format!(
"{}{}&code={}",
TOKEN_URL,
slack_uri_data.slack_auth_params.to_string(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.to_string() not needed.

src/slack/app.rs Outdated
slack_uri_data: web::Data<SlackUriData>,
session: Session,
) -> Box<dyn Future<Item = HttpResponse, Error = Error>> {
let code = query.code.clone();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed we can use query.code a few lines later directly without copying here.

src/slack/app.rs Outdated
auth_url,
Some(token_url),
)
.add_scope(Scope::new(slack.scope.to_string()))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.clone() insteadl of .to_string() to me more explicit.

src/update.rs Outdated Show resolved Hide resolved
src/main.rs Show resolved Hide resolved
src/slack/app.rs Outdated Show resolved Hide resolved
src/update.rs Outdated Show resolved Hide resolved
src/slack/app.rs Outdated
Comment on lines 120 to 122
HttpResponse::Found()
.header(http::header::LOCATION, "/e?identityAdded=error")
.finish()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor niggle: we could call send_response here

Copy link

@LeoMcA LeoMcA left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy with this, but would be more comfortable if @fiji-flo could give it a once over before we deploy to prod in case there's any rust nuances I've missed.

state: String,
}

#[derive(Deserialize, Serialize, Debug)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can derive Clone here if we delete the impl below.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants