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
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/solidautheg/client-profile.jsonld",
"client_name": "Flutter Solid Authentication",
"application_type": "native",
"redirect_uris": [
"https://anusii.github.io/solidautheg/redirect.html",
"com.example.solidautheg://redirect",
"http://localhost:4400/redirect.html"
],
"post_logout_redirect_uris": [
"https://anusii.github.io/solidautheg/redirect.html",
"com.example.solidautheg://logout",
"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"
}
33 changes: 26 additions & 7 deletions example/lib/screens/LoginScreen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
library;

// Flutter imports:
import 'package:flutter/foundation.dart'
show defaultTargetPlatform, kIsWeb, TargetPlatform;
import 'package:flutter/material.dart';

//import 'package:solidautheg/models/RestAPI.dart';
Expand All @@ -45,6 +47,21 @@ import 'package:solidautheg/models/Constants.dart';
import 'package:solidautheg/screens/PrivateScreen.dart';
import 'package:solidautheg/screens/PublicScreen.dart';

/// The Solid-OIDC redirect URI for the current platform.
String _platformRedirectUri({String nativePath = 'redirect'}) {
if (kIsWeb) {
return '${Uri.base.origin}/redirect.html';
}
Comment on lines +52 to +54
switch (defaultTargetPlatform) {
case TargetPlatform.android:
case TargetPlatform.iOS:
case TargetPlatform.macOS:
return 'com.example.solidautheg://$nativePath';
default:
return 'http://localhost:4400/redirect.html';
}
}

class LoginScreen extends StatefulWidget {
const LoginScreen({super.key});

Expand All @@ -71,14 +88,16 @@ class _LoginScreenState extends State<LoginScreen> {
clientId:
'https://anushkavidanage.github.io/solid_auth/example_app/client-profile.jsonld',

/// Redirect URIs vary by platform:
/// Mobile: custom-scheme URI (e.g. com.example.solid.auth.example://redirect)
/// Web: redirect.html URL (e.g. https://anushkavidanage.github.io/.../redirect.html)
/// Desktop: fixed-port localhost (e.g. http://localhost:4400/redirect)
redirectUri: Uri.parse('http://localhost:4400/redirect'),
/// Redirect URI for the current platform, derived at runtime (see
/// [_platformRedirectUri]): the served app's origin on web, a custom
/// scheme on Android/iOS/macOS, a localhost loopback on Windows/Linux.
redirectUri: Uri.parse(_platformRedirectUri()),

/// Must match the redirectUri for the current platform.
postLogoutRedirectUri: Uri.parse('http://localhost:4400/redirect'),
/// Post-logout URI for the current platform. On native platforms this
/// uses the `logout` path so it matches the client identifier document's
/// `post_logout_redirect_uris` entry.
postLogoutRedirectUri:
Uri.parse(_platformRedirectUri(nativePath: 'logout')),

/// Solid-OIDC scopes. The `webid` scope is always added automatically.
scopes: SolidScopes.defaultScopes,
Expand Down
Loading
Loading