Skip to content

Commit

Permalink
Remove profiles endpoint and textures signing mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
erickskrauch committed Jun 11, 2024
1 parent 62b6ac8 commit 716ec8b
Show file tree
Hide file tree
Showing 11 changed files with 1 addition and 823 deletions.
65 changes: 0 additions & 65 deletions docs/swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -165,68 +165,3 @@ paths:
description: The profiles has been successfully deleted.
401:
$ref: "#/components/responses/UnauthorizedError"

/api/signer:
post:
operationId: signData
summary: Signs the sent data.
tags:
- signer
- api
security:
- BearerAuth: [ sign ]
requestBody:
content:
"*":
schema:
description: Accepts data in any format and generates a signature for it.
type: string
responses:
200:
description: Successfully signed data.
content:
application/octet-stream+base64:
schema:
description: A base64 encoded signature for the passed data.
type: string
401:
$ref: "#/components/responses/UnauthorizedError"

/api/signer/public-key.pem:
get:
operationId: signerPublicKeyPem
summary: Get signer's public key in PEM format.
tags:
- signer
- api
security:
- BearerAuth: [ sign ]
responses:
200:
description: The public file in PEM format.
content:
application/x-pem-file:
schema:
type: string
401:
$ref: "#/components/responses/UnauthorizedError"

/api/signer/public-key.der:
get:
operationId: signerPublicKeyPem
summary: Get signer's public key in DER format.
tags:
- signer
- api
security:
- BearerAuth: [ sign ]
responses:
200:
description: The public file in PEM format.
content:
application/octet-stream:
schema:
type: string
format: binary
401:
$ref: "#/components/responses/UnauthorizedError"
34 changes: 0 additions & 34 deletions internal/client/signer/local.go

This file was deleted.

104 changes: 0 additions & 104 deletions internal/client/signer/local_test.go

This file was deleted.

2 changes: 1 addition & 1 deletion internal/cmd/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var serveCmd = &cobra.Command{
Use: "serve",
Short: "Starts HTTP handler for the skins system",
RunE: func(cmd *cobra.Command, args []string) error {
return startServer(di.ModuleSkinsystem, di.ModuleProfiles, di.ModuleSigner)
return startServer(di.ModuleSkinsystem, di.ModuleProfiles)
},
}

Expand Down
1 change: 0 additions & 1 deletion internal/di/di.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ func New() (*di.Container, error) {
loggerDiOptions,
mojangDiOptions,
profilesDiOptions,
securityDiOptions,
serverDiOptions,
)
}
33 changes: 0 additions & 33 deletions internal/di/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@ import (

const ModuleSkinsystem = "skinsystem"
const ModuleProfiles = "profiles"
const ModuleSigner = "signer"

var handlersDiOptions = di.Options(
di.Provide(newHandlerFactory, di.As(new(http.Handler))),
di.Provide(newSkinsystemHandler, di.WithName(ModuleSkinsystem)),
di.Provide(newProfilesApiHandler, di.WithName(ModuleProfiles)),
di.Provide(newSignerApiHandler, di.WithName(ModuleSigner)),
)

func newHandlerFactory(
Expand Down Expand Up @@ -65,26 +63,6 @@ func newHandlerFactory(
mount(router, "/api/profiles", profilesApiRouter)
}

if slices.Contains(enabledModules, ModuleSigner) {
var signerApiRouter *mux.Router
if err := container.Resolve(&signerApiRouter, di.Name(ModuleSigner)); err != nil {
return nil, err
}

var authenticator Authenticator
if err := container.Resolve(&authenticator); err != nil {
return nil, err
}

authMiddleware := NewAuthenticationMiddleware(authenticator, security.SignScope)
conditionalAuth := NewConditionalMiddleware(func(req *http.Request) bool {
return req.Method != "GET"
}, authMiddleware)
signerApiRouter.Use(conditionalAuth)

mount(router, "/api/signer", signerApiRouter)
}

// Resolve health checkers last, because all the services required by the application
// must first be initialized and each of them can publish its own checkers
var healthCheckers []*namedHealthChecker
Expand All @@ -107,14 +85,12 @@ func newHandlerFactory(
func newSkinsystemHandler(
config *viper.Viper,
profilesProvider ProfilesProvider,
texturesSigner SignerService,
) (*mux.Router, error) {
config.SetDefault("textures.extra_param_name", "chrly")
config.SetDefault("textures.extra_param_value", "how do you tame a horse in Minecraft?")

skinsystem, err := NewSkinsystemApi(
profilesProvider,
texturesSigner,
config.GetString("textures.extra_param_name"),
config.GetString("textures.extra_param_value"),
)
Expand All @@ -134,15 +110,6 @@ func newProfilesApiHandler(profilesManager ProfilesManager) (*mux.Router, error)
return profilesApi.Handler(), nil
}

func newSignerApiHandler(signer Signer) (*mux.Router, error) {
signerApi, err := NewSignerApi(signer)
if err != nil {
return nil, err
}

return signerApi.Handler(), nil
}

func mount(router *mux.Router, path string, handler http.Handler) {
router.PathPrefix(path).Handler(
http.StripPrefix(
Expand Down
59 changes: 0 additions & 59 deletions internal/di/security.go

This file was deleted.

Loading

0 comments on commit 716ec8b

Please sign in to comment.