Skip to content
This repository has been archived by the owner on Oct 6, 2020. It is now read-only.

Commit

Permalink
Merge pull request #246 from djc/auth-tweaks
Browse files Browse the repository at this point in the history
Tweak authentication/authorization code
  • Loading branch information
Francesco Cogno authored Mar 4, 2020
2 parents 8b70bcd + fcab20f commit b55322b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion azure_sdk_auth_aad/examples/interactive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
// Create URL to browse for initial authorization
let c = authorize_delegate(
client_id,
client_secret,
Some(client_secret),
&tenant_id,
Url::parse("http://localhost:3003/redirect").unwrap(),
"https://management.azure.com/",
Expand Down
7 changes: 4 additions & 3 deletions azure_sdk_auth_aad/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ use oauth2::basic::BasicClient;
use oauth2::reqwest::async_http_client;
use oauth2::AsyncCodeTokenRequest;
use oauth2::{
AuthType, AuthUrl, AuthorizationCode, ClientId, ClientSecret, CsrfToken, PkceCodeChallenge,
AuthType, AuthUrl, AuthorizationCode, CsrfToken, PkceCodeChallenge,
PkceCodeVerifier, RedirectUrl, TokenUrl,
};
pub use oauth2::{ClientId, ClientSecret};
use url::form_urlencoded;
use url::Url;
mod login_response;
Expand All @@ -33,7 +34,7 @@ pub struct AuthObj {

pub fn authorize_delegate(
client_id: ClientId,
client_secret: ClientSecret,
client_secret: Option<ClientSecret>,
tenant_id: &str,
redirect_url: Url,
resource: &str,
Expand All @@ -54,7 +55,7 @@ pub fn authorize_delegate(
);

// Set up the config for the Microsoft Graph OAuth2 process.
let client = BasicClient::new(client_id, Some(client_secret), auth_url, Some(token_url))
let client = BasicClient::new(client_id, client_secret, auth_url, Some(token_url))
// Microsoft Graph requires client_id and client_secret in URL rather than
// using Basic authentication.
.set_auth_type(AuthType::RequestBody)
Expand Down
3 changes: 2 additions & 1 deletion azure_sdk_auth_aad/src/naive_server.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::errors::ServerReceiveError;
use crate::AuthObj;
use log::debug;
use oauth2::{AuthorizationCode, CsrfToken};
use std::io::{BufRead, BufReader, Write};
use std::net::TcpListener;
Expand All @@ -24,7 +25,7 @@ pub fn naive_server(auth_obj: &AuthObj, port: u32) -> Result<AuthorizationCode,
};
let url = Url::parse(&("http://localhost".to_string() + redirect_url)).unwrap();

println!("url == {}", url);
debug!("url == {}", url);

let code = match url.query_pairs().find(|pair| {
let &(ref key, _) = pair;
Expand Down

0 comments on commit b55322b

Please sign in to comment.