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 auth v2 #474

Merged
merged 71 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 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
7a2eca1
update
oviecodes Jun 12, 2023
4b7863e
Merge branch 'master' of https://github.com/asyncapi/glee
oviecodes Jun 16, 2023
21d6475
update
oviecodes Jun 16, 2023
421fdf2
merge with upstream
oviecodes Jul 9, 2023
2343a9f
merge package.json
oviecodes Jul 9, 2023
a5ac635
fix test errors
oviecodes Jul 9, 2023
78d8825
migrate from gleeAuthV1
oviecodes Jul 10, 2023
8e4af69
update error messages
oviecodes Jul 13, 2023
a5fe8cb
create GleeAuthFunction and GleeAuthFunctionEvent
oviecodes Jul 13, 2023
2821f36
update
oviecodes Jul 13, 2023
08df645
fix PR
oviecodes Jul 19, 2023
50ce812
GleeAuth class
oviecodes Jul 26, 2023
a8519c3
GleeAuth class - format securitySchemes
oviecodes Jul 27, 2023
11f5955
GleeAuth class - clientAuth
oviecodes Jul 27, 2023
474198e
GleeAuth class - getAuthConfig
oviecodes Jul 27, 2023
f3b155d
update
oviecodes Jul 27, 2023
d0d582e
GleeAuth class works for ws
oviecodes Jul 27, 2023
510704b
fix bug
oviecodes Jul 28, 2023
738e4df
update
oviecodes Jul 28, 2023
3d2fd84
update
oviecodes Jul 28, 2023
8b47209
fix error
oviecodes Jul 28, 2023
dc46142
fix ws server auth
oviecodes Jul 28, 2023
744a006
auth
oviecodes Jul 28, 2023
5670658
clean up
oviecodes Jul 28, 2023
f9251aa
add oauth support
oviecodes Aug 5, 2023
9b3f963
add oauth support
oviecodes Aug 5, 2023
3033a52
add HttpAPIKey auth scheme
oviecodes Aug 6, 2023
a7c7c7e
fix user password for http suthentication
oviecodes Aug 6, 2023
b1044b2
fix user password for http suthentication
oviecodes Aug 6, 2023
f402b48
update oauth2 authentication
oviecodes Aug 8, 2023
4f0d001
fix linting issues
oviecodes Aug 8, 2023
057c721
fix linting errors
oviecodes Aug 8, 2023
58ff077
fix linting errors
oviecodes Aug 8, 2023
8897ce9
fix linting errors
oviecodes Aug 8, 2023
f6f7087
fix code smells
oviecodes Aug 8, 2023
1fc071f
fix code smells
oviecodes Aug 8, 2023
0e0c244
update server
oviecodes Aug 9, 2023
2283982
fix linting
oviecodes Aug 10, 2023
83a2b4d
Update src/adapters/http/server.ts
oviecodes Aug 14, 2023
a41e944
docs
oviecodes Aug 14, 2023
bf273c1
Merge branch 'gleeAuthV2' of https://github.com/oviecodes/glee into g…
oviecodes Aug 14, 2023
f38b8ed
revert docs
oviecodes Aug 15, 2023
b12125a
revert docs
oviecodes Aug 15, 2023
e4c238f
Merge remote-tracking branch 'upstream/master'
oviecodes Aug 15, 2023
38e1b1c
merge with master
oviecodes Aug 15, 2023
17d3c30
Merge remote-tracking branch 'origin' into gleeAuthV2
oviecodes Aug 15, 2023
98320e0
working on docs
oviecodes Aug 15, 2023
ae40060
working on docs
oviecodes Aug 15, 2023
90341e0
working on docs
oviecodes Aug 15, 2023
630b85c
refactor ws server.ts auth
oviecodes Aug 15, 2023
d7fbde7
refactor http and ws server.ts auth
oviecodes Aug 15, 2023
35f6205
refactor done
oviecodes Aug 15, 2023
e094be9
refactor callback to done
oviecodes Aug 16, 2023
fb37d9b
remove auth docs
oviecodes Aug 16, 2023
aa67924
clean up
oviecodes Aug 19, 2023
c54f94a
clean up
oviecodes Aug 19, 2023
66891bf
refactor
oviecodes Aug 19, 2023
1f38233
update
oviecodes Aug 19, 2023
ab8ddba
formatting
KhudaDad414 Aug 21, 2023
3c60ed6
clean comments
oviecodes Aug 21, 2023
0a07723
Merge branch 'gleeAuthV2' of https://github.com/oviecodes/glee into g…
oviecodes Aug 21, 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 .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ coverage
.github
examples
node_modules
docs
2 changes: 2 additions & 0 deletions docs/reference/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
- [lib/message](modules/lib_message.md)
- [lib/router](modules/lib_router.md)
- [lib/servers](modules/lib_servers.md)
- [lib/userAuth](modules/lib_userAuth.md)
- [lib/util](modules/lib_util.md)
- [lib/wsHttpAuth](modules/lib_wsHttpAuth.md)
- [middlewares](modules/middlewares.md)
- [middlewares/buffer2string](modules/middlewares_buffer2string.md)
- [middlewares/errorLogger](modules/middlewares_errorLogger.md)
Expand Down
6 changes: 3 additions & 3 deletions docs/reference/classes/lib_glee.default.md
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,9 @@ Adds a connection adapter.
| :------ | :------ |
| `Adapter` | typeof [`default`](lib_adapter.default.md) |
| `«destructured»` | `Object` |
| › `parsedAsyncAPI` | `AsyncAPIDocument` |
| › `server` | `Server` |
| › `serverName` | `string` |
| › `parsedAsyncAPI` | `AsyncAPIDocument` |
| › `server` | `Server` |
| › `serverName` | `string` |

