auth_header 2.1.4

  • Readme
  • Changelog
  • Example
  • Installing
  • 69

auth_header #

Utility library to parse and manipulate HTTP Authorisation header

Usage #

A simple usage example:

import 'dart:io';
import 'package:auth_header/auth_header.dart';

main() {
  HttpRequest request;  // TODO get from the real request

  List<String> headers = request.headers[HttpHeaders.AUTHORIZATION];
  if(headers is! List) {
    throw new Exception('No authorization header!');
  }

  String header = headers.first;

  AuthHeaders authHeader = new AuthHeaders.fromHeaderStr(header);
  print(authHeader);

  AuthHeaderItem items = new AuthHeaderItem('some-scheme', 'teja');
  String headerManipulated = AuthHeaders.addItemToHeaderStr(header, items);
  print(headerManipulated);

  headerManipulated = AuthHeaders.removeSchemeFromHeaderStr(header, items.authScheme);
  print(headerManipulated);
}

Changelog #

2.1.4 #

  • Removed dependency on dart:io

2.1.1 #

  • Fixed bug in addItemToHeaderStr when header is empty

example/auth_header_example.dart

// Copyright (c) 2016, Ravi Teja Gudapati. All rights reserved. Use of this source code
// is governed by a BSD-style license that can be found in the LICENSE file.

import 'dart:io';
import 'package:auth_header/auth_header.dart';

main() {
  String header = "Basic something-something";
  AuthHeaders authHeader = AuthHeaders.fromHeaderStr(header);
  print(authHeader);

  AuthHeaderItem items = AuthHeaderItem('some-scheme', 'teja');
  String headerManipulated = AuthHeaders.addItemToHeaderStr(header, items);
  print(headerManipulated);

  headerManipulated =
      AuthHeaders.removeSchemeFromHeaderStr(header, items.authScheme);
  print(headerManipulated);
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  auth_header: ^2.1.4

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:auth_header/auth_header.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
42
Health:
Code health derived from static analysis. [more]
98
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
95
Overall:
Weighted score of the above. [more]
69
Learn more about scoring.

We analyzed this package on Dec 7, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.1
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:auth_header/auth_header.dart.

Health suggestions

Fix lib/src/auth_header_base.dart. (-1.99 points)

Analysis of lib/src/auth_header_base.dart reported 4 hints:

line 35 col 56: Use = to separate a named parameter from its default value.

line 70 col 23: Unnecessary new keyword.

line 78 col 26: Use = to separate a named parameter from its default value.

line 93 col 24: Unnecessary new keyword.

Maintenance issues and suggestions

Fix analysis_options.yaml.

The analyzer can't parse analysis_options.yaml.

Homepage URL is insecure. (-5 points)

Update the homepage field and use a secure (https) URL.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.65 <3.0.0
Dev dependencies
test ^1.3.0