Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
Weblist Backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Fachschaftsrat MatheInfo
Karaoke
Weblist Backend
Compare revisions
e31be5f0777bbf4859b4c94c97a135091dc04c49 to 021e913cfd426fa1c4421a1221841bafe89b114e
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
fachschaftsrat-mathematikinformatik/karaoke/weblist-backend
Select target project
No results found
021e913cfd426fa1c4421a1221841bafe89b114e
Select Git revision
Swap
Target
fachschaftsrat-mathematikinformatik/karaoke/weblist-backend
Select target project
fachschaftsrat-mathematikinformatik/karaoke/weblist-backend
1 result
e31be5f0777bbf4859b4c94c97a135091dc04c49
Select Git revision
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (3)
Admins no rate limit
· a9e26ab8
Jan Moritz Mertens
authored
11 months ago
a9e26ab8
Changed http status codes
· 9fcd3e6f
Jan Moritz Mertens
authored
11 months ago
9fcd3e6f
Merge branch 'changes' into 'master'
· 021e913c
Jan Moritz Mertens
authored
11 months ago
Changes See merge request
!13
021e913c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.env
+1
-1
1 addition, 1 deletion
.env
api/oauth2/token.go
+5
-3
5 additions, 3 deletions
api/oauth2/token.go
api/router.go
+3
-1
3 additions, 1 deletion
api/router.go
with
9 additions
and
5 deletions
.env
View file @
021e913c
JWT_SECRET=jhdvfkjlkjfjhefzgjhufenjkfhbfrdiuhhiufrdhb
JWT_SECRET=jhdvfkjlkjfjhefzgjhufenjkfhbfrdiuhhiufrdhb
e
CLIENT_IDS=GHEGZIAHOIWHDOWFHUIEAIHUFEUIAS214389WHJ,
CLIENT_IDS=GHEGZIAHOIWHDOWFHUIEAIHUFEUIAS214389WHJ,
\ No newline at end of file
This diff is collapsed.
Click to expand it.
api/oauth2/token.go
View file @
021e913c
...
@@ -61,18 +61,20 @@ func POSTOauth2Token(c *gin.Context) {
...
@@ -61,18 +61,20 @@ func POSTOauth2Token(c *gin.Context) {
return
[]
byte
(
JwtSecret
),
nil
return
[]
byte
(
JwtSecret
),
nil
})
})
if
errPRT
!=
nil
{
if
errPRT
!=
nil
{
c
.
JSON
(
http
.
Status
InternalServerError
,
gin
.
H
{
"error_parsing_refresh_token"
:
errPRT
})
c
.
JSON
(
http
.
Status
Unauthorized
,
gin
.
H
{
"error_parsing_refresh_token"
:
errPRT
})
}
else
if
claims
,
ok
:=
parsedRefreshToken
.
Claims
.
(
*
JWTPayload
);
ok
{
}
else
if
claims
,
ok
:=
parsedRefreshToken
.
Claims
.
(
*
JWTPayload
);
ok
{
accessTokenString
,
errAT
:=
generateAccessToken
(
claims
.
UserUid
,
[]
string
{},
iat
)
accessTokenString
,
errAT
:=
generateAccessToken
(
claims
.
UserUid
,
[]
string
{},
iat
)
refreshTokenString
,
errRT
:=
generateRefreshToken
(
claims
.
UserUid
,
[]
string
{},
iat
)
refreshTokenString
,
errRT
:=
generateRefreshToken
(
claims
.
UserUid
,
[]
string
{},
iat
)
if
errRT
!=
nil
||
errAT
!=
nil
{
if
errRT
!=
nil
||
errAT
!=
nil
{
c
.
JSON
(
http
.
Status
InternalServerError
,
gin
.
H
{
"error_access_token"
:
errAT
,
"error_refresh_token"
:
errRT
})
c
.
JSON
(
http
.
Status
Unauthorized
,
gin
.
H
{
"error_access_token"
:
errAT
,
"error_refresh_token"
:
errRT
})
}
else
{
}
else
{
c
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"access_token"
:
accessTokenString
,
"token_type"
:
"Bearer"
,
"expires_in"
:
10
,
"refresh_token"
:
refreshTokenString
})
c
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"access_token"
:
accessTokenString
,
"token_type"
:
"Bearer"
,
"expires_in"
:
10
,
"refresh_token"
:
refreshTokenString
})
}
}
}
else
{
c
.
AbortWithStatusJSON
(
http
.
StatusUnauthorized
,
gin
.
H
{
"error"
:
"refresh_token invalid"
})
}
}
}
else
{
}
else
{
c
.
AbortWithStatusJSON
(
http
.
Status
BadRequest
,
gin
.
H
{
"error"
:
"wrong grant type"
})
c
.
AbortWithStatusJSON
(
http
.
Status
Unauthorized
,
gin
.
H
{
"error"
:
"wrong grant type"
})
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
api/router.go
View file @
021e913c
...
@@ -82,7 +82,9 @@ func rateLimit(maxRequests int, timeout time.Duration) gin.HandlerFunc {
...
@@ -82,7 +82,9 @@ func rateLimit(maxRequests int, timeout time.Duration) gin.HandlerFunc {
if
errPRT
!=
nil
{
if
errPRT
!=
nil
{
c
.
AbortWithStatusJSON
(
http
.
StatusInternalServerError
,
gin
.
H
{
"error_parsing_access_token"
:
errPRT
})
c
.
AbortWithStatusJSON
(
http
.
StatusInternalServerError
,
gin
.
H
{
"error_parsing_access_token"
:
errPRT
})
}
else
if
claims
,
ok
:=
parsedAccessToken
.
Claims
.
(
*
oauth2
.
JWTPayload
);
ok
&&
parsedAccessToken
.
Valid
{
}
else
if
claims
,
ok
:=
parsedAccessToken
.
Claims
.
(
*
oauth2
.
JWTPayload
);
ok
&&
parsedAccessToken
.
Valid
{
if
val
,
ok
:=
rateLimits
[
claims
.
UserUid
];
ok
{
if
slices
.
Contains
(
claims
.
Scopes
,
"admin"
)
{
c
.
Next
()
}
else
if
val
,
ok
:=
rateLimits
[
claims
.
UserUid
];
ok
{
if
val
<
maxRequests
{
if
val
<
maxRequests
{
rateLimits
[
claims
.
UserUid
]
+=
1
rateLimits
[
claims
.
UserUid
]
+=
1
time
.
AfterFunc
(
timeout
,
func
()
{
time
.
AfterFunc
(
timeout
,
func
()
{
...
...
This diff is collapsed.
Click to expand it.