Skip to content

Commit b75fdf7

Browse files
committed
fix oauth state after redirect
1 parent 5fd5df2 commit b75fdf7

8 files changed

Lines changed: 20 additions & 19 deletions

File tree

OpenFlow/src/OAuthProvider.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ export class OAuthProvider {
4545
app.get('/oauth/login', async (req, res) => {
4646
instance.clients = await Config.db.query<Base>({ _type: "oauthclient" }, null, 10, 0, null, "config", Crypt.rootToken());
4747
if (instance.clients == null || instance.clients.length == 0) return res.status(500).json({ message: 'OAuth not configured' });
48-
let state = req.params.state;
49-
if (state == null) state = encodeURIComponent(req.query.state as any);
50-
const access_type = req.query.access_type;
51-
const client_id = req.query.client_id;
52-
const redirect_uri = req.query.redirect_uri;
53-
const response_type = req.query.response_type;
54-
const scope = req.query.scope;
48+
let state = (req.params.state ? req.params.state : req.params["amp;state"]);
49+
if (state == null) state = encodeURIComponent((req.query.state ? req.query.state : req.query["amp;state"]) as any);
50+
const access_type = (req.query.access_type ? req.query.access_type : req.query["amp;access_type"]);
51+
const client_id = (req.query.client_id ? req.query.client_id : req.query["amp;client_id"]);
52+
const redirect_uri = (req.query.redirect_uri ? req.query.redirect_uri : req.query["amp;redirect_uri"]);
53+
const response_type = (req.query.response_type ? req.query.response_type : req.query["amp;response_type"]);
54+
const scope = (req.query.scope ? req.query.scope : req.query["amp;scope"]);
5555
let client = instance.getClientById(client_id);
5656
if (req.user) {
5757
if (!NoderedUtil.IsNullUndefinded(client) && !Array.isArray(client.redirectUris)) {
@@ -160,7 +160,7 @@ export class OAuthProvider {
160160
const clients = this.clients.filter((client) => {
161161
return client.clientId === clientId;
162162
});
163-
return clients.length ? clients[0] : false;
163+
return clients.length ? clients[0] : null;
164164
}
165165

166166
public async saveToken(token, client, user) {
@@ -212,6 +212,7 @@ export class OAuthProvider {
212212
expiresAt.setMonth(expiresAt.getMonth() + 1);
213213
user = TokenUser.From(user);
214214
let client = this.getClientById(client_id);
215+
if (NoderedUtil.IsNullUndefinded(client)) return null;
215216

216217
let role = client.defaultrole;
217218
const keys: string[] = Object.keys(client.rolemappings);

OpenFlowNodeRED/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "openflow-nodered",
3-
"version": "1.1.84",
3+
"version": "1.1.87",
44
"description": "Simple wrapper around NodeRed, RabbitMQ and MongoDB to support a more scaleable NodeRed implementation.\r Also the \"backend\" for [OpenRPA](https://github.com/skadefro/OpenRPA)",
55
"main": "index.js",
66
"scripts": {

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.1.84
1+
1.1.87

docker-compose-toolbox.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ services:
4545
- "traefik.http.routers.web.rule=Host(`toolbox.openrpa.dk`)"
4646
- "traefik.http.routers.web.entrypoints=web"
4747
- "traefik.frontend.passHostHeader=true"
48-
image: "cloudhack/openflow:1.1.84"
48+
image: "cloudhack/openflow:1.1.87"
4949
container_name: "web"
5050
environment:
5151
- update_acl_based_on_groups=true
@@ -82,7 +82,7 @@ services:
8282
- "traefik.http.routers.nodered.rule=Host(`nodered1.toolbox.openrpa.dk`)"
8383
- "traefik.http.routers.nodered.entrypoints=web"
8484
- "traefik.http.services.nodered.loadbalancer.server.port=1880"
85-
image: "cloudhack/openflownodered:1.1.84"
85+
image: "cloudhack/openflownodered:1.1.87"
8686
container_name: "nodered"
8787
environment:
8888
# - nodered_id=1

docker-compose-traefik-letsencrypt.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ services:
6969
- "traefik.http.routers.web.entrypoints=web,websecure"
7070
- "traefik.frontend.passHostHeader=true"
7171
- "traefik.http.routers.web.tls.certresolver=myresolver"
72-
image: "cloudhack/openflow:1.1.84"
72+
image: "cloudhack/openflow:1.1.87"
7373
container_name: "web"
7474
environment:
7575
- update_acl_based_on_groups=true
@@ -107,7 +107,7 @@ services:
107107
- "traefik.http.routers.nodered.entrypoints=web,websecure"
108108
- "traefik.http.services.nodered.loadbalancer.server.port=1880"
109109
- "traefik.http.routers.nodered.tls.certresolver=myresolver"
110-
image: "cloudhack/openflownodered:1.1.84"
110+
image: "cloudhack/openflownodered:1.1.87"
111111
container_name: "nodered"
112112
environment:
113113
# - nodered_id=1

docker-compose-traefik.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ services:
4545
- "traefik.http.routers.web.rule=Host(`localhost.openrpa.dk`)"
4646
- "traefik.http.routers.web.entrypoints=web"
4747
- "traefik.frontend.passHostHeader=true"
48-
image: "cloudhack/openflow:1.1.84"
48+
image: "cloudhack/openflow:1.1.87"
4949
container_name: "web"
5050
environment:
5151
- update_acl_based_on_groups=true
@@ -82,7 +82,7 @@ services:
8282
- "traefik.http.routers.nodered.rule=Host(`nodered1.localhost.openrpa.dk`)"
8383
- "traefik.http.routers.nodered.entrypoints=web"
8484
- "traefik.http.services.nodered.loadbalancer.server.port=1880"
85-
image: "cloudhack/openflownodered:1.1.84"
85+
image: "cloudhack/openflownodered:1.1.87"
8686
container_name: "nodered"
8787
environment:
8888
# - nodered_id=1

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ services:
1818
- "5672:5672"
1919
- "15672:15672"
2020
web:
21-
image: "cloudhack/openflow:1.1.84"
21+
image: "cloudhack/openflow:1.1.87"
2222
environment:
2323
- update_acl_based_on_groups=true
2424
- multi_tenant=false
@@ -52,7 +52,7 @@ services:
5252
- "80:80"
5353
- "5858:5858"
5454
nodered:
55-
image: "cloudhack/openflownodered:1.1.84"
55+
image: "cloudhack/openflownodered:1.1.87"
5656
environment:
5757
# - nodered_id=1
5858
- nodered_sa=nodered1

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "openiap",
3-
"version": "1.1.84",
3+
"version": "1.1.87",
44
"description": "Simple wrapper around NodeRed, RabbitMQ and MongoDB to support a more scaleable NodeRed implementation.\r Also the \"backend\" for [OpenRPA](https://github.com/skadefro/OpenRPA)",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)