forked from Nexus/nexus
OAuth Support (#53)
Rips out the old auth method, adds OAuth support. Fixes #51. Tested Platforms: - [x] Linux - [x] Flatpak - [x] Native (Nix) - [x] Android - [ ] Windows - [ ] MacOS Reviewed-on: Nexus/nexus#53
This commit is contained in:
parent
5df975f607
commit
7d106ad3a2
86 changed files with 558 additions and 1344 deletions
43
lib/models/requests/oauth/get_auth_url.dart
Normal file
43
lib/models/requests/oauth/get_auth_url.dart
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
import "dart:math";
|
||||
|
||||
import "package:fast_immutable_collections/fast_immutable_collections.dart";
|
||||
import "package:freezed_annotation/freezed_annotation.dart";
|
||||
part "get_auth_url.freezed.dart";
|
||||
part "get_auth_url.g.dart";
|
||||
|
||||
@freezed
|
||||
abstract class OAuthGetAuthUrl with _$OAuthGetAuthUrl {
|
||||
const factory OAuthGetAuthUrl({
|
||||
required ResponseMode responseMode,
|
||||
required Uri homeserverUrl,
|
||||
required Uri redirectUri,
|
||||
required IList<String> scopes,
|
||||
required String clientId,
|
||||
String? userIdHint,
|
||||
}) = _OAuthGetAuthUrl;
|
||||
|
||||
factory OAuthGetAuthUrl.fromJson(Map<String, Object?> json) =>
|
||||
_$OAuthGetAuthUrlFromJson(json);
|
||||
}
|
||||
|
||||
abstract class Scope {
|
||||
static final openid = "openid";
|
||||
static final email = "email";
|
||||
static final clientApi = "urn:matrix:client:api:*";
|
||||
|
||||
static final _deviceChars = IList(
|
||||
("ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
"abcdefghijklmnopqrstuvwxyz"
|
||||
"0123456789"
|
||||
"-._~")
|
||||
.split(""),
|
||||
);
|
||||
|
||||
static String get _deviceId =>
|
||||
_deviceChars.shuffle(Random.secure()).sublist(0, 10).join();
|
||||
|
||||
static String get device => "urn:matrix:client:device:$_deviceId";
|
||||
}
|
||||
|
||||
@JsonEnum(fieldRename: .snake)
|
||||
enum ResponseMode { query, fragment }
|
||||
Loading…
Reference in a new issue