-
Notifications
You must be signed in to change notification settings - Fork 124
Add desktop Debug provider for App Check #1126
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
15f25e7
Add desktop Debug provider for App Check
a-maurice 3a0da8e
File formatting
a-maurice 82790b7
Fix lint errors
a-maurice 16dd372
Merge branch 'main' into am-app_check_desktop
a-maurice 9e40d0c
Address feedback
a-maurice eb8421a
Update debug_token_request.h
a-maurice File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,21 @@ | ||
// Copyright 2022 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
namespace firebase.app_check.fbs; | ||
|
||
table DebugTokenRequest { | ||
debug_token:string; | ||
} | ||
|
||
root_type DebugTokenRequest; |
This file contains hidden or 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,64 @@ | ||
// Copyright 2022 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#ifndef FIREBASE_APP_CHECK_SRC_DESKTOP_DEBUG_TOKEN_REQUEST_H_ | ||
#define FIREBASE_APP_CHECK_SRC_DESKTOP_DEBUG_TOKEN_REQUEST_H_ | ||
|
||
#include <string> | ||
#include <utility> | ||
|
||
#include "app/rest/request_json.h" | ||
#include "app_check/debug_token_request_generated.h" | ||
#include "app_check/debug_token_request_resource.h" | ||
#include "firebase/app.h" | ||
|
||
namespace firebase { | ||
namespace app_check { | ||
namespace internal { | ||
|
||
// The server url to exchange the debug token with for a attestation token. | ||
static const char* kDebugTokenRequestServerUrlBase = | ||
"https://firebaseappcheck.googleapis.com/v1beta/projects/"; | ||
// The header used to pass the project's API key. | ||
static const char* kDebugTokenRequestHeader = "X-Goog-Api-Key"; | ||
|
||
// Request to exchange the user provided Debug Token with a valid attestation | ||
// token. | ||
class DebugTokenRequest | ||
: public firebase::rest::RequestJson<fbs::DebugTokenRequest, | ||
fbs::DebugTokenRequestT> { | ||
public: | ||
explicit DebugTokenRequest(App* app) | ||
: RequestJson(debug_token_request_resource_data) { | ||
std::string server_url(kDebugTokenRequestServerUrlBase); | ||
server_url.append(app->options().project_id()); | ||
server_url.append("/apps/"); | ||
server_url.append(app->options().app_id()); | ||
server_url.append(":exchangeDebugToken"); | ||
set_url(server_url.c_str()); | ||
|
||
add_header(kDebugTokenRequestHeader, app->options().api_key()); | ||
} | ||
|
||
void SetDebugToken(std::string debug_token) { | ||
application_data_->debug_token = std::move(debug_token); | ||
UpdatePostFields(); | ||
} | ||
}; | ||
|
||
} // namespace internal | ||
} // namespace app_check | ||
} // namespace firebase | ||
|
||
#endif // FIREBASE_APP_CHECK_SRC_DESKTOP_DEBUG_TOKEN_REQUEST_H_ |
This file contains hidden or 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,22 @@ | ||
// Copyright 2022 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
namespace firebase.app_check.fbs; | ||
|
||
table TokenResponse { | ||
token:string; | ||
ttl:string; | ||
} | ||
|
||
root_type TokenResponse; |
This file contains hidden or 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,42 @@ | ||
// Copyright 2022 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#ifndef FIREBASE_APP_CHECK_SRC_DESKTOP_TOKEN_RESPONSE_H_ | ||
#define FIREBASE_APP_CHECK_SRC_DESKTOP_TOKEN_RESPONSE_H_ | ||
|
||
#include <string> | ||
|
||
#include "app/rest/response_json.h" | ||
#include "app_check/token_response_generated.h" | ||
#include "app_check/token_response_resource.h" | ||
#include "firebase/app.h" | ||
|
||
namespace firebase { | ||
namespace app_check { | ||
namespace internal { | ||
|
||
class TokenResponse : public firebase::rest::ResponseJson<fbs::TokenResponse, | ||
fbs::TokenResponseT> { | ||
public: | ||
TokenResponse() : ResponseJson(token_response_resource_data) {} | ||
|
||
const std::string& token() { return application_data_->token; } | ||
const std::string& ttl() { return application_data_->ttl; } | ||
}; | ||
|
||
} // namespace internal | ||
} // namespace app_check | ||
} // namespace firebase | ||
|
||
#endif // FIREBASE_APP_CHECK_SRC_DESKTOP_TOKEN_RESPONSE_H_ |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.