Skip to content

Commit 2080379

Browse files
committed
Oauth2 support
1 parent f23299f commit 2080379

File tree

25 files changed

+529
-30
lines changed

25 files changed

+529
-30
lines changed

backend/.testcoverage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ threshold:
1818
# package: 30
1919
# (optional; default 0)
2020
# The minimum total coverage project should have
21-
total: 33
21+
total: 30

backend/embed/api_docs/components/AuthConfigObject.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"enum": [
88
"local",
99
"ldap",
10-
"oidc"
10+
"oauth"
1111
]
1212
}
1313
}

backend/embed/api_docs/components/UserAuthObject.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
},
2525
"type": {
2626
"type": "string",
27-
"pattern": "^(local|ldap|oidc)$"
27+
"pattern": "^(local|ldap|oauth)$"
2828
}
2929
}
3030
}

backend/embed/api_docs/components/UserObject.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
},
5454
"type": {
5555
"type": "string",
56-
"pattern": "^(local|ldap|oidc)$"
56+
"pattern": "^(local|ldap|oauth)$"
5757
}
5858
}
5959
},

backend/embed/migrations/mysql/20201013035839_initial_data.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ INSERT INTO `setting` (
4848
(
4949
ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000),
5050
ROUND(UNIX_TIMESTAMP(CURTIME(4)) * 1000),
51-
"oidc-auth",
52-
"Configuration for OIDC authentication",
51+
"oauth-auth",
52+
"Configuration for OAuth authentication",
5353
'{}' -- remember this is json
5454
),
5555
(

backend/embed/migrations/postgres/20201013035839_initial_data.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ INSERT INTO "setting" (
4848
(
4949
EXTRACT(EPOCH FROM TIMESTAMP '2011-05-17 10:40:28.876944') * 1000,
5050
EXTRACT(EPOCH FROM TIMESTAMP '2011-05-17 10:40:28.876944') * 1000,
51-
'oidc-auth',
52-
'Configuration for OIDC authentication',
51+
'oauth-auth',
52+
'Configuration for OAuth authentication',
5353
'{}' -- remember this is json
5454
),
5555
(

backend/embed/migrations/sqlite/20201013035839_initial_data.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ INSERT INTO `setting` (
4747
(
4848
unixepoch() * 1000,
4949
unixepoch() * 1000,
50-
"oidc-auth",
51-
"Configuration for OIDC authentication",
50+
"oauth-auth",
51+
"Configuration for OAuth authentication",
5252
'{}' -- remember this is json
5353
),
5454
(

backend/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ require (
2424
github.com/vrischmann/envconfig v1.3.0
2525
go.uber.org/goleak v1.3.0
2626
golang.org/x/crypto v0.27.0
27+
golang.org/x/oauth2 v0.23.0
2728
gorm.io/datatypes v1.2.1
2829
gorm.io/driver/mysql v1.5.7
2930
gorm.io/driver/postgres v1.5.9

backend/go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
205205
golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
206206
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
207207
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
208+
golang.org/x/oauth2 v0.23.0 h1:PbgcYx2W7i4LvjJWEbf0ngHV6qJYr86PkAV3bXdLEbs=
209+
golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
208210
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
209211
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
210212
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=

backend/internal/api/handler/auth.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ func NewToken() func(http.ResponseWriter, *http.Request) {
7070
switch payload.Type {
7171
case "ldap":
7272
newTokenLDAP(w, r, payload)
73-
case "oidc":
74-
newTokenOIDC(w, r, payload)
7573
case "local":
7674
newTokenLocal(w, r, payload)
7775
}
@@ -199,10 +197,6 @@ func newTokenLDAP(w http.ResponseWriter, r *http.Request, payload tokenPayload)
199197
}
200198
}
201199

202-
func newTokenOIDC(w http.ResponseWriter, r *http.Request, _ tokenPayload) {
203-
h.ResultErrorJSON(w, r, http.StatusInternalServerError, "NOT YET SUPPORTED", nil)
204-
}
205-
206200
// RefreshToken an existing token by given them a new one with the same claims
207201
// Route: POST /auth/refresh
208202
func RefreshToken() func(http.ResponseWriter, *http.Request) {

0 commit comments

Comments
 (0)