All Projects → Muhesh7 → flutter_dauth

Muhesh7 / flutter_dauth

Licence: MIT license
A flutter package for authentication with DAuth(an OAuth2 based SSO (Single Sign On) for NITT students) authorisations service on behalf of the resource-owner/user.

Programming Languages

dart
5743 projects
shell
77523 projects

Projects that are alternatives of or similar to flutter dauth

flutter bottom reveal
An animated bottom reveal widget
Stars: ✭ 15 (-58.33%)
Mutual labels:  flutter-package
date field
Flutter DateField and DateFormField
Stars: ✭ 33 (-8.33%)
Mutual labels:  flutter-package
wasm.dart
WebAssembly virtual machine for Dart [work in progress]
Stars: ✭ 43 (+19.44%)
Mutual labels:  flutter-package
route transitions
A flutter library containing useful animations and friendly functions for routing 🚦
Stars: ✭ 43 (+19.44%)
Mutual labels:  flutter-package
sounds
Flutter plugin for sound. Audio recorder and player.
Stars: ✭ 74 (+105.56%)
Mutual labels:  flutter-package
research.package
A Flutter package implementing support for surveys like ResearchStack and ResearchKit
Stars: ✭ 43 (+19.44%)
Mutual labels:  flutter-package
scrollytell
Cross-platform Scrolly Telling library built using Flutter.
Stars: ✭ 46 (+27.78%)
Mutual labels:  flutter-package
flutter section table view
A iOS like table view including section, row, section header and divider
Stars: ✭ 73 (+102.78%)
Mutual labels:  flutter-package
flutter scatter
A widget that displays a collection of dispersed and non-overlapping children
Stars: ✭ 85 (+136.11%)
Mutual labels:  flutter-package
flutter google maps
A Flutter plugin for integrating Google Maps in iOS, Android and Web applications. It is a wrapper of google_maps_flutter for Mobile and google_maps for Web.
Stars: ✭ 86 (+138.89%)
Mutual labels:  flutter-package
flutter-simple-url-preview
Simple url preview package for flutter
Stars: ✭ 30 (-16.67%)
Mutual labels:  flutter-package
Liquid
An advance flutter UI Kit for developing responsive, cross platform applications.
Stars: ✭ 27 (-25%)
Mutual labels:  flutter-package
link text
Easy to use text widget for Flutter apps, which converts inlined urls into working, clickable links
Stars: ✭ 20 (-44.44%)
Mutual labels:  flutter-package
fancy bar
A fancy yet beautiful animated widget for your Flutter apps
Stars: ✭ 33 (-8.33%)
Mutual labels:  flutter-package
Motion-Tab-Bar
A beautiful animated flutter widget package library. The tab bar will attempt to use your current theme out of the box, however you may want to theme it.
Stars: ✭ 237 (+558.33%)
Mutual labels:  flutter-package
glassmorphism
Glassmorphic UI Package For Flutter || UI ||
Stars: ✭ 45 (+25%)
Mutual labels:  flutter-package
code editor
A code editor (dart, js, html, ...) for Flutter with syntax highlighting and custom theme.
Stars: ✭ 48 (+33.33%)
Mutual labels:  flutter-package
dough
This package provides some widgets you can use to create a smooshy UI.
Stars: ✭ 518 (+1338.89%)
Mutual labels:  flutter-package
flutter-package-selection menu
A flutter widget, highly customizable, to select an item from a list of items.
Stars: ✭ 32 (-11.11%)
Mutual labels:  flutter-package
open route service
An encapsulation made around openrouteservice API for Dart and Flutter projects. Made for easy generation of Routes and Directions on Maps, Isochrones, Time-Distance Matrix, Pelias Geocoding, POIs, Elevation and routing Optimizations using their amazing API.
Stars: ✭ 20 (-44.44%)
Mutual labels:  flutter-package

A flutter package for authentication with DAuth(an OAuth2 based SSO (Single Sign On) for NITT students) authorisations service on behalf of the resource-owner/user. DAuth lets the application developers securely get access to users’ data without users having to share their passwords.

DAuth allows a Client-App (the program using this library) to access and manipulate a resource that's owned by a resource owner (the end user) and lives on a remote server. The Client-App directs the resource owner to dauth authorization server, where the resource owner tells the authorization server to give the Client-App an access token. This token serves as proof that the client has permission to access resources on behalf of the resource owner.

Note: OAuth2 provides several different methods for the client to obtain authorization.But, currently This package only supports Authorisation Code Grant

