# @antoniojps/passport-identityua

> University of Aveiro authentication strategy for Passport.

Latest version **2.0.0** (published 2019-07-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install @antoniojps/passport-identityua
pnpm add @antoniojps/passport-identityua
yarn add @antoniojps/passport-identityua
bun add @antoniojps/passport-identityua
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2019-07-29 |
| First published | 2019-07-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.4.0 |
| Dependencies | 2 |
| Unpacked size | 11.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Antonio Santos |
| Maintainers | antoniojps |
| Keywords | passport, ua, auth, authn, authentication, identity |

## Links

- npm: https://www.npmjs.com/package/@antoniojps/passport-identityua
- Repository: https://github.com/antoniojps/passport-identityua
- Homepage: https://github.com/antoniojps/passport-identityua#readme
- Issues: https://github.com/antoniojps/passport-identityua/issues
- npm.io page: https://npm.io/package/@antoniojps/passport-identityua

## Dependencies (2)

- [xtraverse](https://npm.io/package/xtraverse.md) 0.1.x
- [passport-oauth1](https://npm.io/package/passport-oauth1.md) 1.x.x

## Alternatives

- [@clerk/clerk-expo](https://npm.io/package/@clerk/clerk-expo.md) — 133.6K weekly downloads
- [@pothos/plugin-authz](https://npm.io/package/@pothos/plugin-authz.md) — 12.4K weekly downloads
- [@bounded-sh/client](https://npm.io/package/@bounded-sh/client.md) — 3.2K weekly downloads
- [@luigi-project/plugin-auth-oauth2](https://npm.io/package/@luigi-project/plugin-auth-oauth2.md) — 2.3K weekly downloads
- [@nocobase/plugin-verification](https://npm.io/package/@nocobase/plugin-verification.md) — 2.0K weekly downloads

## Recent versions

- 2.0.0 (latest) — 2019-07-29

## README

# passport-identityua

[![npm](https://img.shields.io/npm/v/npm.svg)](https://www.npmjs.com/package/passport-identityua)
[![Build Status](https://travis-ci.org/poliveira89/passport-identityua.svg)](https://travis-ci.org/poliveira89/passport-identityua)
[![Coverage Status](https://coveralls.io/repos/poliveira89/passport-identityua/badge.svg?branch=master&service=github)](https://coveralls.io/github/poliveira89/passport-identityua?branch=master)
[![Codacy Badge](https://api.codacy.com/project/badge/d20ac5ee14e1494a80716b7b16e637c8)](https://www.codacy.com/app/paulonascimento89/passport-identityua)
[![Code Climate](https://codeclimate.com/github/poliveira89/passport-identityua/badges/gpa.svg)](https://codeclimate.com/github/poliveira89/passport-identityua)
[![Dependencies](https://david-dm.org/poliveira89/passport-identityua.svg)](https://david-dm.org/poliveira89/passport-identityua)

[Passport](http://passportjs.org/) strategy for authenticating with [IdentityUA](http://identity.ua.pt/)
using the OAuth 1.0a API.

This module lets you authenticate using Universal User from University of Aveiro (UA) in your Node.js applications.

## Install

    $ npm install passport-identityua

## Usage

#### Configure Strategy

The IdentityUA authentication strategy authenticates users using a Universal User UA account
and OAuth tokens. The strategy requires a `verify` callback, which receives the
access token and corresponding secret as arguments, as well as `profile` which
contains the authenticated user's UA profile. The `verify` callback must
call `done` providing a user to complete authentication.

In order to identify your application to IdentityUA, specify the consumer key,
consumer secret, callback URL and scope within `options`. The consumer key and secret
are obtained by [creating an application](http://identity.ua.pt/oauth/apps) at
IdentityUA site.

```js
passport.use(
  new IdentityUaStrategy(
    {
      consumerKey: IDENTITYUA_CONSUMER_KEY,
      consumerSecret: IDENTITYUA_CONSUMER_SECRET,
      callbackURL: "http://127.0.0.1:3000/auth/ua/callback"
    },
    function(token, tokenSecret, profile, done) {
      User.findOrCreate({ id: profile.id }, function(err, user) {
        return done(err, user);
      });
    }
  )
);
```

When the scope option is undefined it defaults to `uu` (Utilizador universal) which returns the user's email.

#### Scopes

The following example demonstrastes the usage of `scopes`.

```js
passport.use(
  new IdentityUaStrategy(
    {
      consumerKey: IDENTITYUA_CONSUMER_KEY,
      consumerSecret: IDENTITYUA_CONSUMER_SECRET,
      callbackURL: "http://127.0.0.1:3000/auth/ua/callback",
      scope: ["uu", "name"]
    },
    function(token, tokenSecret, profile, done) {
      User.findOrCreate({ id: profile.id }, function(err, user) {
        return done(err, user);
      });
    }
  )
);
```

Read the [OAuth service documentation](http://api.web.ua.pt/pt/services/universidade_de_aveiro/oauth) under the `Serviços Disponíveis` section to check all the available scopes.

#### Authenticate Requests

Use `passport.authenticate()`, specifying the `'identityua'` strategy, to
authenticate requests.

For example, as route middleware in an [Express](http://expressjs.com/)
application:

```js
app.get("/auth/ua", passport.authenticate("identityua"));

app.get(
  "/auth/ua/callback",
  passport.authenticate("identityua", { failureRedirect: "/login" }),
  function(req, res) {
    // Successful authentication, redirect home.
    res.redirect("/");
  }
);
```

## Tests

    $ npm install
    $ npm test

## TODO

- [x] Fix `scope` bug
- [ ] Fix "Strategy parsing error from access token endpoint parsing error should error" test (it's hardcoded to pass)

## Credits

- [Jared Hanson](http://github.com/jaredhanson) (developed the code before the fork)
- [Paulo Oliveira](http://github.com/poliveira89)
- [António Santos](http://github.com/antoniojps)

## License

[The MIT License](http://opensource.org/licenses/MIT)

Copyright (c) 2015 Jared Hanson <[http://jaredhanson.net/](http://jaredhanson.net/)>

---
_Source: https://npm.io/package/@antoniojps/passport-identityua · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
