mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-23 02:35:49 +08:00
fix: fix failure of introspection (#682)
* fix: fix failure of introspection * Update token.go Co-authored-by: Yang Luo <hsluoyz@qq.com>
This commit is contained in:
parent
73bd9dd517
commit
b0b3eb0805
@ -80,9 +80,7 @@ p, *, *, GET, /api/get-app-login, *, *
|
|||||||
p, *, *, POST, /api/logout, *, *
|
p, *, *, POST, /api/logout, *, *
|
||||||
p, *, *, GET, /api/get-account, *, *
|
p, *, *, GET, /api/get-account, *, *
|
||||||
p, *, *, GET, /api/userinfo, *, *
|
p, *, *, GET, /api/userinfo, *, *
|
||||||
p, *, *, POST, /api/login/oauth/access_token, *, *
|
p, *, *, *, /api/login/oauth, *, *
|
||||||
p, *, *, POST, /api/login/oauth/refresh_token, *, *
|
|
||||||
p, *, *, GET, /api/login/oauth/logout, *, *
|
|
||||||
p, *, *, GET, /api/get-application, *, *
|
p, *, *, GET, /api/get-application, *, *
|
||||||
p, *, *, GET, /api/get-user, *, *
|
p, *, *, GET, /api/get-user, *, *
|
||||||
p, *, *, GET, /api/get-user-application, *, *
|
p, *, *, GET, /api/get-user-application, *, *
|
||||||
|
@ -275,21 +275,20 @@ func (c *ApiController) IntrospectToken() {
|
|||||||
tokenValue := c.Input().Get("token")
|
tokenValue := c.Input().Get("token")
|
||||||
clientId, clientSecret, ok := c.Ctx.Request.BasicAuth()
|
clientId, clientSecret, ok := c.Ctx.Request.BasicAuth()
|
||||||
if !ok {
|
if !ok {
|
||||||
util.LogWarning(c.Ctx, "Basic Authorization parses failed")
|
clientId = c.Input().Get("client_id")
|
||||||
c.Data["json"] = Response{Status: "error", Msg: "Unauthorized operation"}
|
clientSecret = c.Input().Get("client_secret")
|
||||||
c.ServeJSON()
|
if clientId == "" || clientSecret == "" {
|
||||||
return
|
c.ResponseError("empty clientId or clientSecret")
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
application := object.GetApplicationByClientId(clientId)
|
application := object.GetApplicationByClientId(clientId)
|
||||||
if application == nil || application.ClientSecret != clientSecret {
|
if application == nil || application.ClientSecret != clientSecret {
|
||||||
util.LogWarning(c.Ctx, "Basic Authorization failed")
|
c.ResponseError("invalid application or wrong clientSecret")
|
||||||
c.Data["json"] = Response{Status: "error", Msg: "Unauthorized operation"}
|
|
||||||
c.ServeJSON()
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
token := object.GetTokenByTokenAndApplication(tokenValue, application.Name)
|
token := object.GetTokenByTokenAndApplication(tokenValue, application.Name)
|
||||||
if token == nil {
|
if token == nil {
|
||||||
util.LogWarning(c.Ctx, "application: %s can not find token", application.Name)
|
|
||||||
c.Data["json"] = &object.IntrospectionResponse{Active: false}
|
c.Data["json"] = &object.IntrospectionResponse{Active: false}
|
||||||
c.ServeJSON()
|
c.ServeJSON()
|
||||||
return
|
return
|
||||||
@ -299,7 +298,6 @@ func (c *ApiController) IntrospectToken() {
|
|||||||
// and token revoked case. but we not implement
|
// and token revoked case. but we not implement
|
||||||
// TODO: 2022-03-03 add token revoked check, when we implemented the Token Revocation(rfc7009) Specs.
|
// TODO: 2022-03-03 add token revoked check, when we implemented the Token Revocation(rfc7009) Specs.
|
||||||
// refs: https://tools.ietf.org/html/rfc7009
|
// refs: https://tools.ietf.org/html/rfc7009
|
||||||
util.LogWarning(c.Ctx, "token invalid")
|
|
||||||
c.Data["json"] = &object.IntrospectionResponse{Active: false}
|
c.Data["json"] = &object.IntrospectionResponse{Active: false}
|
||||||
c.ServeJSON()
|
c.ServeJSON()
|
||||||
return
|
return
|
||||||
|
@ -104,6 +104,11 @@ func getUrlPath(urlPath string) string {
|
|||||||
if strings.HasPrefix(urlPath, "/cas") && (strings.HasSuffix(urlPath, "/serviceValidate") || strings.HasSuffix(urlPath, "/proxy") || strings.HasSuffix(urlPath, "/proxyValidate") || strings.HasSuffix(urlPath, "/validate") || strings.HasSuffix(urlPath, "/p3/serviceValidate") || strings.HasSuffix(urlPath, "/p3/proxyValidate") || strings.HasSuffix(urlPath, "/samlValidate")) {
|
if strings.HasPrefix(urlPath, "/cas") && (strings.HasSuffix(urlPath, "/serviceValidate") || strings.HasSuffix(urlPath, "/proxy") || strings.HasSuffix(urlPath, "/proxyValidate") || strings.HasSuffix(urlPath, "/validate") || strings.HasSuffix(urlPath, "/p3/serviceValidate") || strings.HasSuffix(urlPath, "/p3/proxyValidate") || strings.HasSuffix(urlPath, "/samlValidate")) {
|
||||||
return "/cas"
|
return "/cas"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if strings.HasPrefix(urlPath, "/api/login/oauth") {
|
||||||
|
return "/api/login/oauth"
|
||||||
|
}
|
||||||
|
|
||||||
return urlPath
|
return urlPath
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user