-
Notifications
You must be signed in to change notification settings - Fork 434
314 lines (298 loc) · 14 KB
/
Copy pathidentity-stack.yml
File metadata and controls
314 lines (298 loc) · 14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
name: Identity stack
# Focused, fast PR check for the OidcClient / SystemBrowser / AppleSignIn /
# *Connect identity stack. Triggers only when files in the identity surface
# change, so it pages reviewers within a couple of minutes instead of waiting
# for the full PR matrix.
#
# Coverage:
# - linux-tests : compiles core, runs OidcCoreTest + the existing
# Oauth2/Login/*Connect unit tests, builds the Maven
# plugin (so IPhoneBuilder + AndroidGradleBuilder scanner
# changes can't bit-rot), packages the Android port
# (verifies new Java native impls bundle correctly), and
# javac-compiles the UniversalSignInDemo sample against
# the freshly built core jar to catch API drift.
# - sample-secrets : trivial grep scan that fails if real-looking credentials
# appear in the demo sample.
# - macos-clang : runs `clang -fsyntax-only` on both new iOS native
# sources under the host Xcode SDK -- catches Obj-C
# typos and API misuse before the change ever reaches
# the build cloud.
on:
workflow_dispatch: {}
pull_request:
branches: [ master ]
paths:
- 'CodenameOne/src/com/codename1/io/oidc/**'
- 'CodenameOne/src/com/codename1/io/webauthn/**'
- 'CodenameOne/src/com/codename1/io/Oauth2.java'
- 'CodenameOne/src/com/codename1/io/AccessToken.java'
- 'CodenameOne/src/com/codename1/social/**'
- 'Ports/iOSPort/nativeSources/CN1OidcBrowser.*'
- 'Ports/iOSPort/nativeSources/CN1AppleSignIn.*'
- 'Ports/iOSPort/nativeSources/CN1WebAuthn.*'
- 'Ports/iOSPort/nativeSources/CodenameOne_GLViewController.h'
- 'Ports/iOSPort/src/com/codename1/io/oidc/**'
- 'Ports/iOSPort/src/com/codename1/io/webauthn/**'
- 'Ports/iOSPort/src/com/codename1/social/AppleSignInNativeImpl.java'
- 'Ports/iOSPort/src/com/codename1/impl/ios/IOSNative.java'
- 'Ports/Android/src/com/codename1/io/oidc/**'
- 'Ports/Android/src/com/codename1/io/webauthn/**'
- 'Ports/Android/src/com/codename1/social/AppleSignInNativeImpl.java'
- 'maven/codenameone-maven-plugin/src/main/java/com/codename1/builders/IPhoneBuilder.java'
- 'maven/codenameone-maven-plugin/src/main/java/com/codename1/builders/AndroidGradleBuilder.java'
- 'maven/core-unittests/src/test/java/com/codename1/io/oidc/**'
- 'maven/core-unittests/src/test/java/com/codename1/io/webauthn/**'
- 'maven/core-unittests/src/test/java/com/codename1/io/Oauth2*'
- 'maven/core-unittests/src/test/java/com/codename1/social/**'
- 'Samples/samples/UniversalSignInDemo/**'
- 'docs/developer-guide/Authentication-And-Identity.asciidoc'
- '.github/workflows/identity-stack.yml'
push:
branches: [ master ]
paths:
- 'CodenameOne/src/com/codename1/io/oidc/**'
- 'CodenameOne/src/com/codename1/io/webauthn/**'
- 'CodenameOne/src/com/codename1/io/Oauth2.java'
- 'CodenameOne/src/com/codename1/social/**'
- 'Ports/iOSPort/nativeSources/CN1OidcBrowser.*'
- 'Ports/iOSPort/nativeSources/CN1AppleSignIn.*'
- 'Ports/iOSPort/nativeSources/CN1WebAuthn.*'
- 'Ports/iOSPort/src/com/codename1/io/oidc/**'
- 'Ports/iOSPort/src/com/codename1/io/webauthn/**'
- 'Ports/iOSPort/src/com/codename1/social/AppleSignInNativeImpl.java'
- 'Ports/iOSPort/src/com/codename1/impl/ios/IOSNative.java'
- 'Ports/Android/src/com/codename1/io/oidc/**'
- 'Ports/Android/src/com/codename1/io/webauthn/**'
- 'Ports/Android/src/com/codename1/social/AppleSignInNativeImpl.java'
- 'maven/codenameone-maven-plugin/src/main/java/com/codename1/builders/IPhoneBuilder.java'
- 'maven/codenameone-maven-plugin/src/main/java/com/codename1/builders/AndroidGradleBuilder.java'
- 'maven/core-unittests/src/test/java/com/codename1/io/oidc/**'
- 'maven/core-unittests/src/test/java/com/codename1/io/webauthn/**'
- 'Samples/samples/UniversalSignInDemo/**'
- '.github/workflows/identity-stack.yml'
permissions:
contents: read
# Required to pull the pr-ci-container image from ghcr.io.
packages: read
concurrency:
group: identity-stack-${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true
jobs:
linux-tests:
name: Core tests, plugin & Android compile, sample javac
runs-on: ubuntu-latest
# Same container the main PR workflow uses; it ships JDK 8/17/21 and
# cn1-binaries pre-staged at /opt/cn1-binaries.
container: ghcr.io/codenameone/codenameone/pr-ci-container:latest
timeout-minutes: 20
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v6
- name: Select JDK 8
run: |
echo "JAVA_HOME=${JAVA_HOME_8}" >> "$GITHUB_ENV"
echo "${JAVA_HOME_8}/bin" >> "$GITHUB_PATH"
- name: Cache Maven repository
uses: actions/cache@v5
with:
path: ~/.m2/repository
key: ${{ runner.os }}-m2-identity-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-m2-identity-
${{ runner.os }}-m2-
- name: Stage cn1-binaries (required by maven-plugin tests)
run: |
set -euo pipefail
rm -rf maven/target/cn1-binaries
mkdir -p maven/target
cp -r /opt/cn1-binaries maven/target/cn1-binaries
- name: Run identity-stack unit tests
working-directory: maven
run: |
set -euo pipefail
# Targeted run: OidcCoreTest is the new suite; the *Connect / Login /
# Oauth2 tests cover backward-compat for the changes in Login.java
# and friends.
mvn -B -Dmaven.javadoc.skip=true \
-DunitTests=true \
-Plocal-dev-javase \
-P unittests \
-pl core-unittests -am \
test \
-Dtest='OidcCoreTest,WebAuthnCoreTest,Oauth2Test,Oauth2RefreshTokenRequestTest,GoogleConnectTest,FacebookConnectTest,LoginTest,Login1Test,LoginExtrasTest' \
-Dsurefire.failIfNoSpecifiedTests=false
- name: Compile Maven plugin (verifies IPhoneBuilder + AndroidGradleBuilder scanner edits)
working-directory: maven
env:
CN1_BINARIES: ${{ github.workspace }}/maven/target/cn1-binaries
run: |
set -euo pipefail
# `-am` (also-make) pulls in the plugin's intra-repo deps
# (designer, parparvm, ios bundle, javase, android, java-runtime).
# Without it the build can't resolve those SNAPSHOT artifacts
# because only core / factory / core-unittests landed in the
# local repo from the previous step.
mvn -B -Dmaven.javadoc.skip=true \
-pl codenameone-maven-plugin -am \
-Plocal-dev-javase \
-Dcn1.binaries="${CN1_BINARIES}" \
-DskipTests \
install
- name: Package Android port (verifies new Java sources bundle correctly)
run: |
set -euo pipefail
(cd maven && mvn -B -Dmaven.javadoc.skip=true \
-pl android -am \
-Plocal-dev-javase \
-DskipTests \
package)
BUNDLE="maven/android/target/classes/com/codename1/android/android_port_sources.jar"
if [ ! -f "${BUNDLE}" ]; then
echo "::error::android_port_sources.jar not produced at ${BUNDLE}"
exit 1
fi
# Capture the listing once into a variable rather than re-piping
# `unzip -l | grep -q` per file. With pipefail set, `grep -q` exits
# as soon as it finds a match and SIGPIPEs unzip (status 141);
# the resulting non-zero pipeline status was being misread as
# "no match" even though the bundle actually contained the file.
LISTING="$(unzip -l "${BUNDLE}")"
for required in \
com/codename1/io/oidc/OidcBrowserNativeImpl.java \
com/codename1/io/webauthn/WebAuthnNativeImpl.java \
com/codename1/social/AppleSignInNativeImpl.java; do
if ! grep -qF "${required}" <<<"${LISTING}"; then
echo "::error::${required} missing from android_port_sources.jar"
echo "Bundle listing (oidc / webauthn / social entries):"
grep -E "oidc|webauthn|social" <<<"${LISTING}" || true
exit 1
fi
done
- name: Compile UniversalSignInDemo against built core
run: |
set -euo pipefail
CORE_CLASSES="maven/core/target/classes"
if [ ! -d "${CORE_CLASSES}" ]; then
echo "::error::core not built yet at ${CORE_CLASSES}"
exit 1
fi
mkdir -p target/sample-check
# JDK 8 is fine for the sample -- it deliberately avoids Java 8+
# syntax to match the broader Codename One source level.
"${JAVA_HOME}/bin/javac" \
-source 1.8 -target 1.8 \
-Xlint:-options \
-cp "${CORE_CLASSES}" \
-d target/sample-check \
Samples/samples/UniversalSignInDemo/UniversalSignInDemo.java
test -f target/sample-check/com/codename1/samples/UniversalSignInDemo.class
sample-secrets:
name: Scan demo sample for accidental credentials
runs-on: ubuntu-latest
timeout-minutes: 3
steps:
- uses: actions/checkout@v6
- name: Reject real-looking secrets in identity sources & demo
run: |
set -euo pipefail
# Patterns: JWTs, Firebase web API keys (AIza...), Google client IDs
# (numeric-prefixed apps.googleusercontent.com), hex blobs >=32 chars,
# private-key headers, GitHub PATs, AWS keys.
PATTERN='eyJ[A-Za-z0-9_-]{20,}|[0-9]{6,}\.apps\.googleusercontent\.com|AIza[0-9A-Za-z_-]{30,}|sk-[A-Za-z0-9]{20,}|[0-9a-f]{32,}|BEGIN (RSA|EC|PRIVATE) KEY|ghp_[A-Za-z0-9]{20,}|AKIA[0-9A-Z]{16}'
TARGETS=(
Samples/samples/UniversalSignInDemo
CodenameOne/src/com/codename1/io/oidc
CodenameOne/src/com/codename1/social/AppleSignIn.java
CodenameOne/src/com/codename1/social/AppleSignInCallback.java
CodenameOne/src/com/codename1/social/AppleSignInNative.java
CodenameOne/src/com/codename1/social/AppleSignInResult.java
CodenameOne/src/com/codename1/social/Auth0Connect.java
CodenameOne/src/com/codename1/social/FirebaseAuth.java
CodenameOne/src/com/codename1/social/MicrosoftConnect.java
CodenameOne/src/com/codename1/io/webauthn
)
# `|| true` is intentional: grep -E exits 1 when there are zero
# matches, which is the success case.
HITS=$(grep -rEn "$PATTERN" "${TARGETS[@]}" 2>/dev/null || true)
if [ -n "$HITS" ]; then
echo "::error::Real-looking credentials found in identity-stack files:"
echo "$HITS"
exit 1
fi
echo "No credential leaks detected."
macos-clang:
name: Clang syntax check for iOS native sources
runs-on: macos-15
timeout-minutes: 10
steps:
- uses: actions/checkout@v6
- name: Show Xcode toolchain
run: |
xcodebuild -version
xcrun --show-sdk-path --sdk iphoneos
- name: Clang -fsyntax-only on new iOS native impls
run: |
set -euo pipefail
cd Ports/iOSPort/nativeSources
SDK="$(xcrun --show-sdk-path --sdk iphoneos)"
if [ ! -d "$SDK" ]; then
echo "::error::No iPhoneOS SDK available on this runner"
exit 1
fi
# The .m files include "xmlvm.h" and use ParparVM's CN1_THREAD_*
# macros. Those live in the ParparVM build pipeline, not in this
# checkout, so we stage a minimal shim header that defines the
# types and macros the .m files reference. The real header on the
# build cloud supplies richer definitions; this shim is enough to
# exercise everything clang cares about for -fsyntax-only.
STUB="$(mktemp -d)"
cat > "$STUB/xmlvm.h" <<'EOF'
typedef void* JAVA_OBJECT;
typedef int JAVA_BOOLEAN;
typedef int JAVA_INT;
typedef long JAVA_LONG;
typedef void JAVA_VOID;
#define JAVA_TRUE 1
#define JAVA_FALSE 0
#define JAVA_NULL 0
#define POOL_BEGIN()
#define POOL_END()
typedef void* CODENAME_ONE_THREAD_STATE;
// _SINGLE_ARG short-circuits the override block in the real
// CodenameOne_GLViewController.h so our threadStateData-bearing
// expansions survive the include.
#define CN1_THREAD_STATE_SINGLE_ARG
#define CN1_THREAD_STATE_MULTI_ARG void* threadStateData,
#define CN1_THREAD_STATE_PASS_ARG threadStateData,
#define CN1_THREAD_STATE_PASS_SINGLE_ARG threadStateData
#define CN1_THREAD_GET_STATE_PASS_ARG threadStateData,
#define CN1_THREAD_GET_STATE_PASS_SINGLE_ARG threadStateData
EOF
# Exercise BOTH configurations -- the "stubs" path (apps that
# don't reference com.codename1.io.oidc / AppleSignIn) and the
# "full" path (apps that do). IPhoneBuilder flips the macros on
# via the classpath scanner; we want either to keep building.
for label in stubs full; do
extra=""
if [ "$label" = full ]; then
extra="-DCN1_INCLUDE_OIDC -DCN1_INCLUDE_APPLESIGNIN -DCN1_INCLUDE_WEBAUTHN"
fi
echo "::group::clang $label"
xcrun --sdk iphoneos clang \
-fsyntax-only \
-arch arm64 \
-fobjc-arc \
-Werror=incompatible-pointer-types \
-Werror=objc-method-access \
-Wno-unused-parameter \
-I"$STUB" \
-DNEW_CODENAME_ONE_VM=1 \
$extra \
CN1OidcBrowser.m \
CN1AppleSignIn.m \
CN1WebAuthn.m
echo "::endgroup::"
done