mirror of
https://github.com/unmojang/drasl.git
synced 2025-09-08 06:35:12 -04:00
optionally sign public keys
This commit is contained in:
parent
7f50a977ed
commit
5318882aef
4
auth.go
4
auth.go
@ -27,8 +27,10 @@ func AuthGetServerInfo(app *App) func(c echo.Context) error {
|
|||||||
infoMap["SpecificationVersion"] = "2.13.34"
|
infoMap["SpecificationVersion"] = "2.13.34"
|
||||||
infoMap["ImplementationVersion"] = "0.1.0"
|
infoMap["ImplementationVersion"] = "0.1.0"
|
||||||
infoMap["ApplicationOwner"] = "TODO"
|
infoMap["ApplicationOwner"] = "TODO"
|
||||||
// TODO multiple public keys
|
|
||||||
|
if app.Config.SignPublicKeys {
|
||||||
infoMap["PublicKey"] = base64.StdEncoding.EncodeToString(publicKeyDer)
|
infoMap["PublicKey"] = base64.StdEncoding.EncodeToString(publicKeyDer)
|
||||||
|
}
|
||||||
|
|
||||||
infoBlob, err := json.Marshal(infoMap)
|
infoBlob, err := json.Marshal(infoMap)
|
||||||
|
|
||||||
|
@ -65,6 +65,7 @@ type Config struct {
|
|||||||
InstanceName string
|
InstanceName string
|
||||||
DataDirectory string
|
DataDirectory string
|
||||||
ApplicationOwner string
|
ApplicationOwner string
|
||||||
|
SignPublicKeys bool
|
||||||
LogRequests bool
|
LogRequests bool
|
||||||
HideListenAddress bool
|
HideListenAddress bool
|
||||||
DefaultPreferredLanguage string
|
DefaultPreferredLanguage string
|
||||||
@ -87,6 +88,7 @@ func DefaultConfig() Config {
|
|||||||
DataDirectory: "/var/lib/drasl",
|
DataDirectory: "/var/lib/drasl",
|
||||||
ApplicationOwner: "Unmojang",
|
ApplicationOwner: "Unmojang",
|
||||||
LogRequests: true,
|
LogRequests: true,
|
||||||
|
SignPublicKeys: false,
|
||||||
DefaultPreferredLanguage: "en",
|
DefaultPreferredLanguage: "en",
|
||||||
AllowHighResolutionSkins: false,
|
AllowHighResolutionSkins: false,
|
||||||
HideListenAddress: false,
|
HideListenAddress: false,
|
||||||
|
4
front.go
4
front.go
@ -29,8 +29,8 @@ Web front end for creating user accounts, changing passwords, skins, player name
|
|||||||
// Must be in a region of the skin that supports translucency
|
// Must be in a region of the skin that supports translucency
|
||||||
const SKIN_WINDOW_X_MIN = 40
|
const SKIN_WINDOW_X_MIN = 40
|
||||||
const SKIN_WINDOW_X_MAX = 48
|
const SKIN_WINDOW_X_MAX = 48
|
||||||
const SKIN_WINDOW_Y_MIN = 8
|
const SKIN_WINDOW_Y_MIN = 9
|
||||||
const SKIN_WINDOW_Y_MAX = 10
|
const SKIN_WINDOW_Y_MAX = 11
|
||||||
|
|
||||||
// https://echo.labstack.com/guide/templates/
|
// https://echo.labstack.com/guide/templates/
|
||||||
// https://stackoverflow.com/questions/36617949/how-to-use-base-template-file-for-golang-html-template/69244593#69244593
|
// https://stackoverflow.com/questions/36617949/how-to-use-base-template-file-for-golang-html-template/69244593#69244593
|
||||||
|
11
services.go
11
services.go
@ -260,6 +260,10 @@ func ServicesPlayerCertificates(app *App) func(c echo.Context) error {
|
|||||||
}
|
}
|
||||||
expiresAtMilli := expiresAtTime.UnixMilli()
|
expiresAtMilli := expiresAtTime.UnixMilli()
|
||||||
|
|
||||||
|
publicKeySignatureText := ""
|
||||||
|
publicKeySignatureV2Text := ""
|
||||||
|
|
||||||
|
if app.Config.SignPublicKeys {
|
||||||
// publicKeySignature, used in 1.19
|
// publicKeySignature, used in 1.19
|
||||||
// We don't just sign the public key itself---the signed data consists
|
// We don't just sign the public key itself---the signed data consists
|
||||||
// of expiresAt timestamp as a string, concatenated with the PEM(ish)
|
// of expiresAt timestamp as a string, concatenated with the PEM(ish)
|
||||||
@ -289,6 +293,7 @@ func ServicesPlayerCertificates(app *App) func(c echo.Context) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
publicKeySignatureText = base64.StdEncoding.EncodeToString(publicKeySignature)
|
||||||
|
|
||||||
// publicKeySignatureV2, used in 1.19.1+
|
// publicKeySignatureV2, used in 1.19.1+
|
||||||
// Again, we don't just sign the public key, we need to
|
// Again, we don't just sign the public key, we need to
|
||||||
@ -324,14 +329,16 @@ func ServicesPlayerCertificates(app *App) func(c echo.Context) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
publicKeySignatureV2Text = base64.StdEncoding.EncodeToString(publicKeySignatureV2)
|
||||||
|
}
|
||||||
|
|
||||||
res := playerCertificatesResponse{
|
res := playerCertificatesResponse{
|
||||||
KeyPair: keyPair{
|
KeyPair: keyPair{
|
||||||
PrivateKey: string(keyPEM[:]),
|
PrivateKey: string(keyPEM[:]),
|
||||||
PublicKey: string(pubPEM[:]),
|
PublicKey: string(pubPEM[:]),
|
||||||
},
|
},
|
||||||
PublicKeySignature: base64.StdEncoding.EncodeToString(publicKeySignature),
|
PublicKeySignature: publicKeySignatureText,
|
||||||
PublicKeySignatureV2: base64.StdEncoding.EncodeToString(publicKeySignatureV2),
|
PublicKeySignatureV2: publicKeySignatureV2Text,
|
||||||
ExpiresAt: expiresAt,
|
ExpiresAt: expiresAt,
|
||||||
RefreshedAfter: "2022-12-30T00:11:32.174783069Z",
|
RefreshedAfter: "2022-12-30T00:11:32.174783069Z",
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user