All Projects → Clancey → Simple_auth

Clancey / Simple_auth

Licence: mit
The Simplest way to Authenticate in Flutter

Programming Languages

dart
5743 projects

Projects that are alternatives of or similar to Simple auth

flutter simple dependency injection
A super simple dependency injection implementation for flutter that behaviours like any normal IOC container and does not rely on mirrors
Stars: ✭ 91 (-67.03%)
Mutual labels:  flutter-plugin
Pam reattach
Reattach to the user's GUI session on macOS during authentication (for Touch ID support in tmux)
Stars: ✭ 262 (-5.07%)
Mutual labels:  authentication
Kerberos.net
A Kerberos implementation built entirely in managed code.
Stars: ✭ 268 (-2.9%)
Mutual labels:  authentication
Accownt
🐮 Dead simple user account system so easy a cow could do it.
Stars: ✭ 255 (-7.61%)
Mutual labels:  authentication
Auth0 React
Auth0 SDK for React Single Page Applications (SPA)
Stars: ✭ 261 (-5.43%)
Mutual labels:  authentication
Flutter tts
Flutter Text to Speech package
Stars: ✭ 263 (-4.71%)
Mutual labels:  flutter-plugin
flutter qq ads
🔥🔥🔥 Flutter 广告插件 -- 优量汇 、广点通、腾讯广告(支持开屏、插屏、激励视频、Banner、信息流、视频贴片)
Stars: ✭ 51 (-81.52%)
Mutual labels:  flutter-plugin
Auth Boss
🔒 Become an Auth Boss. Learn about different authentication methodologies on the web.
Stars: ✭ 2,879 (+943.12%)
Mutual labels:  authentication
Flask Login
Flask user session management.
Stars: ✭ 2,952 (+969.57%)
Mutual labels:  authentication
Jwt
Vapor JWT provider
Stars: ✭ 266 (-3.62%)
Mutual labels:  authentication
Webauthn.io
The source code for webauthn.io, a demonstration of WebAuthn.
Stars: ✭ 252 (-8.7%)
Mutual labels:  authentication
Jwt Spring Security Demo
This is a demo for using JWT (JSON Web Token) with Spring Security and Spring Boot. I completely rewrote my first version. Now this solution is based on the code base from the JHipster Project. I tried to extract the minimal configuration and classes that are needed for JWT-Authentication and did some changes.
Stars: ✭ 2,843 (+930.07%)
Mutual labels:  authentication
Stream Chat Flutter
Stream Chat official Flutter SDK. Build your own chat experience using Dart and Flutter.
Stars: ✭ 220 (-20.29%)
Mutual labels:  flutter-plugin
Authenticationviewcontroller
A simple to use, standard interface for authenticating to oauth 2.0 protected endpoints via SFSafariViewController.
Stars: ✭ 254 (-7.97%)
Mutual labels:  authentication
Passcodeview
PasscodeView is an Android Library to easily and securely authenticate user with PIN code or using the fingerprint scanner.
Stars: ✭ 270 (-2.17%)
Mutual labels:  authentication
http middleware
A middleware library for Dart's http library.
Stars: ✭ 38 (-86.23%)
Mutual labels:  flutter-plugin
Proxy Login Automator
A single node.js script to automatically inject user/password to http proxy server via a local forwarder
Stars: ✭ 263 (-4.71%)
Mutual labels:  authentication
Qrcode scanner
🛠 Flutter QR code scanner plugin.
Stars: ✭ 274 (-0.72%)
Mutual labels:  flutter-plugin
Material Kit React
React Dashboard made with Material UI’s components. Our pro template contains features like TypeScript version, authentication system with Firebase and Auth0 plus many other
Stars: ✭ 3,465 (+1155.43%)
Mutual labels:  authentication
React Redux Firebase Authentication
🔥Boilerplate Project for Authentication with Firebase in React and Redux
Stars: ✭ 265 (-3.99%)
Mutual labels:  authentication

Simple Auth Pub Most apps need to make API calls. Every API needs authentication, yet no developer wants to deal with authentication. Simple Auth embeds authentication into the API so you dont need to deal with it.

This is a port of Clancey.SimpleAuth for Dart and Flutter

The network/api part including the generator was based off of Chopper by Hadrien Lejard

Join the chat at https://gitter.im/simple_auth/community

iOS: Build status

Android: Build status

Providers

Current Built in Providers

  • Azure Active Directory
  • Amazon
  • Dropbox
  • Facebook
  • Github
  • Google
  • Instagram
  • Linked In
  • Microsoft Live Connect
  • Keycloak
  • And of course any standard OAuth2/Basic Auth server.

Usage

var api = new simpleAuth.GoogleApi(
      "google", "client_id",clientSecret: "clientSecret",
      scopes: [
        "https://www.googleapis.com/auth/userinfo.email",
        "https://www.googleapis.com/auth/userinfo.profile"
      ]);
