Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Upgrade openapi to R17 #30

Open
wants to merge 12 commits into
base: next
Choose a base branch
from
71 changes: 39 additions & 32 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,56 +1,63 @@
module github.com/free5gc/ausf

go 1.21
go 1.21.0

require (
github.com/antihax/optional v1.0.0
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2
github.com/bronze1man/radius v0.0.0-20190516032554-afd8baec892d
github.com/free5gc/openapi v1.0.8
github.com/free5gc/openapi v1.0.9-0.20240823100026-6a9f667e914f
github.com/free5gc/util v1.0.6
github.com/gin-gonic/gin v1.9.1
github.com/gin-gonic/gin v1.10.0
github.com/google/gopacket v1.1.19
github.com/google/uuid v1.3.0
github.com/google/uuid v1.6.0
github.com/pkg/errors v0.9.1
github.com/sirupsen/logrus v1.8.1
github.com/urfave/cli v1.22.5
github.com/sirupsen/logrus v1.9.3
github.com/urfave/cli v1.22.15
go.uber.org/mock v0.4.0
gopkg.in/yaml.v2 v2.4.0
)

require (
github.com/bytedance/sonic v1.9.1 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
github.com/bytedance/sonic v1.12.2 // indirect
github.com/bytedance/sonic/loader v0.2.0 // indirect
github.com/cloudwego/base64x v0.1.4 // indirect
github.com/cloudwego/iasm v0.2.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/gabriel-vasile/mimetype v1.4.5 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.14.0 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/golang-jwt/jwt v3.2.1+incompatible // indirect
github.com/golang/protobuf v1.5.0 // indirect
github.com/go-playground/validator/v10 v10.22.0 // indirect
github.com/goccy/go-json v0.10.3 // indirect
github.com/golang-jwt/jwt/v5 v5.2.1 // indirect
github.com/h2non/gock v1.2.0 // indirect
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/klauspost/cpuid/v2 v2.2.8 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
github.com/russross/blackfriday/v2 v2.0.1 // indirect
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/tim-ywliu/nested-logrus-formatter v1.3.2 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.11 // indirect
golang.org/x/arch v0.3.0 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/oauth2 v0.0.0-20210810183815-faf39c7919d5 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/appengine v1.6.6 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/h2non/gock.v1 v1.1.2 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.49.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect
go.opentelemetry.io/otel v1.24.0 // indirect
go.opentelemetry.io/otel/metric v1.24.0 // indirect
go.opentelemetry.io/otel/trace v1.24.0 // indirect
golang.org/x/arch v0.9.0 // indirect
golang.org/x/crypto v0.26.0 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/oauth2 v0.22.0 // indirect
golang.org/x/sys v0.24.0 // indirect
golang.org/x/text v0.17.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
506 changes: 90 additions & 416 deletions go.sum

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions internal/context/ausf_context_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,17 @@ func InitAusfContext(context *AUSFContext) {
context.PlmnList = append(context.PlmnList, configuration.PlmnSupportList...)

// context.NfService
context.NfService = make(map[models.ServiceName]models.NfService)
context.NfService = make(map[models.ServiceName]models.NrfNfManagementNfService)
AddNfServices(&context.NfService, config, context)
fmt.Println("ausf context = ", context)

context.EapAkaSupiImsiPrefix = configuration.EapAkaSupiImsiPrefix
}

func AddNfServices(serviceMap *map[models.ServiceName]models.NfService, config *factory.Config, context *AUSFContext) {
var nfService models.NfService
func AddNfServices(
serviceMap *map[models.ServiceName]models.NrfNfManagementNfService, config *factory.Config, context *AUSFContext,
) {
var nfService models.NrfNfManagementNfService
var ipEndPoints []models.IpEndPoint
var nfServiceVersions []models.NfServiceVersion
services := *serviceMap
Expand All @@ -86,7 +88,7 @@ func AddNfServices(serviceMap *map[models.ServiceName]models.NfService, config *
nfService.Scheme = context.UriScheme
nfService.NfServiceStatus = models.NfServiceStatus_REGISTERED

nfService.IpEndPoints = &ipEndPoints
nfService.Versions = &nfServiceVersions
nfService.IpEndPoints = ipEndPoints
nfService.Versions = nfServiceVersions
services[models.ServiceName_NAUSF_AUTH] = nfService
}
8 changes: 4 additions & 4 deletions internal/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type AUSFContext struct {
UriScheme models.UriScheme
NrfUri string
NrfCertPem string
NfService map[models.ServiceName]models.NfService
NfService map[models.ServiceName]models.NrfNfManagementNfService
PlmnList []models.PlmnId
UdmUeauUrl string
snRegex *regexp.Regexp
Expand All @@ -35,7 +35,7 @@ type AusfUeContext struct {
Kausf string
Kseaf string
ServingNetworkName string
AuthStatus models.AuthResult
AuthStatus models.AusfUeAuthenticationAuthResult
UdmUeauUrl string

// for 5G AKA
Expand Down Expand Up @@ -166,13 +166,13 @@ func (a *AUSFContext) GetSelfID() string {
return a.NfId
}

func (c *AUSFContext) GetTokenCtx(serviceName models.ServiceName, targetNF models.NfType) (
func (c *AUSFContext) GetTokenCtx(serviceName models.ServiceName, targetNF models.NrfNfManagementNfType) (
context.Context, *models.ProblemDetails, error,
) {
if !c.OAuth2Required {
return context.TODO(), nil, nil
}
return oauth.GetTokenCtx(models.NfType_AUSF, targetNF,
return oauth.GetTokenCtx(models.NrfNfManagementNfType_AUSF, targetNF,
c.NfId, c.NrfUri, string(serviceName))
}

Expand Down
10 changes: 7 additions & 3 deletions internal/sbi/api_sorprotection.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,22 @@ import (
func (s *Server) getSorprotectionRoutes() []Route {
return []Route{
{
Name: "Index",
Method: http.MethodGet,
Pattern: "/",
APIFunc: Index,
APIFunc: func(c *gin.Context) {
c.String(http.StatusOK, "Hello free5GC!")
},
},
{
Name: "SupiUeSorPost",
Method: http.MethodPost,
Pattern: "/:supi/ue-sor",
APIFunc: s.SupiUeSorPost,
APIFunc: s.HTTPSupiUeSorPost,
},
}
}

func (s *Server) SupiUeSorPost(c *gin.Context) {
func (s *Server) HTTPSupiUeSorPost(c *gin.Context) {
c.JSON(http.StatusNotImplemented, gin.H{})
}
94 changes: 84 additions & 10 deletions internal/sbi/api_ueauthentication.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,30 +29,78 @@ func Index(c *gin.Context) {
func (s *Server) getUeAuthenticationRoutes() []Route {
return []Route{
{
Name: "Index",
Method: http.MethodGet,
Pattern: "/",
APIFunc: Index,
APIFunc: func(c *gin.Context) {
c.String(http.StatusOK, "Hello free5GC!")
},
},
{
Name: "EapAuthMethod",
Method: http.MethodPost,
Pattern: "/ue-authentications/:authCtxId/eap-session",
APIFunc: s.EapAuthMethodPost,
APIFunc: s.HTTPEapAuthMethod,
},
{
Name: "UeAuthenticationsPost",
Method: http.MethodPost,
Pattern: "/ue-authentications",
APIFunc: s.UeAuthenticationsPost,
APIFunc: s.HTTPUeAuthenticationsPost,
},
{
Name: "UeAuthenticationsAuthCtxId5gAkaConfirmationPut",
Method: http.MethodPut,
Pattern: "/ue-authentications/:authCtxId/5g-aka-confirmation",
APIFunc: s.UeAuthenticationsAuthCtxID5gAkaConfirmationPut,
APIFunc: s.HTTPUeAuthenticationsAuthCtxId5gAkaConfirmationPut,
},

{
Name: "Delete5gAkaAuthenticationResult",
Method: http.MethodDelete,
Pattern: "/ue-authentications/:authCtxId/5g-aka-confirmation",
APIFunc: s.HTTPDelete5gAkaAuthenticationResult,
},
{
Name: "DeleteEapAuthenticationResult",
Method: http.MethodDelete,
Pattern: "/ue-authentications/:authCtxId/eap-session",
APIFunc: s.HTTPDeleteEapAuthenticationResult,
},
{
Name: "DeleteProSeAuthenticationResult",
Method: http.MethodDelete,
Pattern: "/prose-authentications/:authCtxId/prose-auth",
APIFunc: s.HTTPDeleteProSeAuthenticationResult,
},
{
Name: "ProseAuth",
Method: http.MethodPost,
Pattern: "/prose-authentications",
APIFunc: s.HTTPProseAuth,
},
{
Name: "ProseAuthenticationsPost",
Method: http.MethodPost,
Pattern: "/prose-authentications/:authCtxId/prose-auth",
APIFunc: s.HTTPProseAuthenticationsPost,
},
{
Name: "RgAuthenticationsPost",
Method: http.MethodPost,
Pattern: "/rg-authentications/:authCtxId",
APIFunc: s.HTTPRgAuthenticationsPost,
},
{
Name: "UeAuthenticationsDeregisterPost",
Method: http.MethodPost,
Pattern: "/ue-authentications/deregister",
APIFunc: s.HTTPUeAuthenticationsDeregisterPost,
},
}
}

// EapAuthMethodPost -
func (s *Server) EapAuthMethodPost(c *gin.Context) {
func (s *Server) HTTPEapAuthMethod(c *gin.Context) {
var eapSessionReq models.EapSession

requestBody, err := c.GetRawData()
Expand Down Expand Up @@ -85,8 +133,7 @@ func (s *Server) EapAuthMethodPost(c *gin.Context) {
s.Processor().HandleEapAuthComfirmRequest(c, eapSessionReq, eapSessionId)
}

// UeAuthenticationsPost
func (s *Server) UeAuthenticationsPost(c *gin.Context) {
func (s *Server) HTTPUeAuthenticationsPost(c *gin.Context) {
var authInfo models.AuthenticationInfo

requestBody, err := c.GetRawData()
Expand Down Expand Up @@ -118,8 +165,7 @@ func (s *Server) UeAuthenticationsPost(c *gin.Context) {
s.Processor().HandleUeAuthPostRequest(c, authInfo)
}

// UeAuthenticationsAuthCtxID5gAkaConfirmationPut
func (s *Server) UeAuthenticationsAuthCtxID5gAkaConfirmationPut(c *gin.Context) {
func (s *Server) HTTPUeAuthenticationsAuthCtxId5gAkaConfirmationPut(c *gin.Context) {
var confirmationData models.ConfirmationData

requestBody, err := c.GetRawData()
Expand Down Expand Up @@ -151,3 +197,31 @@ func (s *Server) UeAuthenticationsAuthCtxID5gAkaConfirmationPut(c *gin.Context)

s.Processor().HandleAuth5gAkaComfirmRequest(c, confirmationData, confirmationDataResponseId)
}

func (s *Server) HTTPDelete5gAkaAuthenticationResult(c *gin.Context) {
c.JSON(http.StatusNotImplemented, gin.H{})
}

func (s *Server) HTTPDeleteEapAuthenticationResult(c *gin.Context) {
c.JSON(http.StatusNotImplemented, gin.H{})
}

func (s *Server) HTTPDeleteProSeAuthenticationResult(c *gin.Context) {
c.JSON(http.StatusNotImplemented, gin.H{})
}

func (s *Server) HTTPProseAuth(c *gin.Context) {
c.JSON(http.StatusNotImplemented, gin.H{})
}

func (s *Server) HTTPProseAuthenticationsPost(c *gin.Context) {
c.JSON(http.StatusNotImplemented, gin.H{})
}

func (s *Server) HTTPRgAuthenticationsPost(c *gin.Context) {
c.JSON(http.StatusNotImplemented, gin.H{})
}

func (s *Server) HTTPUeAuthenticationsDeregisterPost(c *gin.Context) {
c.JSON(http.StatusNotImplemented, gin.H{})
}
10 changes: 7 additions & 3 deletions internal/sbi/api_upuprotection.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,22 @@ import (
func (s *Server) getUpuprotectionRoutes() []Route {
return []Route{
{
Name: "Index",
Method: http.MethodGet,
Pattern: "/",
APIFunc: Index,
APIFunc: func(c *gin.Context) {
c.String(http.StatusOK, "Hello free5GC!")
},
},
{
Name: "SupiUeUpuPost",
Method: http.MethodPost,
Pattern: "/:supi/ue-upu",
APIFunc: s.SupiUeUpuPost,
APIFunc: s.HTTPSupiUeUpuPost,
},
}
}

func (s *Server) SupiUeUpuPost(c *gin.Context) {
func (s *Server) HTTPSupiUeUpuPost(c *gin.Context) {
c.JSON(http.StatusNotImplemented, gin.H{})
}
6 changes: 3 additions & 3 deletions internal/sbi/consumer/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ 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"
Nnrf_NFDiscovery "github.com/free5gc/openapi/nrf/NFDiscovery"
Nnrf_NFManagement "github.com/free5gc/openapi/nrf/NFManagement"
Nudm_UEAuthentication "github.com/free5gc/openapi/udm/UEAuthentication"
)

type ConsumerAusf interface {
Expand Down
Loading
Loading