Compare commits
2 Commits
7a757248c7
...
09f68e7a6e
Author | SHA1 | Date | |
---|---|---|---|
![]() |
09f68e7a6e | ||
![]() |
846ef5bf1c |
@ -101,7 +101,6 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
final uptime = await client.run('uptime');
|
final uptime = await client.run('uptime');
|
||||||
print(uptime);
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_output = utf8.decode(uptime);
|
_output = utf8.decode(uptime);
|
||||||
});
|
});
|
||||||
@ -387,7 +386,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
return mainPage;
|
return mainPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
var title;
|
Widget title;
|
||||||
var children = <Widget>[];
|
var children = <Widget>[];
|
||||||
var actions = [
|
var actions = [
|
||||||
TextButton(onPressed: authentikApiState.exit, child: Text("Cancel")),
|
TextButton(onPressed: authentikApiState.exit, child: Text("Cancel")),
|
||||||
@ -472,9 +471,6 @@ class AuthentikUserSettingsChangeDialogState extends ChangeNotifier {
|
|||||||
List<String> get keysToKeep => _keysToKeep;
|
List<String> get keysToKeep => _keysToKeep;
|
||||||
|
|
||||||
Future<oauth2.Client?> getOAuth2Client() async {
|
Future<oauth2.Client?> getOAuth2Client() async {
|
||||||
// This is a placeholder for OAuth2 client initialization.
|
|
||||||
// Replace with your actual OAuth2 client setup.
|
|
||||||
|
|
||||||
final authorizationEndpoint = Uri.parse(
|
final authorizationEndpoint = Uri.parse(
|
||||||
'https://auth.leinelab.org/application/o/authorize/',
|
'https://auth.leinelab.org/application/o/authorize/',
|
||||||
);
|
);
|
||||||
@ -484,23 +480,10 @@ class AuthentikUserSettingsChangeDialogState extends ChangeNotifier {
|
|||||||
);
|
);
|
||||||
|
|
||||||
final identifier = 'UwSMm8gTwBTUURSaxp5uPpuwX1OkGO4FRHeO9v3i';
|
final identifier = 'UwSMm8gTwBTUURSaxp5uPpuwX1OkGO4FRHeO9v3i';
|
||||||
final secret = null; // = 'my client secret';
|
final secret = null;
|
||||||
|
|
||||||
final redirectUrl = Uri.parse('http://localhost:30165/');
|
final redirectUrl = Uri.parse('http://localhost:30165/');
|
||||||
|
|
||||||
// final credentialsFile = File('~/.myapp/credentials.json');
|
|
||||||
|
|
||||||
// //....
|
|
||||||
|
|
||||||
// var exists = await credentialsFile.exists();
|
|
||||||
|
|
||||||
// if (exists) {
|
|
||||||
// var credentials = oauth2.Credentials.fromJson(
|
|
||||||
// await credentialsFile.readAsString(),
|
|
||||||
// );
|
|
||||||
// return oauth2.Client(credentials, identifier: identifier, secret: secret);
|
|
||||||
// }
|
|
||||||
|
|
||||||
var grant = oauth2.AuthorizationCodeGrant(
|
var grant = oauth2.AuthorizationCodeGrant(
|
||||||
identifier,
|
identifier,
|
||||||
authorizationEndpoint,
|
authorizationEndpoint,
|
||||||
@ -513,18 +496,19 @@ class AuthentikUserSettingsChangeDialogState extends ChangeNotifier {
|
|||||||
scopes: ["profile", "email", "goauthentik.io/api", "openid"],
|
scopes: ["profile", "email", "goauthentik.io/api", "openid"],
|
||||||
);
|
);
|
||||||
|
|
||||||
// TODO: clicking the button twice might try to bind the server twice
|
|
||||||
server = await HttpServer.bind("127.0.0.1", 30165);
|
server = await HttpServer.bind("127.0.0.1", 30165);
|
||||||
|
|
||||||
await launchUrl(authorizationUrl);
|
await launchUrl(authorizationUrl);
|
||||||
|
|
||||||
var queryParameters;
|
|
||||||
|
|
||||||
if (server == null) {
|
if (server == null) {
|
||||||
// exit() might have been called before we arrived here.
|
// exit() might have been called before we arrived here.
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// When the http server receives a request, we store the query parameters,
|
||||||
|
// so the oauth2 client can handle the response.
|
||||||
|
Map<String, String>? queryParameters;
|
||||||
|
|
||||||
await server!.forEach((HttpRequest request) {
|
await server!.forEach((HttpRequest request) {
|
||||||
request.response.write(
|
request.response.write(
|
||||||
'Success! You can close this window now and go back to the app.',
|
'Success! You can close this window now and go back to the app.',
|
||||||
@ -534,7 +518,12 @@ class AuthentikUserSettingsChangeDialogState extends ChangeNotifier {
|
|||||||
server!.close();
|
server!.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
return await grant.handleAuthorizationResponse(queryParameters);
|
if (queryParameters == null) {
|
||||||
|
// If we did not receive any query parameters, exit
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return await grant.handleAuthorizationResponse(queryParameters!);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> start(String currentKey) async {
|
Future<void> start(String currentKey) async {
|
||||||
@ -682,13 +671,13 @@ class KeepOrDeleteKey extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
|
|
||||||
final buttonStyleKeepActive = ButtonStyle(
|
final buttonStyleKeepActive = ButtonStyle(
|
||||||
backgroundColor: MaterialStateProperty.all(Colors.blue),
|
backgroundColor: WidgetStateProperty.all(Colors.blue),
|
||||||
foregroundColor: MaterialStateProperty.all(Colors.white),
|
foregroundColor: WidgetStateProperty.all(Colors.white),
|
||||||
);
|
);
|
||||||
|
|
||||||
final buttonStyleDeleteActive = ButtonStyle(
|
final buttonStyleDeleteActive = ButtonStyle(
|
||||||
backgroundColor: MaterialStateProperty.all(Colors.red),
|
backgroundColor: WidgetStateProperty.all(Colors.red),
|
||||||
foregroundColor: MaterialStateProperty.all(Colors.white),
|
foregroundColor: WidgetStateProperty.all(Colors.white),
|
||||||
);
|
);
|
||||||
|
|
||||||
ButtonStyle? buttonStyleKeep;
|
ButtonStyle? buttonStyleKeep;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user