fix(auth): flutter_web_auth_2 + PKCE manuel (retour OIDC fiable via CallbackActivity)
Build APK / build (push) Successful in 2m28s
Build APK / build (push) Successful in 2m28s
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
1fe4528b0b
commit
4a265e0fd2
+12
-23
@@ -2,7 +2,7 @@
|
||||
"""Patche le scaffold Android généré par `flutter create` :
|
||||
- permissions (internet + auto-install APK)
|
||||
- signature release depuis key.properties
|
||||
- schéma de redirection OIDC (flutter_appauth)
|
||||
- CallbackActivity flutter_web_auth_2 (retour OIDC, schéma nfteam.gamemanager)
|
||||
Lancé dans la CI après `flutter create`. Idempotent."""
|
||||
import os
|
||||
import re
|
||||
@@ -11,7 +11,7 @@ KSPW = os.environ["KSPW"]
|
||||
ALIAS = os.environ["ALIAS"]
|
||||
KEYSTORE_PATH = os.environ.get("KEYSTORE_PATH", os.path.abspath("gamemanager.keystore"))
|
||||
|
||||
# 1) key.properties (chemin absolu du keystore, robuste peu importe le cwd gradle)
|
||||
# 1) key.properties (chemin absolu du keystore)
|
||||
with open("android/key.properties", "w") as f:
|
||||
f.write(
|
||||
f"storePassword={KSPW}\n"
|
||||
@@ -20,39 +20,34 @@ with open("android/key.properties", "w") as f:
|
||||
f"storeFile={KEYSTORE_PATH}\n"
|
||||
)
|
||||
|
||||
# 2) AndroidManifest : permissions + App Link HTTPS (retour OIDC fiable)
|
||||
# 2) AndroidManifest : permissions + CallbackActivity OIDC
|
||||
man = "android/app/src/main/AndroidManifest.xml"
|
||||
s = open(man).read()
|
||||
# namespace tools (pour merger dans l'activity de flutter_appauth)
|
||||
if "xmlns:tools" not in s:
|
||||
s = s.replace("<manifest ", '<manifest xmlns:tools="http://schemas.android.com/tools" ', 1)
|
||||
perms = (
|
||||
'<uses-permission android:name="android.permission.INTERNET"/>\n'
|
||||
' <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>\n'
|
||||
)
|
||||
if "REQUEST_INSTALL_PACKAGES" not in s:
|
||||
s = s.replace("<application", perms + " <application", 1)
|
||||
# App Link https://gamemanager-api.nfteam.ovh/oidc/callback → capté par l'app
|
||||
applink = (
|
||||
' <activity android:name="net.openid.appauth.RedirectUriReceiverActivity" '
|
||||
'android:exported="true" tools:node="merge">\n'
|
||||
' <intent-filter android:autoVerify="true">\n'
|
||||
callback = (
|
||||
' <activity android:name="com.linusu.flutter_web_auth_2.CallbackActivity" '
|
||||
'android:exported="true">\n'
|
||||
' <intent-filter android:label="flutter_web_auth_2">\n'
|
||||
' <action android:name="android.intent.action.VIEW"/>\n'
|
||||
' <category android:name="android.intent.category.DEFAULT"/>\n'
|
||||
' <category android:name="android.intent.category.BROWSABLE"/>\n'
|
||||
' <data android:scheme="https" android:host="gamemanager-api.nfteam.ovh" '
|
||||
'android:path="/oidc/callback"/>\n'
|
||||
' <data android:scheme="nfteam.gamemanager"/>\n'
|
||||
' </intent-filter>\n'
|
||||
' </activity>\n'
|
||||
)
|
||||
if "gamemanager-api.nfteam.ovh" not in s:
|
||||
s = s.replace("</application>", applink + " </application>", 1)
|
||||
if "flutter_web_auth_2.CallbackActivity" not in s:
|
||||
s = s.replace("</application>", callback + " </application>", 1)
|
||||
open(man, "w").write(s)
|
||||
|
||||
# 3) build.gradle : signature + schéma OIDC
|
||||
# 3) build.gradle : signature release
|
||||
gr = "android/app/build.gradle"
|
||||
s = open(gr).read()
|
||||
# ⚠️ Rien n'est autorisé AVANT le bloc plugins {} → on insère juste avant `android {`
|
||||
# ⚠️ Rien avant plugins {} → insérer juste avant `android {`
|
||||
if "keystoreProperties" not in s:
|
||||
s = s.replace(
|
||||
"android {",
|
||||
@@ -62,12 +57,6 @@ if "keystoreProperties" not in s:
|
||||
'android {',
|
||||
1,
|
||||
)
|
||||
if "appAuthRedirectScheme" not in s:
|
||||
s = s.replace(
|
||||
"defaultConfig {",
|
||||
'defaultConfig {\n manifestPlaceholders += [appAuthRedirectScheme: "nfteam.gamemanager"]',
|
||||
1,
|
||||
)
|
||||
if "signingConfigs {" not in s:
|
||||
s = re.sub(
|
||||
r"(\n\s*buildTypes\s*\{)",
|
||||
|
||||
Reference in New Issue
Block a user