Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: glee authentication using auth directory #473

Closed
wants to merge 55 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
bf52926
refactor mqtt _connect() function
oviecodes Mar 13, 2023
e127849
refactor mqtt _connect() function
oviecodes Mar 13, 2023
4165e63
refactor mqtt _connect() function
oviecodes Mar 14, 2023
8a7bce3
revert to master
oviecodes Mar 14, 2023
9c4a557
Merge branch 'master' of https://github.com/asyncapi/glee
oviecodes Mar 14, 2023
a3f9cd3
update lockfileVersion to 2
oviecodes Mar 22, 2023
6504e2b
update package.json
oviecodes Mar 27, 2023
2d9f14e
Merge branch 'master' of https://github.com/asyncapi/glee
oviecodes Apr 20, 2023
6ae5f42
Merge branch 'master' of https://github.com/asyncapi/glee
oviecodes May 8, 2023
919edd9
update repo
oviecodes May 8, 2023
8a39e27
fix
oviecodes May 27, 2023
09a4b2c
working on glee auth
oviecodes Jun 5, 2023
1add038
running auth files
oviecodes Jun 6, 2023
814399b
working on authentication
oviecodes Jun 7, 2023
fa406db
auth event
oviecodes Jun 12, 2023
7a2eca1
update
oviecodes Jun 12, 2023
a811c37
update
oviecodes Jun 15, 2023
1881d55
add file checks
oviecodes Jun 15, 2023
f2c27ca
lifecycle authentication
oviecodes Jun 16, 2023
ae6b460
resolve adapter conflicts
oviecodes Jun 16, 2023
9480c9e
resolve glee conflicts
oviecodes Jun 16, 2023
964522e
lint:fix
oviecodes Jun 16, 2023
4b7863e
Merge branch 'master' of https://github.com/asyncapi/glee
oviecodes Jun 16, 2023
d85622a
merged master
oviecodes Jun 16, 2023
5f0c8b2
fixing conflicts
oviecodes Jun 16, 2023
9570dfb
update
oviecodes Jun 16, 2023
21d6475
update
oviecodes Jun 16, 2023
3838596
fix docs test
oviecodes Jun 16, 2023
2c73e20
http auth with lifecycle
oviecodes Jun 20, 2023
cb5ca48
http auth
oviecodes Jun 20, 2023
be66340
lint:fix
oviecodes Jun 20, 2023
247a7be
lint:fix
oviecodes Jun 20, 2023
c1b413e
update
oviecodes Jun 21, 2023
6e7606f
update
oviecodes Jun 21, 2023
9dc1e0e
update server auth
oviecodes Jul 1, 2023
7e58132
refactor auth
oviecodes Jul 1, 2023
d20798d
authentication
oviecodes Jul 1, 2023
e98aa44
auth refactor
oviecodes Jul 1, 2023
297d8ba
remove auth from lifecycleEvents.ts
oviecodes Jul 3, 2023
27b0d72
update ws/http client auth
oviecodes Jul 3, 2023
4de1676
update ws/http client auth
oviecodes Jul 3, 2023
a33c36f
update ws/http client auth
oviecodes Jul 3, 2023
e8f7f2b
update
oviecodes Jul 9, 2023
421fdf2
merge with upstream
oviecodes Jul 9, 2023
e54eac4
merge with master
oviecodes Jul 9, 2023
02fe629
fix merge issues
oviecodes Jul 9, 2023
d449763
fix linting errors
oviecodes Jul 9, 2023
5c2930f
fix linting errors
oviecodes Jul 9, 2023
e3ef51e
fix linting errors
oviecodes Jul 9, 2023
e9ff99c
fix linting errors
oviecodes Jul 9, 2023
42e82a8
move jest config to jest.config.json
oviecodes Jul 9, 2023
79b97e5
merge package.json
oviecodes Jul 9, 2023
2781bac
fix test errors
oviecodes Jul 9, 2023
727f1da
attempt remove duplication from adapter.test
oviecodes Jul 9, 2023
7441203
fix
oviecodes Jul 9, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/anime-http/client/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TOKEN=arb-valueFromClientAuth
2 changes: 1 addition & 1 deletion examples/anime-http/client/asyncapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ components:
test:
summary: ping client
payload:
type: object
type: object
9 changes: 9 additions & 0 deletions examples/anime-http/client/auth/trendingAnime.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* eslint-disable no-undef */

export async function clientAuth({ parsedAsyncAPI, serverName }) {
console.log("serverName", serverName)

return {
token: process.env.TOKEN,
}
}
128 changes: 128 additions & 0 deletions examples/anime-http/client/docs/asyncapi.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# AsyncAPI IMDB client 1.0.0 documentation

This app creates a client that subscribes to the server for getting the top 10 trending/upcoming anime.

## Table of Contents

