forked from Azure/iotedge
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merged PR 826036: TPM challenge in DPS flow
PR contains the following: - First roundtrip to DPS. It calls register on DPS, gets the TPM authentication challenge, uses the challenge to sign a token and reissues the registration call - Moved http client from iothubservice to edgelet-http crate. This is because both iothubservice and dps use the http client to talk to their respective services.
- Loading branch information
Showing
23 changed files
with
932 additions
and
209 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -313,4 +313,5 @@ backup.json | |
|
||
# linux dev files | ||
*.swp | ||
*.swo | ||
*.vi |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
[workspace] | ||
members = [ | ||
"docker-rs", | ||
"dps", | ||
"edgelet-core", | ||
"edgelet-docker", | ||
"edgelet-hsm", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
[package] | ||
name = "dps" | ||
version = "0.1.0" | ||
authors = ["Janice D'Sa <[email protected]>"] | ||
|
||
[dependencies] | ||
base64 = "0.9" | ||
chrono = { version = "0.4", features = ["serde"] } | ||
failure = "0.1" | ||
futures = "0.1" | ||
hyper = "0.11" | ||
log = "0.4" | ||
percent-encoding = "1.0" | ||
serde = "1.0" | ||
serde_derive = "1.0" | ||
serde_json = "1.0" | ||
url = "1.7" | ||
|
||
edgelet-core = { path = "../edgelet-core" } | ||
edgelet-http = { path = "../edgelet-http" } | ||
edgelet-utils = { path = "../edgelet-utils" } | ||
|
||
[dev_dependencies] | ||
tokio-core = "0.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
|
||
use std::fmt; | ||
use std::fmt::Display; | ||
|
||
use failure::{Backtrace, Context, Fail}; | ||
use serde_json::Error as SerdeError; | ||
|
||
use edgelet_core::Error as CoreError; | ||
use edgelet_http::{Error as HttpError, ErrorKind as HttpErrorKind}; | ||
|
||
#[derive(Debug)] | ||
pub struct Error { | ||
inner: Context<ErrorKind>, | ||
} | ||
|
||
#[derive(Debug, Fail)] | ||
pub enum ErrorKind { | ||
#[fail(display = "Core error")] | ||
Core, | ||
#[fail(display = "Http error")] | ||
Http, | ||
#[fail(display = "Serde error")] | ||
Serde, | ||
#[fail(display = "DPS returned an empty response when a value was expected")] | ||
EmptyResponse, | ||
#[fail(display = "Invalid Tpm token")] | ||
InvalidTpmToken, | ||
} | ||
|
||
impl Fail for Error { | ||
fn cause(&self) -> Option<&Fail> { | ||
self.inner.cause() | ||
} | ||
|
||
fn backtrace(&self) -> Option<&Backtrace> { | ||
self.inner.backtrace() | ||
} | ||
} | ||
|
||
impl Display for Error { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
Display::fmt(&self.inner, f) | ||
} | ||
} | ||
|
||
impl Error { | ||
pub fn kind(&self) -> &ErrorKind { | ||
self.inner.get_context() | ||
} | ||
} | ||
|
||
impl From<ErrorKind> for Error { | ||
fn from(kind: ErrorKind) -> Error { | ||
Error { | ||
inner: Context::new(kind), | ||
} | ||
} | ||
} | ||
|
||
impl From<Context<ErrorKind>> for Error { | ||
fn from(inner: Context<ErrorKind>) -> Error { | ||
Error { inner } | ||
} | ||
} | ||
|
||
impl From<CoreError> for Error { | ||
fn from(error: CoreError) -> Error { | ||
Error { | ||
inner: error.context(ErrorKind::Core), | ||
} | ||
} | ||
} | ||
|
||
impl From<HttpError> for Error { | ||
fn from(error: HttpError) -> Error { | ||
Error { | ||
inner: error.context(ErrorKind::Http), | ||
} | ||
} | ||
} | ||
|
||
impl From<SerdeError> for Error { | ||
fn from(error: SerdeError) -> Error { | ||
Error { | ||
inner: error.context(ErrorKind::Serde), | ||
} | ||
} | ||
} | ||
|
||
impl From<Error> for HttpError { | ||
fn from(err: Error) -> HttpError { | ||
HttpError::from(err.context(HttpErrorKind::TokenSource)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
|
||
#![deny(warnings)] | ||
|
||
extern crate base64; | ||
extern crate chrono; | ||
#[macro_use] | ||
extern crate failure; | ||
extern crate futures; | ||
extern crate hyper; | ||
extern crate log; | ||
extern crate percent_encoding; | ||
extern crate serde; | ||
#[macro_use] | ||
extern crate serde_derive; | ||
extern crate serde_json; | ||
#[cfg(test)] | ||
extern crate tokio_core; | ||
extern crate url; | ||
|
||
extern crate edgelet_core; | ||
extern crate edgelet_http; | ||
extern crate edgelet_utils; | ||
|
||
pub mod error; | ||
mod model; | ||
pub mod registration; | ||
|
||
pub use model::{DeviceRegistration, TpmRegistrationResult}; |
Oops, something went wrong.