diff --git a/.gitignore b/.gitignore index 69dda72c4..d73f9f228 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,5 @@ tags branding/ secrets/ run/ + +.cache/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 8417be93e..b7018d1b6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,10 +79,13 @@ set(Launcher_PASTE_EE_API_KEY "utLvciUouSURFzfjPxLBf5W4ISsUX4pwBDF7N1AfZ" CACHE set(Launcher_IMGUR_CLIENT_ID "5b97b0713fba4a3" CACHE STRING "Client ID you can get from Imgur when you register an application") # Google analytics ID -set(Launcher_ANALYTICS_ID "UA-87731965-2" CACHE STRING "ID you can get from Google analytics") +set(Launcher_ANALYTICS_ID "" CACHE STRING "ID you can get from Google analytics") + +# MSA Client ID +set(Launcher_MSA_CLIENT_ID "17b47edd-c884-4997-926d-9e7f9a6b4647" CACHE STRING "Client ID you can get from Microsoft Identity Platform when you register an application") # Bug tracker URL -set(Launcher_BUG_TRACKER_URL "" CACHE STRING "URL for the bug tracker.") +set(Launcher_BUG_TRACKER_URL "https://github.com/PolyMC/PolyMC/issues" CACHE STRING "URL for the bug tracker.") # Discord URL set(Launcher_DISCORD_URL "" CACHE STRING "URL for the Discord guild.") @@ -90,9 +93,6 @@ set(Launcher_DISCORD_URL "" CACHE STRING "URL for the Discord guild.") # Subreddit URL set(Launcher_SUBREDDIT_URL "" CACHE STRING "URL for the subreddit.") -# Use the secrets library or a public stub? -option(Launcher_EMBED_SECRETS "Determines whether to embed secrets. Secrets are separate and non-public." OFF) - #### Check the current Git commit and branch include(GetGitRevisionDescription) get_git_head_revision(Launcher_GIT_REFSPEC Launcher_GIT_COMMIT) @@ -131,11 +131,7 @@ endif() ####################################### Secrets ####################################### -if(Launcher_EMBED_SECRETS) - add_subdirectory(secrets) -else() - add_subdirectory(notsecrets) -endif() +add_subdirectory(program_info) ####################################### Install layout ####################################### diff --git a/README.md b/README.md index 9c4856049..4c78e08c4 100644 --- a/README.md +++ b/README.md @@ -15,9 +15,9 @@ This is a **fork** of the MultiMC Launcher and not endorsed by MultiMC. The Poly - [ ] Packaging for Linux--Any help packaging for your favorite distro is appreciated! - [ ] Packaging for MacOS/Windows - [ ] Stop relying on MultiMC-Hosted metadata services -- [ ] Long-term solution for the MSA client ID issue - [ ] Remove references to MultiMC - [ ] Meson +- [x] Long-term solution for the MSA client ID issue - [x] Figure out a way to switch to GPL. ## Packages diff --git a/buildconfig/BuildConfig.cpp.in b/buildconfig/BuildConfig.cpp.in index 9e449aec7..66cb0f179 100644 --- a/buildconfig/BuildConfig.cpp.in +++ b/buildconfig/BuildConfig.cpp.in @@ -45,6 +45,7 @@ Config::Config() NEWS_RSS_URL = "@Launcher_NEWS_RSS_URL@"; PASTE_EE_KEY = "@Launcher_PASTE_EE_API_KEY@"; IMGUR_CLIENT_ID = "@Launcher_IMGUR_CLIENT_ID@"; + MSA_CLIENT_ID = "@Launcher_MSA_CLIENT_ID@"; META_URL = "@Launcher_META_URL@"; BUG_TRACKER_URL = "@Launcher_BUG_TRACKER_URL@"; diff --git a/buildconfig/BuildConfig.h b/buildconfig/BuildConfig.h index ac05f2881..2d847f944 100644 --- a/buildconfig/BuildConfig.h +++ b/buildconfig/BuildConfig.h @@ -79,6 +79,11 @@ public: * Client ID you can get from Imgur when you register an application */ QString IMGUR_CLIENT_ID; + + /** + * Client ID you can get from Microsoft Identity Platform when you register an application + */ + QString MSA_CLIENT_ID; /** * Metadata repository URL prefix diff --git a/launcher/Application.cpp b/launcher/Application.cpp index 72ed5e5aa..0d7eeaef3 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -76,8 +76,6 @@ #include #include -#include - #if defined Q_OS_WIN32 #ifndef WIN32_LEAN_AND_MEAN @@ -1559,10 +1557,6 @@ void Application::on_windowClose() } } -QString Application::msaClientId() const { - return Secrets::getMSAClientID('-'); -} - void Application::updateProxySettings(QString proxyTypeStr, QString addr, int port, QString user, QString password) { // Set the application proxy settings. diff --git a/launcher/Application.h b/launcher/Application.h index 1b2a2b603..982e22e32 100644 --- a/launcher/Application.h +++ b/launcher/Application.h @@ -104,8 +104,6 @@ public: return m_accounts; } - QString msaClientId() const; - Status status() const { return m_status; } diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt index 2dfc78b55..fceca8e23 100644 --- a/launcher/CMakeLists.txt +++ b/launcher/CMakeLists.txt @@ -935,7 +935,7 @@ target_link_libraries(Launcher_logic ganalytics ) -target_link_libraries(Launcher_logic secrets) +target_link_libraries(Launcher_logic) add_executable(${Launcher_Name} MACOSX_BUNDLE WIN32 main.cpp ${LAUNCHER_RCS}) target_link_libraries(${Launcher_Name} Launcher_logic) diff --git a/launcher/minecraft/auth/steps/MSAStep.cpp b/launcher/minecraft/auth/steps/MSAStep.cpp index be711f7e8..bc10aa4ed 100644 --- a/launcher/minecraft/auth/steps/MSAStep.cpp +++ b/launcher/minecraft/auth/steps/MSAStep.cpp @@ -2,6 +2,7 @@ #include +#include "BuildConfig.h" #include "minecraft/auth/AuthRequest.h" #include "minecraft/auth/Parsers.h" @@ -13,7 +14,7 @@ using Activity = Katabasis::Activity; MSAStep::MSAStep(AccountData* data, Action action) : AuthStep(data), m_action(action) { OAuth2::Options opts; opts.scope = "XboxLive.signin offline_access"; - opts.clientIdentifier = APPLICATION->msaClientId(); + opts.clientIdentifier = BuildConfig.MSA_CLIENT_ID; opts.authorizationUrl = "https://login.microsoftonline.com/consumers/oauth2/v2.0/devicecode"; opts.accessTokenUrl = "https://login.microsoftonline.com/consumers/oauth2/v2.0/token"; diff --git a/launcher/ui/instanceview/InstanceView.cpp b/launcher/ui/instanceview/InstanceView.cpp index 1f044866e..25aec1abe 100644 --- a/launcher/ui/instanceview/InstanceView.cpp +++ b/launcher/ui/instanceview/InstanceView.cpp @@ -835,15 +835,6 @@ QModelIndex InstanceView::moveCursor(QAbstractItemView::CursorAction cursorActio if(group_index < 0) return current; - auto real_group = m_groups[group_index]; - int beginning_row = 0; - for(auto group: m_groups) - { - if(group == real_group) - break; - beginning_row += group->numRows(); - } - QPair pos = cat->positionOf(current); int column = pos.first; int row = pos.second; diff --git a/launcher/ui/pages/global/AccountListPage.cpp b/launcher/ui/pages/global/AccountListPage.cpp index d3eb26554..87fcac86a 100644 --- a/launcher/ui/pages/global/AccountListPage.cpp +++ b/launcher/ui/pages/global/AccountListPage.cpp @@ -37,8 +37,6 @@ #include "BuildConfig.h" -#include "Secrets.h" - AccountListPage::AccountListPage(QWidget *parent) : QMainWindow(parent), ui(new Ui::AccountListPage) { @@ -74,7 +72,7 @@ AccountListPage::AccountListPage(QWidget *parent) updateButtonStates(); // Xbox authentication won't work without a client identifier, so disable the button if it is missing - ui->actionAddMicrosoft->setVisible(Secrets::hasMSAClientID()); + ui->actionAddMicrosoft->setVisible(BuildConfig.MSA_CLIENT_ID.size() != 0); } AccountListPage::~AccountListPage() diff --git a/notsecrets/CMakeLists.txt b/notsecrets/CMakeLists.txt deleted file mode 100644 index 00b132a36..000000000 --- a/notsecrets/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -add_library(secrets STATIC Secrets.cpp Secrets.h) -target_link_libraries(secrets Qt5::Core) -target_compile_definitions(secrets PUBLIC -DEMBED_SECRETS) -target_include_directories(secrets PUBLIC .) - -set(Launcher_CommonName "PolyMC") - -set(Launcher_Copyright "MultiMC Contributors" PARENT_SCOPE) -set(Launcher_Domain "multimc.org" PARENT_SCOPE) -set(Launcher_Name "${Launcher_CommonName}" PARENT_SCOPE) -set(Launcher_DisplayName "${Launcher_CommonName} 5" PARENT_SCOPE) -set(Launcher_UserAgent "${Launcher_CommonName}/5.0" PARENT_SCOPE) -set(Launcher_ConfigFile "polymc.cfg" PARENT_SCOPE) -set(Launcher_Git "https://github.com/MultiMC/Launcher" PARENT_SCOPE) - -set(Launcher_Branding_ICNS "notsecrets/Launcher.icns" PARENT_SCOPE) -set(Launcher_Branding_WindowsRC "notsecrets/launcher.rc" PARENT_SCOPE) -set(Launcher_Branding_LogoQRC "notsecrets/logo.qrc" PARENT_SCOPE) diff --git a/notsecrets/README.md b/notsecrets/README.md deleted file mode 100644 index dcc676991..000000000 --- a/notsecrets/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# PolyMC (Not) Secrets - -This is a dummy implementation of PolyMC's _Secrets_ library, used to store private information needed for: -- Application name and logo (and branding in general) -- Various URLs and API endpoints -- Your Microsoft Identity Platform client ID. **This is required to use Microsoft accounts to play!** - - If omitted, adding Microsoft accounts will be completely disabled. - -## MultiMC development - -In its current state, the `notsecrets` library is suitable for PolyMC code contributions. - -All you have to do is add the Microsoft client ID. See `Secrets.cpp` for details. diff --git a/notsecrets/Secrets.cpp b/notsecrets/Secrets.cpp deleted file mode 100644 index 6d2444a2d..000000000 --- a/notsecrets/Secrets.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include "Secrets.h" - -#include -#include - -namespace { - -/* - * This is the MSA client ID. It is confidential and should not be reused. - * You can obtain one for yourself by using azure app registration: - * https://docs.microsoft.com/en-us/azure/active-directory/develop/quickstart-register-app - * - * The app registration should: - * - Be only for personal accounts. - * - Not have any redirect URI. - * - Not have any platform. - * - Have no credentials. - * - No certificates. - * - No client secrets. - * - Enable 'Live SDK support' for access to XBox APIs. - * - Enable 'public client flows' for OAuth2 device flow. - * - * By putting one in here, you accept the terms and conditions for using the MS Identity Plaform and assume all responsibilities associated with it. - * See: https://docs.microsoft.com/en-us/legal/microsoft-identity-platform/terms-of-use - * - * If you intend to base your own launcher on this code, take care and customize this to obfuscate the client ID, so it cannot be trivially found by casual attackers. - */ - -QString MSAClientID = ""; -} - -namespace Secrets { -bool hasMSAClientID() { - return !MSAClientID.isEmpty(); -} - -QString getMSAClientID(uint8_t separator) { - return MSAClientID; -} -} diff --git a/notsecrets/Secrets.h b/notsecrets/Secrets.h deleted file mode 100644 index 6872b68ef..000000000 --- a/notsecrets/Secrets.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once -#include -#include - -namespace Secrets { -bool hasMSAClientID(); -QString getMSAClientID(uint8_t separator); -} diff --git a/program_info/CMakeLists.txt b/program_info/CMakeLists.txt new file mode 100644 index 000000000..f418f8b29 --- /dev/null +++ b/program_info/CMakeLists.txt @@ -0,0 +1,13 @@ +set(Launcher_CommonName "PolyMC") + +set(Launcher_Copyright "PolyMC Contributors" PARENT_SCOPE) +set(Launcher_Domain "github.com/PolyMC" PARENT_SCOPE) +set(Launcher_Name "${Launcher_CommonName}" PARENT_SCOPE) +set(Launcher_DisplayName "${Launcher_CommonName} 5" PARENT_SCOPE) +set(Launcher_UserAgent "${Launcher_CommonName}/5.0" PARENT_SCOPE) +set(Launcher_ConfigFile "polymc.cfg" PARENT_SCOPE) +set(Launcher_Git "https://github.com/PolyMC/Launcher" PARENT_SCOPE) + +set(Launcher_Branding_ICNS "program_info/Launcher.icns" PARENT_SCOPE) +set(Launcher_Branding_WindowsRC "program_info/launcher.rc" PARENT_SCOPE) +set(Launcher_Branding_LogoQRC "program_info/logo.qrc" PARENT_SCOPE) diff --git a/notsecrets/Launcher.icns b/program_info/Launcher.icns similarity index 100% rename from notsecrets/Launcher.icns rename to program_info/Launcher.icns diff --git a/notsecrets/Launcher.ico b/program_info/Launcher.ico similarity index 100% rename from notsecrets/Launcher.ico rename to program_info/Launcher.ico diff --git a/notsecrets/Launcher.manifest b/program_info/Launcher.manifest similarity index 100% rename from notsecrets/Launcher.manifest rename to program_info/Launcher.manifest diff --git a/program_info/README.md b/program_info/README.md new file mode 100644 index 000000000..01c4d02be --- /dev/null +++ b/program_info/README.md @@ -0,0 +1,5 @@ +# PolyMC Program Info + +This is PolyMC's program info which contains information about: +- Application name and logo (and branding in general) +- Various URLs and API endpoints diff --git a/notsecrets/genicons.sh b/program_info/genicons.sh similarity index 100% rename from notsecrets/genicons.sh rename to program_info/genicons.sh diff --git a/notsecrets/launcher.rc b/program_info/launcher.rc similarity index 100% rename from notsecrets/launcher.rc rename to program_info/launcher.rc diff --git a/notsecrets/logo.qrc b/program_info/logo.qrc similarity index 100% rename from notsecrets/logo.qrc rename to program_info/logo.qrc diff --git a/notsecrets/logo.svg b/program_info/logo.svg similarity index 100% rename from notsecrets/logo.svg rename to program_info/logo.svg