* [Servers](#servers)
* [trendingAnime](#trendinganime-server)
* [testwebhook](#testwebhook-server)
* [Operations](#operations)
* [PUB /test](#pub-test-operation)
* [PUB trendingAnime](#pub-trendinganime-operation)
* [SUB trendingAnime](#sub-trendinganime-operation)

## Servers

### `trendingAnime` Server

* URL: `http://localhost:8081`
* Protocol: `http`



### `testwebhook` Server

* URL: `ws://localhost:9000`
* Protocol: `ws`



## Operations

### PUB `/test` Operation

* Operation ID: `index`

#### `ws` Channel specific information

| Name | Type | Description | Value | Constraints | Notes |
|---|---|---|---|---|---|
| bindingVersion | - | - | `"0.1.0"` | - | - |

#### Message `test`

*ping client*

##### Payload

| Name | Type | Description | Value | Constraints | Notes |
|---|---|---|---|---|---|
| (root) | object | - | - | - | **additional properties are allowed** |

> Examples of payload _(generated)_

```json
{}
```



### PUB `trendingAnime` Operation

* Operation ID: `trendingAnimeListRecieverController`
* Available only on servers: [trendingAnime](#trendinganime-server)

#### `http` Channel specific information

| Name | Type | Description | Value | Constraints | Notes |
|---|---|---|---|---|---|
| type | - | - | `"request"` | - | - |
| method | - | - | `"POST"` | - | - |
| bindingVersion | - | - | `"0.1.0"` | - | - |

#### Message `<anonymous-message-2>`

*Data required to populate trending anime*

##### Payload

| Name | Type | Description | Value | Constraints | Notes |
|---|---|---|---|---|---|
| (root) | object | - | - | - | **additional properties are allowed** |
| name | string | Name of the anime. | - | - | **required** |
| rating | string | Rating of the show. | - | - | **required** |
| genre | string | The genre of anime. | - | - | **required** |
| studio | string | The studio of anime. | - | - | **required** |

> Examples of payload _(generated)_

```json
{
"name": "string",
"rating": "string",
"genre": "string",
"studio": "string"
}
```



### SUB `trendingAnime` Operation

* Available only on servers: [trendingAnime](#trendinganime-server)

#### `http` Channel specific information

| Name | Type | Description | Value | Constraints | Notes |
|---|---|---|---|---|---|
| type | - | - | `"request"` | - | - |
| method | - | - | `"POST"` | - | - |
| bindingVersion | - | - | `"0.1.0"` | - | - |

#### Message `<anonymous-message-3>`

##### Payload

| Name | Type | Description | Value | Constraints | Notes |
|---|---|---|---|---|---|
| (root) | object | - | - | - | **additional properties are allowed** |

> Examples of payload _(generated)_

```json
{}
```



22 changes: 11 additions & 11 deletions examples/anime-http/client/functions/index.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
export default async function () {
const payload = {
body: {
name: 'test12',
rating: '5',
studio: 'teststudio',
genre: 'testgenre',
name: "test12",
rating: "5",
studio: "teststudio",
genre: "testgenre",
},
query: {
name: 'test34',
rating: '5',
studio: 'teststudio',
genre: 'testgenre',
}
name: "test34",
rating: "5",
studio: "teststudio",
genre: "testgenre",
},
}
return {
send: [
{
server: 'trendingAnime',
server: "trendingAnime",
payload: payload.body,
query: payload.query
query: payload.query,
},
],
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export default async function (event) {
console.log('Trending Anime Payload:', event.payload)
console.log("Trending Anime Payload:", event.payload)
}
15 changes: 15 additions & 0 deletions examples/anime-http/client/glee.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export default async function () {
return {
http: {
client: {
auth: async ({ serverName }) => {
if (serverName === "websockets") {
return {
token: process.env.TOKEN,
}
}
},
},
},
}
}
90 changes: 90 additions & 0 deletions examples/anime-http/client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 25 additions & 6 deletions examples/anime-http/server/asyncapi.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
asyncapi: 2.4.0
asyncapi: 2.6.0
info:
title: AsyncAPI IMDB server
version: 1.0.0
description: This app is a dummy server that would stream the trending/upcoming anime.
servers:
trendingAnimeServer:
url: http://localhost:8081
url: 'http://localhost:8081'
protocol: http
security:
- tokens: []
- userPass: []
- apiKey: []
- cert: []
channels:
trendingAnime:
bindings:
Expand All @@ -15,13 +20,13 @@ channels:
method: POST
bindingVersion: 0.1.0
query:
$ref: "#/components/schemas/request"
$ref: '#/components/schemas/request'
body:
$ref: "#/components/schemas/request"
$ref: '#/components/schemas/request'
publish:
operationId: trendingAnimeController
message:
$ref: "#/components/messages/trendingAnime"
$ref: '#/components/messages/trendingAnime'
subscribe:
message:
payload:
Expand All @@ -31,7 +36,7 @@ components:
trendingAnime:
summary: Data required to populate trending anime
payload:
$ref: "#/components/schemas/request"
$ref: '#/components/schemas/request'
schemas:
request:
type: object
Expand All @@ -53,3 +58,17 @@ components:
studio:
type: string
description: The studio of anime.
securitySchemes:
tokens:
type: http
scheme: bearer
bearerFormat: JWT
userPass:
type: userPassword
apiKey:
type: httpApiKey
name: api_key
in: header
cert:
type: apiKey
in: user
26 changes: 26 additions & 0 deletions examples/anime-http/server/auth/trendingAnimeServer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// /* eslint-disable no-undef */

// //@ts-ignore
// import { Message } from "@asyncapi/glee";
import axios from "axios"

export async function serverAuth({ headers, callback: done }) {
await axios.get("https://jsonplaceholder.typicode.com/todos/1")

console.log("running in auth file in auth folder")

console.log("headers", headers["authentication"])

// console.log("network data", res.data)

// callback(false, 401, "Unauthorized");
done(true)
}

export async function clientAuth({ parsedAsyncAPI, serverName }) {
if (serverName === "websockets") {
return {
token: process.env.TOKEN,
}
}
}
Loading