Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/release/1.2' into HEAD
Browse files Browse the repository at this point in the history
  • Loading branch information
wparad committed Apr 17, 2022
2 parents 5583cc4 + f43f006 commit 83e712c
Show file tree
Hide file tree
Showing 19 changed files with 1,297 additions and 1,362 deletions.
5 changes: 4 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
"allowModules": ["jose"]
}],

"@typescript-eslint/no-var-requires": "off"
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/ban-ts-comment": "off",
"no-use-before-define": "off",
"@typescript-eslint/no-shadow": ["error"]
}
}
46 changes: 46 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
on:
push:
branches:
- main
- master
- 'release/**'
pull_request:
branches:
- main
- master
- 'release/**'

jobs:
build:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v1
with:
node-version: 12.21.0
registry-url: 'https://registry.npmjs.org'

- name: Install packages
run: npm install
- name: Run build
run: node make.js build
- name: Test
run: yarn lint && yarn test
- name: Deploy to NPM
if: github.repository_owner == 'Authress' && github.ref != 'refs/heads/main' && github.ref != 'refs/heads/master' && github.event_name == 'push'
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}

- name: After build
if: github.repository_owner == 'Authress' && github.ref != 'refs/heads/main' && github.ref != 'refs/heads/master' && github.event_name == 'push'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: node make.js after_build
- name: Create Github Release and Tag
if: github.repository_owner == 'Authress' && github.ref != 'refs/heads/main' && github.ref != 'refs/heads/master' && github.event_name == 'push'
run: |
git tag ${GITHUB_REF/refs\/heads\/release\//}.$GITHUB_RUN_NUMBER
git push origin ${GITHUB_REF/refs\/heads\/release\//}.$GITHUB_RUN_NUMBER
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
12
23 changes: 0 additions & 23 deletions .travis.yml

This file was deleted.

10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
# Change log
This is the changelog for [Authress SDK](readme.md).

## 1.2 ##
* Removed legacy support for RS512 service client tokens.
* Add EdDSA support for `tokenVerifier()` class
* Set the service client authorization request type to be `oauth-authz-req+jwt`
* Handle malformed baseUrls in `httpClient`.

## 1.1 ##
* Migrated to Github Actions

## 1.0 ##
* Allow key format to be base64 or unencoded
* Added `getUserRolesForResource` for access to user roles on a resource.
* Add `Last-Modified` and `If-Unmodified-Since` support to access record updates.
* Add `Groups` to `AccessRecords`
* Add `ConnectionsApi` to fetch user credentials for a specific connection
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
This is the Authress SDK used to integrate with the authorization as a service provider Authress at https://authress.io.

[![npm version](https://badge.fury.io/js/authress-sdk.svg)](https://badge.fury.io/js/authress-sdk)
[![Build Status](https://travis-ci.com/authress/authress-sdk.js.svg?branch=master)](https://travis-ci.com/authress/authress-sdk.js)


## Usage
Expand All @@ -26,8 +25,7 @@ const { AuthressClient } = require('authress-sdk');
```js
const { AuthressClient } = require('authress-sdk');

// create an instance of the API class during service initialization
// Replace DOMAIN with the Authress domain for your account
// What is my baseUrl? => API Host: https://authress.io/app/#/api?route=overview
const authressClient = new AuthressClient({ baseUrl: 'https://DOMAIN.api-REGION.authress.io' })

// on api route
Expand Down Expand Up @@ -108,8 +106,7 @@ try {
// Grab authorization cookie from the request, the best way to do this will be framework specific.
const cookies = cookieManager.parse(request.headers.cookie || '');
const userToken = cookies.authorization || request.headers.Authorization.split(' ')[1];
// Specify your custom domain for tokens. Configurable at https://authress.io/app/#/manage?focus=applications
// Replacing the domain with your login url
// What should my url be? => https://authress.io/app/#/setup?focus=domain
const userIdentity = await TokenVerifier('https://login.application.com', userToken);
} catch (error) {
console.log('User is unauthorized', error);
Expand Down
4 changes: 2 additions & 2 deletions examples/expressMicroservice/expressMicroservice.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ api.use((error, req, res, next) => {
/** Start of Example section for integration with Authress */

/** Setup middleware */
const jwtManager = require('jsonwebtoken');
const base64url = require('base64url');
const { AuthressClient, ServiceClientTokenProvider, UnauthorizedError } = require('authress-sdk');

// Some requests to authress request service client access and cannot use the user's JWT
Expand All @@ -59,7 +59,7 @@ api.use((request, response, next) => {
return;
}
const token = authorizationHeader.replace(/Bearer\s+/i, '').trim();
const jwt = jwtManager.decode(token);
const jwt = JSON.parse(base64url.decode(token.split('.')[1]));
response.locals.userId = jwt.sub;
// Other requests to Authress can and should be done with the user's token when possible
response.locals.authressClient = new AuthressClient({ baseUrl: authressDomain }, () => token);
Expand Down
2 changes: 1 addition & 1 deletion examples/expressMicroservice/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
"dependencies": {},
"devDependencies": {
"authress-sdk": "^1",
"base64url": "^3.0.1",
"body-parser": "^1.19.0",
"express": "^4.17.1",
"header-case-normalizer": "^1.0.3",
"json-stringify-safe": "^5.0.1",
"jsonwebtoken": "^8.5.1",
"lodash": "^4.17.21",
"morgan": "^1.10.0",
"nodemon": "^2.0.4"
Expand Down
Loading

0 comments on commit 83e712c

Please sign in to comment.