Skip to content
Snippets Groups Projects
Commit 70ea4576 authored by igorwork's avatar igorwork Committed by Markin Igor
Browse files

Integrate OAuth2 lib

parent 33957099
Branches
No related tags found
1 merge request!1Mobile app initial implementation.
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.vereign.mobile_app"> package="com.vereign.mobile_app">
<uses-permission android:name="android.permission.INTERNET" />
<!-- io.flutter.app.FlutterApplication is an android.app.Application that <!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method. calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide In most cases you can leave this as-is, but you if you want to provide
...@@ -31,6 +34,7 @@ ...@@ -31,6 +34,7 @@
<intent-filter> <intent-filter>
<action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" /> <category android:name="android.intent.category.BROWSABLE" />
<data <data
...@@ -38,5 +42,26 @@ ...@@ -38,5 +42,26 @@
android:host="app.vereign.com" /> android:host="app.vereign.com" />
</intent-filter> </intent-filter>
</activity> </activity>
<activity
android:name="net.openid.appauth.RedirectUriReceiverActivity"
tools:node="replace">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="app"
android:host="com.vereign.app"
android:path="/oauth2"/>
</intent-filter>
</activity>
<activity
android:name="github.showang.flutterappauthwrapper.OAuthActivity"
android:configChanges="orientation|screenSize"
android:theme="@style/Theme.AppCompat.Translucent" />
</application> </application>
</manifest> </manifest>
...@@ -5,4 +5,13 @@ ...@@ -5,4 +5,13 @@
Flutter draws its first frame --> Flutter draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item> <item name="android:windowBackground">@drawable/launch_background</item>
</style> </style>
<style name="Theme.AppCompat.Translucent" parent="@style/Theme.AppCompat.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">@null</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowAnimationStyle">@android:style/Animation</item>
<item name="android:statusBarColor">@android:color/transparent</item>
</style>
</resources> </resources>
org.gradle.jvmargs=-Xmx1536M org.gradle.jvmargs=-Xmx1536M
android.enableJetifier=true
android.useAndroidX=true
...@@ -17,7 +17,7 @@ class App extends StatefulWidget { ...@@ -17,7 +17,7 @@ class App extends StatefulWidget {
class _AppState extends State<App> { class _AppState extends State<App> {
StreamSubscription _sub; StreamSubscription _sub;
String _appMode = "oauth"; String _appMode = "app";
@override @override
initState() { initState() {
...@@ -51,7 +51,7 @@ class _AppState extends State<App> { ...@@ -51,7 +51,7 @@ class _AppState extends State<App> {
} }
updateAppMode(uri) { updateAppMode(uri) {
log("Uri ${uri?.toString()}");
if (uri?.path == "/oauth2") { if (uri?.path == "/oauth2") {
setState(() { setState(() {
_appMode = "oauth"; _appMode = "oauth";
......
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_web_browser/flutter_web_browser.dart'; import 'package:flutter_web_browser/flutter_web_browser.dart';
import 'package:flutter_app_auth_wrapper/flutter_app_auth_wrapper.dart';
import 'dart:developer'; import 'dart:developer';
class Home extends StatefulWidget { class Home extends StatefulWidget {
...@@ -10,8 +11,15 @@ class Home extends StatefulWidget { ...@@ -10,8 +11,15 @@ class Home extends StatefulWidget {
_HomeState createState() => _HomeState(); _HomeState createState() => _HomeState();
} }
String clientId = "222222";
String clientSecret = "22222222";
String redirectURL = "app://com.vereign.app/oauth2";
String authEndpoint = "https://gospodinbodurov.dev.vereign.com/api/oauth2/authorize";
String tokenEndpoint = "https://gospodinbodurov.dev.vereign.com/api/oauth2/token";
class _HomeState extends State<Home> { class _HomeState extends State<Home> {
final _links = ['vereign://app.vereign.com', 'vereign://app.vereign.com/oauth2', 'https://rosengeorgiev.dev.vereign.com', 'https://igormarkin.dev.vereign.com', 'https://gospodinbodurov.dev.vereign.com']; final _links = ['vereign://app.vereign.com', 'vereign://app.vereign.com/oauth2', 'testredirect://app.vereign.com', 'https://igormarkin.dev.vereign.com', 'https://gospodinbodurov.dev.vereign.com'];
@override @override
initState() { initState() {
...@@ -31,10 +39,26 @@ class _HomeState extends State<Home> { ...@@ -31,10 +39,26 @@ class _HomeState extends State<Home> {
} }
showMode(mode) { showMode(mode) {
log(mode);
if (mode == "app") { if (mode == "app") {
FlutterWebBrowser.openWebPage(url: 'https://app.vereign.com', androidToolbarColor: Colors.deepPurple); FlutterWebBrowser.openWebPage(url: 'https://app.vereign.com', androidToolbarColor: Colors.deepPurple);
} else if (mode == "oauth") { } else if (mode == "oauth") {
FlutterWebBrowser.openWebPage(url: 'https://app.vereign.com/oauth2', androidToolbarColor: Colors.deepPurple); FlutterAppAuthWrapper.startAuth(
AuthConfig(
clientId: clientId,
clientSecret: clientSecret,
redirectUrl: redirectURL,
state: "login",
prompt: "consent",
endpoint: AuthEndpoint(
auth: authEndpoint, token: tokenEndpoint),
scopes: [
"user_account_status",
"user_territory",
"user_profile"
],
),
);
} }
} }
......
...@@ -41,6 +41,13 @@ packages: ...@@ -41,6 +41,13 @@ packages:
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.0" version: "0.0.0"
flutter_app_auth_wrapper:
dependency: "direct main"
description:
name: flutter_app_auth_wrapper
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.1+3"
flutter_test: flutter_test:
dependency: "direct dev" dependency: "direct dev"
description: flutter description: flutter
...@@ -53,6 +60,20 @@ packages: ...@@ -53,6 +60,20 @@ packages:
relative: true relative: true
source: path source: path
version: "0.11.0" version: "0.11.0"
http:
dependency: "direct main"
description:
name: http
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.0+2"
http_parser:
dependency: transitive
description:
name: http_parser
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.3"
matcher: matcher:
dependency: transitive dependency: transitive
description: description:
......
...@@ -26,6 +26,8 @@ dependencies: ...@@ -26,6 +26,8 @@ dependencies:
# Use # Use
path: ./deps/flutter_web_browser path: ./deps/flutter_web_browser
uni_links: 0.2.0 uni_links: 0.2.0
http: ^0.12.0
flutter_app_auth_wrapper: ^0.1.1+3
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment