-
Notifications
You must be signed in to change notification settings - Fork 3
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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")? |
There was a problem hiding this comment.
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.
|
There was a problem hiding this 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>>>, |
There was a problem hiding this comment.
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(), |
There was a problem hiding this comment.
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(), |
There was a problem hiding this comment.
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(), |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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())) |
There was a problem hiding this comment.
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/slack/app.rs
Outdated
HttpResponse::Found() | ||
.header(http::header::LOCATION, "/e?identityAdded=error") | ||
.finish() |
There was a problem hiding this comment.
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
There was a problem hiding this 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)] |
There was a problem hiding this comment.
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.
Adding slack confirmation and handling to whoami application
Jira Story: https://jira.mozilla.com/browse/IAM-170