Move MSA Client ID to the same place as the others

MSA Client ID has been moved to CMakeLists.txt, and defaults to the
Client ID for the PolyMC application.

Removed secrets/notsecrets library, replace with (temporary?)
program_info subdirectory.
This commit is contained in:
Lenny McLennington 2021-12-20 02:41:08 +00:00
parent dcb57f1995
commit e6246a9306
No known key found for this signature in database
GPG Key ID: F0467078ECA45FCB
24 changed files with 37 additions and 112 deletions

2
.gitignore vendored
View File

@ -37,3 +37,5 @@ tags
branding/
secrets/
run/
.cache/

View File

@ -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 #######################################

View File

@ -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

View File

@ -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@";

View File

@ -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

View File

@ -76,8 +76,6 @@
#include <ganalytics.h>
#include <sys.h>
#include <Secrets.h>
#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.

View File

@ -104,8 +104,6 @@ public:
return m_accounts;
}
QString msaClientId() const;
Status status() const {
return m_status;
}

View File

@ -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)

View File

@ -2,6 +2,7 @@
#include <QNetworkRequest>
#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";

View File

@ -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<int, int> pos = cat->positionOf(current);
int column = pos.first;
int row = pos.second;

View File

@ -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()

View File

@ -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)

View File

@ -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.

View File

@ -1,40 +0,0 @@
#include "Secrets.h"
#include <array>
#include <cstdio>
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;
}
}

View File

@ -1,8 +0,0 @@
#pragma once
#include <QString>
#include <cstdint>
namespace Secrets {
bool hasMSAClientID();
QString getMSAClientID(uint8_t separator);
}

View File

@ -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)

View File

Before

Width:  |  Height:  |  Size: 100 KiB

After

Width:  |  Height:  |  Size: 100 KiB

5
program_info/README.md Normal file
View File

@ -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

View File

Before

Width:  |  Height:  |  Size: 8.9 KiB

After

Width:  |  Height:  |  Size: 8.9 KiB