update at 2023/08/14
This commit is contained in:
@@ -14,8 +14,11 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
UriOauthToken = config.UriPrefix + "/securityManagement/{apiVersion}/oauth/token"
|
||||
UriOauthHandshake = config.UriPrefix + "/securityManagement/{apiVersion}/oauth/handshake"
|
||||
UriOauthToken = config.DefaultUriPrefix + "/securityManagement/{apiVersion}/oauth/token"
|
||||
UriOauthHandshake = config.DefaultUriPrefix + "/securityManagement/{apiVersion}/oauth/handshake"
|
||||
|
||||
CustomUriOauthToken = config.UriPrefix + "/securityManagement/{apiVersion}/oauth/token"
|
||||
CustomUriOauthHandshake = config.UriPrefix + "/securityManagement/{apiVersion}/oauth/handshake"
|
||||
)
|
||||
|
||||
func LoginFromOMC(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -105,36 +108,42 @@ func LoginFromOMC(w http.ResponseWriter, r *http.Request) {
|
||||
func LogoutFromOMC(w http.ResponseWriter, r *http.Request) {
|
||||
log.Info("LogoutFromOMC processing... ")
|
||||
|
||||
// check media type(content type) only support "application/json"
|
||||
if services.IsVallidContentType(r, !config.GetYamlConfig().OMC.CheckContentType) {
|
||||
log.Error("Invalid Content-Type")
|
||||
services.ResponseUnsupportedMediaType415(w)
|
||||
token, err := services.CheckFrontValidRequest(w, r)
|
||||
if err != nil {
|
||||
log.Error("Request error:", err)
|
||||
return
|
||||
}
|
||||
// // check media type(content type) only support "application/json"
|
||||
// if services.IsVallidContentType(r, config.GetYamlConfig().OMC.CheckContentType) == false {
|
||||
// log.Error("Invalid Content-Type")
|
||||
// services.ResponseUnsupportedMediaType415(w)
|
||||
// return
|
||||
// }
|
||||
|
||||
// check extend uri, response 404
|
||||
if !services.IsValidOAuthUri(r) {
|
||||
log.Error("Uri is invalid")
|
||||
services.ResponseNotFound404UriNotExist(w, r)
|
||||
return
|
||||
}
|
||||
// // check extend uri, response 404
|
||||
// if !services.IsValidOAuthUri(r) {
|
||||
// log.Error("Uri is invalid")
|
||||
// services.ResponseNotFound404UriNotExist(w, r)
|
||||
// return
|
||||
// }
|
||||
|
||||
// error processing ...
|
||||
// 401-1 response
|
||||
token, ret := oauth.IsCarriedToken(r)
|
||||
if !ret {
|
||||
log.Error("AccessToken is not carried")
|
||||
services.ResponseUnauthorized401AccessTokenNotCarried(w)
|
||||
return
|
||||
}
|
||||
// // error processing ...
|
||||
// // 401-1 response
|
||||
// token, ret := oauth.IsCarriedToken(r)
|
||||
// if ret == false {
|
||||
// log.Error("AccessToken is not carried")
|
||||
// services.ResponseUnauthorized401AccessTokenNotCarried(w)
|
||||
// return
|
||||
// }
|
||||
|
||||
_, err := dborm.XormLogoutUpdateSession(token)
|
||||
_, err = dborm.XormLogoutUpdateSession(token)
|
||||
if err != nil {
|
||||
log.Error("Uri is invalid")
|
||||
services.ResponseNotFound404UriNotExist(w, r)
|
||||
return
|
||||
}
|
||||
services.ResponseStatusOK200Null(w)
|
||||
return
|
||||
}
|
||||
|
||||
func HandshakeFromOMC(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -157,7 +166,7 @@ func HandshakeFromOMC(w http.ResponseWriter, r *http.Request) {
|
||||
// error processing ...
|
||||
// 401-1 response
|
||||
token, ret := oauth.IsCarriedToken(r)
|
||||
if !ret {
|
||||
if ret == false {
|
||||
log.Error("AccessToken is not carried")
|
||||
services.ResponseUnauthorized401AccessTokenNotCarried(w)
|
||||
return
|
||||
@@ -170,4 +179,5 @@ func HandshakeFromOMC(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
services.ResponseStatusOK200Null(w)
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user