forked from baron/baron-sso
인증수단 세션 확인 추가
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import 'dart:convert';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'auth_token_store.dart';
|
||||
import 'http_client.dart';
|
||||
import 'web_window.dart';
|
||||
|
||||
@@ -266,7 +265,6 @@ class AuthProxyService {
|
||||
if (token != null && token.isNotEmpty) {
|
||||
headers['Authorization'] = 'Bearer $token';
|
||||
}
|
||||
final sessionId = _extractSessionIdFromJwt(token ?? AuthTokenStore.getToken() ?? '');
|
||||
final client = createHttpClient(withCredentials: true);
|
||||
try {
|
||||
final response = await client.post(
|
||||
@@ -274,8 +272,6 @@ class AuthProxyService {
|
||||
headers: headers,
|
||||
body: jsonEncode({
|
||||
'login_challenge': loginChallenge,
|
||||
if (sessionId != null && sessionId.isNotEmpty)
|
||||
'approved_session_id': sessionId,
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -290,35 +286,6 @@ class AuthProxyService {
|
||||
}
|
||||
}
|
||||
|
||||
static String? _extractSessionIdFromJwt(String token) {
|
||||
if (token.isEmpty) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
final parts = token.split('.');
|
||||
if (parts.length != 3) {
|
||||
return null;
|
||||
}
|
||||
final payload = utf8.decode(base64Url.decode(base64Url.normalize(parts[1])));
|
||||
final data = json.decode(payload) as Map<String, dynamic>;
|
||||
for (final key in ['sid', 'session_id', 'sessionId', 'jti']) {
|
||||
final value = data[key];
|
||||
if (value == null) {
|
||||
continue;
|
||||
}
|
||||
if (value is String && value.isNotEmpty) {
|
||||
return value;
|
||||
}
|
||||
final converted = value.toString();
|
||||
if (converted.isNotEmpty) {
|
||||
return converted;
|
||||
}
|
||||
}
|
||||
} catch (_) {
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static Future<Map<String, dynamic>> initiatePasswordReset(String loginId, {bool? drySend}) async {
|
||||
final url = Uri.parse('$_baseUrl/api/v1/auth/password/reset/initiate');
|
||||
|
||||
Reference in New Issue
Block a user