var request = new Request(HttpMethod.Get, "https://www.googleapis.com/oauth2/v1/userinfo?alt=json");
var userInfo = await api.send<UserInfo>(request);

That's it! If the user is not logged in, they will automatically be prompted. If their credentials are cached from a previous session, the api call proceeds! Expired tokens even automatically refresh.

Flutter Setup

Call SimpleAuthFlutter.init(); in your Main.Dart. Now Simple Auth can automatically present your login UI

Redirect

Google requires the following redirect: com.googleusercontent.apps.YOUR_CLIENT_ID

Simple Auth by default uses SFSafari on iOS and Chrome Tabs on Android.

This means normal http redirects cannot work. You will need to register a custom scheme for your app as a redirect. For most providers, you can create whatever you want. i.e. com.myapp.foo:/redirct

Android Manifest

you would then add the following to your Android manifest

<activity android:name="clancey.simpleauth.simpleauthflutter.SimpleAuthCallbackActivity" >
    <intent-filter android:label="simple_auth">
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="com.myapp.foo" />
    </intent-filter>
</activity>

For instagram, the above won't work, as it will only accept redirect URIs that start with https. Add the following instead:

    <activity android:name="clancey.simpleauth.simpleauthflutter.SimpleAuthCallbackActivity">

      <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="http" />
        <data android:scheme="https" />
        <data android:host="myflutterapp.com" />
      </intent-filter>
    </activity>

iOS & macOS

on iOS you need something like the following as your AppDelegate.m file under the Runner folder

#include "AppDelegate.h"
#include "GeneratedPluginRegistrant.h"
#import <Flutter/Flutter.h>
#import <simple_auth_flutter/SimpleAuthFlutterPlugin.h>

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application
    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  [GeneratedPluginRegistrant registerWithRegistry:self];
  // Override point for customization after application launch.
  return [super application:application didFinishLaunchingWithOptions:launchOptions];
}

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options{
    return [SimpleAuthFlutterPlugin checkUrl:url];
}

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation{
    return [SimpleAuthFlutterPlugin checkUrl:url];
}

@end

On macOS:

import Cocoa
import FlutterMacOS
import simple_auth_flutter

@NSApplicationMain
class AppDelegate: FlutterAppDelegate {
  override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
    return true
  }
    
    override func applicationDidFinishLaunching(_ notification: Notification) {
        let appleEventManager:NSAppleEventManager = NSAppleEventManager.shared()
        appleEventManager.setEventHandler(self, andSelector: #selector(AppDelegate.handleGetURLEvent(event:replyEvent:)), forEventClass: AEEventClass(kInternetEventClass), andEventID: AEEventID(kAEGetURL))

    }
    
    @objc func handleGetURLEvent(event: NSAppleEventDescriptor, replyEvent: NSAppleEventDescriptor) {
        let urlString = event.paramDescriptor(forKeyword: AEKeyword(keyDirectObject))?.stringValue!
        let url = URL(string: urlString!)!
        SimpleAuthFlutterPlugin.check(url);
    }
}

For iOS 11/macOS 10.15 and higher, you don't need to do anything else. On older versions the following is required in the info.plist

	<key>CFBundleURLTypes</key>
	<array>
		<dict>
			<key>CFBundleURLSchemes</key>
			<array>
				<string>com.myapp.foo</string>
			</array>
			<key>CFBundleURLName</key>
			<string>myappredirect</string>
		</dict>
	</array>

Note, if you want to avoid Apples mandatory user consent dialog

"foo" Wants to use "bar.com" to Sign In
This allows the app and website to share information about you.

add the lines above and set FooAuthenticator.useSSO = false; which will not use SFAuthenticationSession on iOS, and ASWebAuthenticationSession on macOS. This is the default behavior for the Keycloak provider.

Serialization

Json objects will automatically serialize if you conform to JsonSerializable

If you use the generator and you objects have the factory factory JsonSerializable.fromJson(Map<String, dynamic> json) your api calls will automatically Serialize/Deserialize

Or you can pass your own Converter to the api and handle conversion yourself.

Generator

Dart

pub run build_runner build

flutter

flutter packages pub run build_runner build

Add the following to your pubspec.yaml

dev_dependencies:
  simple_auth_generator:
  build_runner: ^0.8.0

The Generator is not required, however it will make things magical.

@GoogleApiDeclaration("GoogleTestApi","client_id",clientSecret: "client_secret", scopes: ["TestScope", "Scope2"])
abstract class GoogleTestDefinition {
  @Get(url: "https://www.googleapis.com/oauth2/v1/userinfo?alt=json")
  Future<Response<GoogleUser>> getCurrentUserInfo();
}

will generate a new Api for you that is easy to use!

var api = new GoogleTestApi("google");
var user = await api.getCurrentUserInfo();

For more examples, check out the example project

Contributor

TODO

  • Add more documentation
  • Add native flutter providers for google
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].