-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from TYuan0816/refactor/server
Refactor AUSF app, sbi, processor, consumer
- Loading branch information
Showing
27 changed files
with
1,834 additions
and
1,863 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package sbi | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/gin-gonic/gin" | ||
) | ||
|
||
func (s *Server) getSorprotectionRoutes() []Route { | ||
return []Route{ | ||
{ | ||
Method: http.MethodGet, | ||
Pattern: "/", | ||
APIFunc: Index, | ||
}, | ||
{ | ||
Method: http.MethodPost, | ||
Pattern: "/:supi/ue-sor", | ||
APIFunc: s.SupiUeSorPost, | ||
}, | ||
} | ||
} | ||
|
||
func (s *Server) SupiUeSorPost(c *gin.Context) { | ||
c.JSON(http.StatusNotImplemented, gin.H{}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
/* | ||
* Nausf_UeAuthentication | ||
* | ||
* UeAuthentication Service | ||
* © 2021, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). | ||
* All rights reserved. | ||
* | ||
* API version: 3.0.3 | ||
* Generated by: OpenAPI Generator (https://openapi-generator.tech) | ||
*/ | ||
|
||
package sbi | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/gin-gonic/gin" | ||
|
||
"github.com/free5gc/ausf/internal/logger" | ||
"github.com/free5gc/openapi" | ||
"github.com/free5gc/openapi/models" | ||
) | ||
|
||
// Index is the index handler. | ||
func Index(c *gin.Context) { | ||
c.String(http.StatusOK, "Hello World!") | ||
} | ||
|
||
func (s *Server) getUeAuthenticationRoutes() []Route { | ||
return []Route{ | ||
{ | ||
Method: http.MethodGet, | ||
Pattern: "/", | ||
APIFunc: Index, | ||
}, | ||
{ | ||
Method: http.MethodPost, | ||
Pattern: "/ue-authentications/:authCtxId/eap-session", | ||
APIFunc: s.EapAuthMethodPost, | ||
}, | ||
{ | ||
Method: http.MethodPost, | ||
Pattern: "/ue-authentications", | ||
APIFunc: s.UeAuthenticationsPost, | ||
}, | ||
{ | ||
Method: http.MethodPut, | ||
Pattern: "/ue-authentications/:authCtxId/5g-aka-confirmation", | ||
APIFunc: s.UeAuthenticationsAuthCtxID5gAkaConfirmationPut, | ||
}, | ||
} | ||
} | ||
|
||
// EapAuthMethodPost - | ||
func (s *Server) EapAuthMethodPost(c *gin.Context) { | ||
var eapSessionReq models.EapSession | ||
|
||
requestBody, err := c.GetRawData() | ||
if err != nil { | ||
problemDetail := models.ProblemDetails{ | ||
Title: "System failure", | ||
Status: http.StatusInternalServerError, | ||
Detail: err.Error(), | ||
Cause: "SYSTEM_FAILURE", | ||
} | ||
logger.Auth5gAkaLog.Errorf("Get Request Body error: %+v", err) | ||
c.JSON(http.StatusInternalServerError, problemDetail) | ||
return | ||
} | ||
|
||
err = openapi.Deserialize(&eapSessionReq, requestBody, "application/json") | ||
if err != nil { | ||
problemDetail := "[Request Body] " + err.Error() | ||
rsp := models.ProblemDetails{ | ||
Title: "Malformed request syntax", | ||
Status: http.StatusBadRequest, | ||
Detail: problemDetail, | ||
} | ||
logger.Auth5gAkaLog.Errorln(problemDetail) | ||
c.JSON(http.StatusBadRequest, rsp) | ||
return | ||
} | ||
eapSessionId := c.Param("authCtxId") | ||
|
||
s.Processor().HandleEapAuthComfirmRequest(c, eapSessionReq, eapSessionId) | ||
} | ||
|
||
// UeAuthenticationsPost | ||
func (s *Server) UeAuthenticationsPost(c *gin.Context) { | ||
var authInfo models.AuthenticationInfo | ||
|
||
requestBody, err := c.GetRawData() | ||
if err != nil { | ||
problemDetail := models.ProblemDetails{ | ||
Title: "System failure", | ||
Status: http.StatusInternalServerError, | ||
Detail: err.Error(), | ||
Cause: "SYSTEM_FAILURE", | ||
} | ||
logger.UeAuthLog.Errorf("Get Request Body error: %+v", err) | ||
c.JSON(http.StatusInternalServerError, problemDetail) | ||
return | ||
} | ||
|
||
err = openapi.Deserialize(&authInfo, requestBody, "application/json") | ||
if err != nil { | ||
problemDetail := "[Request Body] " + err.Error() | ||
rsp := models.ProblemDetails{ | ||
Title: "Malformed request syntax", | ||
Status: http.StatusBadRequest, | ||
Detail: problemDetail, | ||
} | ||
logger.UeAuthLog.Errorln(problemDetail) | ||
c.JSON(http.StatusBadRequest, rsp) | ||
return | ||
} | ||
|
||
s.Processor().HandleUeAuthPostRequest(c, authInfo) | ||
} | ||
|
||
// UeAuthenticationsAuthCtxID5gAkaConfirmationPut | ||
func (s *Server) UeAuthenticationsAuthCtxID5gAkaConfirmationPut(c *gin.Context) { | ||
var confirmationData models.ConfirmationData | ||
|
||
requestBody, err := c.GetRawData() | ||
if err != nil { | ||
problemDetail := models.ProblemDetails{ | ||
Title: "System failure", | ||
Status: http.StatusInternalServerError, | ||
Detail: err.Error(), | ||
Cause: "SYSTEM_FAILURE", | ||
} | ||
logger.Auth5gAkaLog.Errorf("Get Request Body error: %+v", err) | ||
c.JSON(http.StatusInternalServerError, problemDetail) | ||
return | ||
} | ||
|
||
err = openapi.Deserialize(&confirmationData, requestBody, "application/json") | ||
if err != nil { | ||
problemDetail := "[Request Body] " + err.Error() | ||
rsp := models.ProblemDetails{ | ||
Title: "Malformed request syntax", | ||
Status: http.StatusBadRequest, | ||
Detail: problemDetail, | ||
} | ||
logger.Auth5gAkaLog.Errorln(problemDetail) | ||
c.JSON(http.StatusBadRequest, rsp) | ||
return | ||
} | ||
confirmationDataResponseId := c.Param("authCtxId") | ||
|
||
s.Processor().HandleAuth5gAkaComfirmRequest(c, confirmationData, confirmationDataResponseId) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package sbi | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/gin-gonic/gin" | ||
) | ||
|
||
func (s *Server) getUpuprotectionRoutes() []Route { | ||
return []Route{ | ||
{ | ||
Method: http.MethodGet, | ||
Pattern: "/", | ||
APIFunc: Index, | ||
}, | ||
{ | ||
Method: http.MethodPost, | ||
Pattern: "/:supi/ue-upu", | ||
APIFunc: s.SupiUeUpuPost, | ||
}, | ||
} | ||
} | ||
|
||
func (s *Server) SupiUeUpuPost(c *gin.Context) { | ||
c.JSON(http.StatusNotImplemented, gin.H{}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package consumer | ||
|
||
import ( | ||
"github.com/free5gc/ausf/pkg/app" | ||
"github.com/free5gc/openapi/Nnrf_NFDiscovery" | ||
"github.com/free5gc/openapi/Nnrf_NFManagement" | ||
"github.com/free5gc/openapi/Nudm_UEAuthentication" | ||
) | ||
|
||
type ConsumerAusf interface { | ||
app.App | ||
} | ||
|
||
type Consumer struct { | ||
ConsumerAusf | ||
|
||
*nnrfService | ||
*nudmService | ||
} | ||
|
||
func NewConsumer(ausf ConsumerAusf) (*Consumer, error) { | ||
c := &Consumer{ | ||
ConsumerAusf: ausf, | ||
} | ||
|
||
c.nnrfService = &nnrfService{ | ||
consumer: c, | ||
nfMngmntClients: make(map[string]*Nnrf_NFManagement.APIClient), | ||
nfDiscClients: make(map[string]*Nnrf_NFDiscovery.APIClient), | ||
} | ||
|
||
c.nudmService = &nudmService{ | ||
consumer: c, | ||
ueauClients: make(map[string]*Nudm_UEAuthentication.APIClient), | ||
} | ||
|
||
return c, nil | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.