Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .lycheeignore
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ https://github.com/anusii/solidpod/blob/main/solidpodeg/README.md
https://server/POD_NAME/APP_NAME/data/FILE_PATH
https://server/alice/
https://server/alice/myapp/
https://anusii.github.io/solidpodeg/client-profile.jsonld

# 20260605 gjw Failing solid servers

Expand Down
25 changes: 25 additions & 0 deletions example/client-profile.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"@context": "https://www.w3.org/ns/solid/oidc-context.jsonld",
"client_id": "https://anusii.github.io/solidpodeg/client-profile.jsonld",
"client_name": "Solid Pod Demonstrator",
"application_type": "native",
"redirect_uris": [
"https://anusii.github.io/solidpodeg/redirect.html",
"com.example.solidpodeg://redirect",
"http://localhost:4400/redirect.html"
],
"post_logout_redirect_uris": [
"https://anusii.github.io/solidpodeg/redirect.html",
"com.example.solidpodeg://redirect",
"http://localhost:4400/redirect.html"
],
"scope": "openid profile offline_access webid",
"grant_types": [
"authorization_code",
"refresh_token"
],
"response_types": [
"code"
],
"token_endpoint_auth_method": "none"
}
38 changes: 26 additions & 12 deletions example/lib/constants/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

library;

import 'package:flutter/foundation.dart' show kIsWeb;
import 'package:flutter/material.dart';

const titleBackgroundColor = Color(0xFFF0E4D7);
Expand Down Expand Up @@ -57,17 +58,30 @@ demo:exampleData$fileName
''';
}

const clientIdVal =
'https://anushkavidanage.github.io/solidpod/example/client-profile.jsonld';
/// URL of the Solid-OIDC client identifier document. Must be publicly readable
/// and its own `client_id` field must equal this URL. The source document lives
/// in the project root as `client-profile.jsonld`.
const clientIdVal = 'https://anusii.github.io/solidpodeg/client-profile.jsonld';

const redirectUrisList = [
'https://anushkavidanage.github.io/solidpod/example/redirect.html',
'http://localhost:4400/redirect',
'com.example.demopod://redirect', // Was com.example.solidpodeg
];
/// Redirect URIs offered to the Solid-OIDC flow.
List<String> get redirectUrisList {
if (kIsWeb) {
return ['${Uri.base.origin}/redirect.html'];
}
return const [
'com.example.solidpodeg://redirect',
'http://localhost:4400/redirect.html',
];
}

const postLogoutRedirectUrisList = [
'https://anushkavidanage.github.io/solidpod/example/redirect.html',
'http://localhost:4400/redirect',
'com.example.demopod://redirect', // Was com.example.solidpodeg
];
/// Post-logout redirect URIs, derived the same origin-aware way as
/// [redirectUrisList].
List<String> get postLogoutRedirectUrisList {
if (kIsWeb) {
return ['${Uri.base.origin}/redirect.html'];
}
return const [
'com.example.solidpodeg://redirect',
'http://localhost:4400/redirect.html',
];
}
2 changes: 1 addition & 1 deletion example/support/flutter.mk
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ help::

.PHONY: chrome
chrome:
flutter run -d chrome
flutter run -d chrome --release --web-port=4400

# 20220503 gjw The following fails if the target files already exist -
# just needs to be run once.
Expand Down
20 changes: 16 additions & 4 deletions lib/src/solid/authenticate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ import 'package:solidpod/src/solid/utils/exceptions.dart'
import 'package:solidpod/src/solid/utils/misc.dart' show isUserLoggedIn;

/// Selects the appropriate redirect URI from [uris] based on the runtime
/// platform, using the URI format as the discriminator:
/// platform, using the URI format (and, on web, the origin) as the
/// discriminator:
///
/// | Platform | Matched format |
/// |---|---|
/// | Web | `https://` URI (same-origin BroadcastChannel requirement) |
/// | Web | The entry whose origin equals the app's current origin ([Uri.base]) |
/// | Android / iOS / macOS | Custom scheme URI (not `http://` or `https://`) |
/// | Desktop (Windows / Linux) | `http://localhost` loopback URI |
///
Expand All @@ -64,9 +65,20 @@ String pickRedirectUri(List<String> uris) {
if (uris.length == 1) return uris.first;

if (kIsWeb) {
final currentOrigin = Uri.base.origin;
return uris.firstWhere(
(u) => u.startsWith('https://'),
orElse: () => uris.first,
(u) {
final parsed = Uri.tryParse(u);
if (parsed == null) return false;
if (!parsed.isScheme('http') && !parsed.isScheme('https')) {
return false;
}
return parsed.origin == currentOrigin;
},
orElse: () => uris.firstWhere(
(u) => u.startsWith('https://'),
orElse: () => uris.first,
),
);
}
if (defaultTargetPlatform == TargetPlatform.android ||
Expand Down
Loading