update at 2023/08/14

This commit is contained in:
2023-08-14 21:41:37 +08:00
parent a039a664f1
commit 44e8cbee2c
255 changed files with 20426 additions and 233 deletions

View File

@@ -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
}