Features

AuthorisationCodeGrant

  • This Package Allows user to get the authorized token by calling fetchToken(authorizationRequest), which automates the following workflow:
    • Generates authorizationUrl using the provided authorizationRequest in the parameter.
    • Opens up a webView with the generated authorizationUrl and Listens to the NavigationRequests.
    • Allows user to enable permissions to Client-App to access the resource of the user from Dauth-Resource-Provider.
    • After Authentication server redirects to the registered redirect_uri and code is fetched by listening to the NavigationRequest.
    • Using the code as body parameter a post-request is automated to retrive the token.
  • Once the tokenResponse is fetched the user can send a post request using fetchResources(token) and get the protectedResources based on the Scope mentioned.

DataTypes

DataTypes Parameters Description
ResourceResponse String? tokenType, String? accessToken, String? state, int? expiresIn,String? idToken,String? status,ErrorResponse? errorResponse Response-body returned from fetchResources() request
TokenResponse String? email,String? id,String? name,String? phoneNumber,String? gender,DateTime? createdAt,DateTime? updatedAt, Response-body returned from fetchToken() request
Scope bool isOpenId, bool isEmail, bool isProfile, bool isUser Consists of 4 boolean parameters to enable SCOPE of Resource Access
TokenRequest String? clientId,String? codeVerifier,String codeChallengeMethod,String? redirectUri,String? responseType,String? grantType,String? state,String? scope,String? nonce Request-Parameter for fetchToken()

Methods

Methods Parameters
TokenResponse fetchToken() TokenRequest request
ResourceResponse fetchResource() String access_token
Widget DauthButton() Function OnPressed: (TokenResponse res){}

Getting started

To use this package:

  • Run the following command in terminal
    • flutter pub get flutter_dauth
      
      OR
  • Add the following in pubspec.yaml file
    • dependencies:
          flutter:
              sdk: flutter
          flutter_dauth:   

Usage

Following is an example of Authorization Grant Code using this package.

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) => const MaterialApp(
        debugShowCheckedModeBanner: false,
        home: HomePage(),
      );
}

class HomePage extends StatefulWidget {
  const HomePage({Key? key}) : super(key: key);
  @override
  State<StatefulWidget> createState() => HomeState();
}

class HomeState extends State<HomePage> {
  //A string object used in Text() widget as data.
  String _exampleText = 'Flutter Application';

  //Create a TokenRequest Object
  final dauth.TokenRequest _request = TokenRequest(
     //Your Client-Id provided by Dauth Server at the time of registration.
      clientId: 'YOUR CLIENT ID',
      //redirectUri provided by You to Dauth Server at the time of registration.
      redirectUri: 'YOUR REDIRECT URI',
      //A String which will retured with access_token for token verification in client side.
      state: 'STATE',
      //setting isUser to true to retrive UserDetails in ResourceResponse from Dauth server.
      scope: const dauth.Scope(isUser: true),
      //codeChallengeMethod Should be specified as `plain` or `S256` based on thier requirement.
      codeChallengeMethod: 'S256');

  @override
  Widget build(BuildContext context) => SafeArea(
          child: Scaffold(
              body: Container(
        color: Colors.blueGrey,
        child: Stack(
          children: [
            Center(
                child: Text(
              _exampleText,
              style: const TextStyle(fontSize: 30, fontWeight: FontWeight.bold),
            )),
            Positioned(
                left: 50,
                right: 50,
                bottom: 10,
                //DAuth button returns TokenResponse and ResponseMessage when pressed.
                child: dauth.DauthButton(
                    request: _request,
                    onPressed:
                        (dauth.TokenResponse res) {
                      //changes the exampleText as Token_TYPE: <YOUR_TOKEN> from the previous string if the response is success'
                        setState(() {
                          _exampleText = 'Token_TYPE: ' +
                              (res)
                                  .tokenType
                                  .toString();
                        });
                    }))
          ],
        ),
      )));
}

Updates

  • To Ensure Security issues related to Interception attacks PKCE is added with Authorisation Code Grant.

Issues/Upcoming Changes

  • DAuth only supports Authorisation Grant Flow at the time of writing supports, in future more methods will be added and flutter_dauth will also be updated accordingly.

Credits

This package wouldn't be possible without the following:

  • webviewx : for opening AuthorizationUrl in WebView and Listening to NavigationRequest
  • https : for HTTP requests to the Dauth-Server.
  • crypto : for SHA256 encryption.

License

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].