Skip to content

Commit f9d2130

Browse files
authored
Merge pull request #270 from authorizerdev/fix/oauth-provider
fix(server): authorizer openid flow
2 parents 824f286 + bb2a42a commit f9d2130

30 files changed

+1121
-735
lines changed

.github/workflows/release.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ on:
22
workflow_dispatch:
33
inputs:
44
logLevel:
5-
description: "Log level"
5+
description: 'Log level'
66
required: true
7-
default: "warning"
7+
default: 'warning'
88
type: choice
99
options:
1010
- info
1111
- warning
1212
- debug
1313
tags:
14-
description: "Tags"
14+
description: 'Tags'
1515
required: false
1616
type: boolean
1717
release:
@@ -25,7 +25,7 @@ jobs:
2525
- uses: actions/checkout@v3
2626
- uses: actions/setup-node@v2
2727
with:
28-
node-version: "16"
28+
node-version: '16'
2929
- # Add support for more platforms with QEMU (optional)
3030
# https://github.com/docker/setup-qemu-action
3131
name: Set up QEMU
@@ -36,7 +36,7 @@ jobs:
3636
platforms: linux/amd64,linux/arm64
3737
- uses: actions/setup-go@v2
3838
with:
39-
go-version: "^1.17.3"
39+
go-version: '^1.19.1'
4040
- name: Install dependencies
4141
run: |
4242
sudo apt-get install build-essential wget zip libc6-dev-arm64-cross && \

app/.prettierrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"tabWidth": 2,
33
"singleQuote": true,
44
"trailingComma": "all",
5-
"useTabs": false
5+
"useTabs": true
66
}

app/package-lock.json

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
"scripts": {
77
"build": "rm -rf build && NODE_ENV=production node ./esbuild.config.js",
88
"start": "NODE_ENV=development node ./esbuild.config.js",
9-
"format": "prettier --write --use-tabs 'src/**/*.(ts|tsx|js|jsx)'"
9+
"format": "prettier --write 'src/**/*.(ts|tsx|js|jsx)'"
1010
},
1111
"keywords": [],
1212
"author": "Lakhan Samani",
1313
"license": "ISC",
1414
"dependencies": {
15-
"@authorizerdev/authorizer-react": "^1.1.2",
15+
"@authorizerdev/authorizer-react": "^1.1.3",
1616
"@types/react": "^17.0.15",
1717
"@types/react-dom": "^17.0.9",
1818
"esbuild": "^0.12.17",

app/src/Root.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ export default function Root({
3838
const scope = searchParams.get('scope')
3939
? searchParams.get('scope')?.toString().split(' ')
4040
: ['openid', 'profile', 'email'];
41+
const code = searchParams.get('code') || '';
42+
const nonce = searchParams.get('nonce') || '';
4143

4244
const urlProps: Record<string, any> = {
4345
state,
@@ -58,9 +60,19 @@ export default function Root({
5860
if (token) {
5961
let redirectURL = config.redirectURL || '/app';
6062
let params = `access_token=${token.access_token}&id_token=${token.id_token}&expires_in=${token.expires_in}&state=${globalState.state}`;
63+
64+
if (code !== '') {
65+
params += `&code=${code}`;
66+
}
67+
68+
if (nonce !== '') {
69+
params += `&nonce=${nonce}`;
70+
}
71+
6172
if (token.refresh_token) {
6273
params += `&refresh_token=${token.refresh_token}`;
6374
}
75+
6476
const url = new URL(redirectURL);
6577
if (redirectURL.includes('?')) {
6678
redirectURL = `${redirectURL}&${params}`;
@@ -74,7 +86,7 @@ export default function Root({
7486
}
7587
}
7688
return () => {};
77-
}, [token]);
89+
}, [token, config]);
7890

7991
if (loading) {
8092
return <h1>Loading...</h1>;
@@ -100,7 +112,7 @@ export default function Root({
100112
<Route path="/app" exact>
101113
<Login urlProps={urlProps} />
102114
</Route>
103-
<Route path="/app/signup" exact>
115+
<Route path="/app/signup">
104116
<SignUp urlProps={urlProps} />
105117
</Route>
106118
<Route path="/app/reset-password">

dashboard/.prettierrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"tabWidth": 2,
33
"singleQuote": true,
44
"trailingComma": "all",
5-
"useTabs": false
5+
"useTabs": true
66
}

server/constants/oauth2.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package constants
2+
3+
const (
4+
// - query: for Authorization Code grant. 302 Found triggers redirect.
5+
ResponseModeQuery = "query"
6+
// - fragment: for Implicit grant. 302 Found triggers redirect.
7+
ResponseModeFragment = "fragment"
8+
// - form_post: 200 OK with response parameters embedded in an HTML form as hidden parameters.
9+
ResponseModeFormPost = "form_post"
10+
// - web_message: For Silent Authentication. Uses HTML5 web messaging.
11+
ResponseModeWebMessage = "web_message"
12+
13+
// For the Authorization Code grant, use response_type=code to include the authorization code.
14+
ResponseTypeCode = "code"
15+
// For the Implicit grant, use response_type=token to include an access token.
16+
ResponseTypeToken = "token"
17+
// For the Implicit grant of id_token, use response_type=id_token to include an identifier token.
18+
ResponseTypeIDToken = "id_token"
19+
)

server/go.mod

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ require (
77
github.com/arangodb/go-driver v1.2.1
88
github.com/aws/aws-sdk-go v1.44.109
99
github.com/coreos/go-oidc/v3 v3.1.0
10-
github.com/denisenkom/go-mssqldb v0.11.0 // indirect
1110
github.com/gin-gonic/gin v1.8.1
12-
github.com/glebarez/sqlite v1.5.0 // indirect
11+
github.com/glebarez/sqlite v1.5.0
1312
github.com/go-playground/validator/v10 v10.11.1 // indirect
1413
github.com/go-redis/redis/v8 v8.11.0
1514
github.com/goccy/go-json v0.9.11 // indirect
@@ -19,7 +18,6 @@ require (
1918
github.com/google/uuid v1.3.0
2019
github.com/guregu/dynamo v1.16.0
2120
github.com/joho/godotenv v1.3.0
22-
github.com/mitchellh/gox v1.0.1 // indirect
2321
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
2422
github.com/pelletier/go-toml/v2 v2.0.5 // indirect
2523
github.com/robertkrimen/otto v0.0.0-20211024170158-b87d35c0b86f

0 commit comments

Comments
 (0)