#### Returns

Expand Down
12 changes: 12 additions & 0 deletions docs/reference/interfaces/lib.HttpAuthConfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,22 @@

### Properties

- [password](lib.HttpAuthConfig.md#password)
- [token](lib.HttpAuthConfig.md#token)
- [username](lib.HttpAuthConfig.md#username)

## Properties

### password

• `Optional` **password**: `string`

#### Defined in

[src/lib/index.d.ts:35](https://github.com/oviecodes/glee/blob/2283982/src/lib/index.d.ts#L35)

___

### token

• `Optional` **token**: `string`
Expand Down
22 changes: 22 additions & 0 deletions docs/reference/interfaces/lib.WsAuthConfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,36 @@

### Properties

- [password](lib.WsAuthConfig.md#password)
- [token](lib.WsAuthConfig.md#token)
- [username](lib.WsAuthConfig.md#username)

## Properties

### password

• `Optional` **password**: `string`

#### Defined in

[src/lib/index.d.ts:29](https://github.com/oviecodes/glee/blob/2283982/src/lib/index.d.ts#L29)

___

### token

• `Optional` **token**: `string`

#### Defined in

[src/lib/index.d.ts:27](https://github.com/asyncapi/glee/blob/b84101b/src/lib/index.d.ts#L27)

___

### username

• `Optional` **username**: `string`

#### Defined in

[src/lib/index.d.ts:28](https://github.com/oviecodes/glee/blob/2283982/src/lib/index.d.ts#L28)
4 changes: 4 additions & 0 deletions docs/reference/modules/lib.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
### Type Aliases

- [AuthFunction](lib.md#authfunction)
- [AuthProps](lib.md#authprops)
- [CoreGleeConfig](lib.md#coregleeconfig)
- [GleeAuthFunction](lib.md#gleeauthfunction)
- [GleeAuthFunctionEvent](lib.md#gleeauthfunctionevent)
- [GleeClusterAdapterConfig](lib.md#gleeclusteradapterconfig)
- [GleeConfig](lib.md#gleeconfig)
- [GleeFunction](lib.md#gleefunction)
Expand All @@ -30,6 +33,7 @@
- [QueryParam](lib.md#queryparam)
- [WebSocketServerType](lib.md#websocketservertype)
- [WebsocketAdapterConfig](lib.md#websocketadapterconfig)
- [WsHttpAuth](lib.md#wshttpauth)

## Type Aliases

Expand Down
20 changes: 20 additions & 0 deletions docs/reference/modules/lib_adapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,30 @@

### Type Aliases

- [AuthEvent](lib_adapter.md#authevent)
- [EnrichedEvent](lib_adapter.md#enrichedevent)

## Type Aliases

### AuthEvent

Ƭ **AuthEvent**: `Object`

#### Type declaration

| Name | Type |
| :------ | :------ |
| `authProps` | [`AuthProps`](lib.md#authprops) |
| `callback` | `any` |
| `doc` | `any` |
| `serverName` | `string` |

#### Defined in

[src/lib/adapter.ts:17](https://github.com/oviecodes/glee/blob/2283982/src/lib/adapter.ts#L17)

___

### EnrichedEvent

Ƭ **EnrichedEvent**: `Object`
Expand Down
85 changes: 85 additions & 0 deletions docs/reference/modules/lib_userAuth.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
[@asyncapi/glee](../README.md) / lib/userAuth

# Module: lib/userAuth

## Table of contents

### Variables

- [authFunctions](lib_userAuth.md#authfunctions)

### Functions

- [clientAuthConfig](lib_userAuth.md#clientauthconfig)
- [register](lib_userAuth.md#register)
- [triggerAuth](lib_userAuth.md#triggerauth)

## Variables

### authFunctions

• `Const` **authFunctions**: `Map`<`string`, `AuthFunctionInfo`\>

#### Defined in

[src/lib/userAuth.ts:15](https://github.com/oviecodes/glee/blob/2283982/src/lib/userAuth.ts#L15)

## Functions

### clientAuthConfig

▸ **clientAuthConfig**(`serverName`): `Promise`<[`GleeAuthFunction`](lib.md#gleeauthfunction)\>

#### Parameters

| Name | Type |
| :------ | :------ |
| `serverName` | `string` |

#### Returns

`Promise`<[`GleeAuthFunction`](lib.md#gleeauthfunction)\>

#### Defined in

[src/lib/userAuth.ts:79](https://github.com/oviecodes/glee/blob/2283982/src/lib/userAuth.ts#L79)

___

### register

▸ **register**(`dir`): `Promise`<`void`[]\>

#### Parameters

| Name | Type |
| :------ | :------ |
| `dir` | `string` |

#### Returns

`Promise`<`void`[]\>

#### Defined in

[src/lib/userAuth.ts:17](https://github.com/oviecodes/glee/blob/2283982/src/lib/userAuth.ts#L17)

___

### triggerAuth

▸ **triggerAuth**(`params`): `Promise`<`void`\>

#### Parameters

| Name | Type |
| :------ | :------ |
| `params` | [`GleeAuthFunctionEvent`](lib.md#gleeauthfunctionevent) |

#### Returns

`Promise`<`void`\>

#### Defined in

[src/lib/userAuth.ts:49](https://github.com/oviecodes/glee/blob/2283982/src/lib/userAuth.ts#L49)
9 changes: 9 additions & 0 deletions docs/reference/modules/lib_wsHttpAuth.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[@asyncapi/glee](../README.md) / lib/wsHttpAuth

# Module: lib/wsHttpAuth

## Table of contents

### Classes

- [default](../classes/lib_wsHttpAuth.default.md)
3 changes: 3 additions & 0 deletions examples/anime-http/client/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
TOKEN=arb-valueFromClientAuth
OAUTH2=arb-OAUTH_access_token
APIKEY=arb-APIKEY_token
37 changes: 37 additions & 0 deletions examples/anime-http/client/asyncapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ servers:
trendingAnime:
url: http://localhost:8081
protocol: http
security:
- token: []
- userPass: []
- apiKey: []
- UserOrPassKey: []
- oauth:
- write:pets
- read:pets
testwebhook:
url: ws://localhost:9000
protocol: ws
Expand Down Expand Up @@ -43,3 +51,32 @@ components:
summary: ping client
payload:
type: object
securitySchemes:
token:
type: http
scheme: bearer
bearerFormat: JWT
userPass:
type: userPassword
apiKey:
type: httpApiKey
name: api_key
in: query
UserOrPassKey:
type: apiKey
in: user
oauth:
type: oauth2
flows:
implicit:
authorizationUrl: https://example.com/api/oauth/dialog
scopes:
write:pets: modify pets in your account
read:pets: read your pets
authorizationCode:
authorizationUrl: https://example.com/api/oauth/dialog
tokenUrl: https://example.com/api/oauth/dialog
scopes:
delete:pets: modify pets in your account
update:pets: read your pets

15 changes: 15 additions & 0 deletions examples/anime-http/client/auth/trendingAnime.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* eslint-disable no-undef */

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

return {
token: process.env.TOKEN,
oauth: process.env.OAUTH2,
oviecodes marked this conversation as resolved.
Show resolved Hide resolved
apiKey: process.env.APIKEY,
userPass: {
user: process.env.USERNAME,
password: process.env.PASSWORD
}
}
}
Loading