Merge CIP code
This commit is contained in:
committed by
Arthur Barr
parent
4a3bdf3b53
commit
c079c1b60d
@@ -78,10 +78,14 @@ RUN mkdir -p /run/runmqserver \
|
|||||||
COPY --from=builder /opt/app-root/src/go/src/github.com/ibm-messaging/mq-container/runmqserver /usr/local/bin/
|
COPY --from=builder /opt/app-root/src/go/src/github.com/ibm-messaging/mq-container/runmqserver /usr/local/bin/
|
||||||
COPY --from=builder /opt/app-root/src/go/src/github.com/ibm-messaging/mq-container/chkmq* /usr/local/bin/
|
COPY --from=builder /opt/app-root/src/go/src/github.com/ibm-messaging/mq-container/chkmq* /usr/local/bin/
|
||||||
COPY NOTICES.txt /opt/mqm/licenses/notices-container.txt
|
COPY NOTICES.txt /opt/mqm/licenses/notices-container.txt
|
||||||
|
# Copy web XML files
|
||||||
|
COPY web /etc/mqm/web
|
||||||
RUN chmod ug+x /usr/local/bin/runmqserver \
|
RUN chmod ug+x /usr/local/bin/runmqserver \
|
||||||
&& chown mqm:mqm /usr/local/bin/*mq* \
|
&& chown mqm:mqm /usr/local/bin/*mq* \
|
||||||
&& chmod ug+xs /usr/local/bin/chkmq* \
|
&& chmod ug+xs /usr/local/bin/chkmq* \
|
||||||
|
&& chown -R mqm:mqm /etc/mqm/* \
|
||||||
&& install --directory --mode 0775 --owner mqm --group root /run/runmqserver \
|
&& install --directory --mode 0775 --owner mqm --group root /run/runmqserver \
|
||||||
|
&& install --directory --mode 0775 --owner mqm --group root /run/tls \
|
||||||
&& touch /run/termination-log \
|
&& touch /run/termination-log \
|
||||||
&& chown mqm:root /run/termination-log \
|
&& chown mqm:root /run/termination-log \
|
||||||
&& chmod 0660 /run/termination-log
|
&& chmod 0660 /run/termination-log
|
||||||
@@ -133,6 +137,6 @@ COPY incubating/mqadvanced-server-dev/web /etc/mqm/web
|
|||||||
RUN chown -R mqm:mqm /etc/mqm/* \
|
RUN chown -R mqm:mqm /etc/mqm/* \
|
||||||
&& chmod +x /usr/local/bin/runmq* \
|
&& chmod +x /usr/local/bin/runmq* \
|
||||||
&& install --directory --mode 0775 --owner mqm --group root /run/runmqdevserver
|
&& install --directory --mode 0775 --owner mqm --group root /run/runmqdevserver
|
||||||
ENV MQ_BETA_ENABLE_WEB_SERVER=1
|
ENV MQ_ENABLE_EMBEDDED_WEB_SERVER=1
|
||||||
USER $MQM_UID
|
USER $MQM_UID
|
||||||
ENTRYPOINT ["runmqdevserver"]
|
ENTRYPOINT ["runmqdevserver"]
|
||||||
@@ -25,6 +25,7 @@ import (
|
|||||||
"github.com/ibm-messaging/mq-container/internal/command"
|
"github.com/ibm-messaging/mq-container/internal/command"
|
||||||
containerruntimelogger "github.com/ibm-messaging/mq-container/internal/containerruntimelogger"
|
containerruntimelogger "github.com/ibm-messaging/mq-container/internal/containerruntimelogger"
|
||||||
"github.com/ibm-messaging/mq-container/internal/logger"
|
"github.com/ibm-messaging/mq-container/internal/logger"
|
||||||
|
"github.com/ibm-messaging/mq-container/internal/mqtemplate"
|
||||||
"github.com/ibm-messaging/mq-container/internal/name"
|
"github.com/ibm-messaging/mq-container/internal/name"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -91,7 +92,7 @@ func configureLogger() error {
|
|||||||
|
|
||||||
func configureWeb(qmName string) error {
|
func configureWeb(qmName string) error {
|
||||||
out := "/etc/mqm/web/installations/Installation1/angular.persistence/admin.json"
|
out := "/etc/mqm/web/installations/Installation1/angular.persistence/admin.json"
|
||||||
return processTemplateFile("/etc/mqm/admin.json.tpl", out, map[string]string{"QueueManagerName": qmName})
|
return mqtemplate.ProcessTemplateFile("/etc/mqm/admin.json.tpl", out, map[string]string{"QueueManagerName": qmName}, log)
|
||||||
}
|
}
|
||||||
|
|
||||||
func logTerminationf(format string, args ...interface{}) {
|
func logTerminationf(format string, args ...interface{}) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
© Copyright IBM Corporation 2018
|
© Copyright IBM Corporation 2018, 2019
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -17,6 +17,8 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
"github.com/ibm-messaging/mq-container/internal/mqtemplate"
|
||||||
)
|
)
|
||||||
|
|
||||||
func updateMQSC(appPasswordRequired bool) error {
|
func updateMQSC(appPasswordRequired bool) error {
|
||||||
@@ -30,7 +32,7 @@ func updateMQSC(appPasswordRequired bool) error {
|
|||||||
if os.Getenv("MQ_DEV") == "true" {
|
if os.Getenv("MQ_DEV") == "true" {
|
||||||
const mqscTemplate string = mqsc + ".tpl"
|
const mqscTemplate string = mqsc + ".tpl"
|
||||||
// Re-configure channel if app password not set
|
// Re-configure channel if app password not set
|
||||||
err := processTemplateFile(mqsc+".tpl", mqsc, map[string]string{"ChckClnt": checkClient})
|
err := mqtemplate.ProcessTemplateFile(mqsc+".tpl", mqsc, map[string]string{"ChckClnt": checkClient}, log)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
© Copyright IBM Corporation 2018
|
© Copyright IBM Corporation 2018, 2019
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -21,20 +21,22 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/ibm-messaging/mq-container/internal/command"
|
"github.com/ibm-messaging/mq-container/internal/command"
|
||||||
|
"github.com/ibm-messaging/mq-container/internal/keystore"
|
||||||
|
"github.com/ibm-messaging/mq-container/internal/mqtemplate"
|
||||||
)
|
)
|
||||||
|
|
||||||
func configureWebTLS(cms *KeyStore) error {
|
func configureWebTLS(cms *keystore.KeyStore) error {
|
||||||
dir := "/run/runmqdevserver/tls"
|
dir := "/run/runmqdevserver/tls"
|
||||||
ks := NewJKSKeyStore(filepath.Join(dir, "key.jks"), cms.Password)
|
ks := keystore.NewJKSKeyStore(filepath.Join(dir, "key.jks"), cms.Password)
|
||||||
ts := NewJKSKeyStore(filepath.Join(dir, "trust.jks"), cms.Password)
|
ts := keystore.NewJKSKeyStore(filepath.Join(dir, "trust.jks"), cms.Password)
|
||||||
|
|
||||||
log.Debug("Creating key store")
|
log.Debug("Creating key store")
|
||||||
err := ks.Create()
|
err := ks.Create(log)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
log.Debug("Creating trust store")
|
log.Debug("Creating trust store")
|
||||||
err = ts.Create()
|
err = ts.Create(log)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -105,14 +107,14 @@ func configureTLS(qmName string, inputFile string, passPhrase string) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cms := NewCMSKeyStore(keyFile, passPhrase)
|
cms := keystore.NewCMSKeyStore(keyFile, passPhrase)
|
||||||
|
|
||||||
err = cms.Create()
|
err = cms.Create(log)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = cms.CreateStash()
|
err = cms.CreateStash(log)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -146,11 +148,11 @@ func configureTLS(qmName string, inputFile string, passPhrase string) error {
|
|||||||
const mqsc string = "/etc/mqm/20-dev-tls.mqsc"
|
const mqsc string = "/etc/mqm/20-dev-tls.mqsc"
|
||||||
const mqscTemplate string = mqsc + ".tpl"
|
const mqscTemplate string = mqsc + ".tpl"
|
||||||
|
|
||||||
err = processTemplateFile(mqscTemplate, mqsc, map[string]string{
|
err = mqtemplate.ProcessTemplateFile(mqscTemplate, mqsc, map[string]string{
|
||||||
"SSLKeyR": filepath.Join(dir, "key"),
|
"SSLKeyR": filepath.Join(dir, "key"),
|
||||||
"CertificateLabel": newLabel,
|
"CertificateLabel": newLabel,
|
||||||
"SSLCipherSpec": sslCipherSpec,
|
"SSLCipherSpec": sslCipherSpec,
|
||||||
})
|
}, log)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -167,11 +167,20 @@ func logDiagnostics() {
|
|||||||
out, _, _ = command.Run("ls", "-l", "/mnt/mqm/data")
|
out, _, _ = command.Run("ls", "-l", "/mnt/mqm/data")
|
||||||
log.Debugf("/mnt/mqm/data:\n%s", out)
|
log.Debugf("/mnt/mqm/data:\n%s", out)
|
||||||
// #nosec G104
|
// #nosec G104
|
||||||
|
out, _, _ = command.Run("ls", "-l", "/mnt/mqm-log/log")
|
||||||
|
log.Debugf("/mnt/mqm-log/log:\n%s", out)
|
||||||
|
// #nosec G104
|
||||||
|
out, _, _ = command.Run("ls", "-l", "/mnt/mqm-data/qmgrs")
|
||||||
|
log.Debugf("/mnt/mqm-data/qmgrs:\n%s", out)
|
||||||
|
// #nosec G104
|
||||||
out, _, _ = command.Run("ls", "-l", "/var/mqm")
|
out, _, _ = command.Run("ls", "-l", "/var/mqm")
|
||||||
log.Debugf("/var/mqm:\n%s", out)
|
log.Debugf("/var/mqm:\n%s", out)
|
||||||
// #nosec G104
|
// #nosec G104
|
||||||
out, _, _ = command.Run("ls", "-l", "/var/mqm/errors")
|
out, _, _ = command.Run("ls", "-l", "/var/mqm/errors")
|
||||||
log.Debugf("/var/mqm/errors:\n%s", out)
|
log.Debugf("/var/mqm/errors:\n%s", out)
|
||||||
|
// #nosec G104
|
||||||
|
out, _, _ = command.Run("ls", "-l", "/etc/mqm")
|
||||||
|
log.Debugf("/etc/mqm:\n%s", out)
|
||||||
|
|
||||||
// Print out summary of any FDCs
|
// Print out summary of any FDCs
|
||||||
// #nosec G204
|
// #nosec G204
|
||||||
|
|||||||
@@ -21,9 +21,19 @@ import (
|
|||||||
|
|
||||||
// postInit is run after /var/mqm is set up
|
// postInit is run after /var/mqm is set up
|
||||||
func postInit(name string) error {
|
func postInit(name string) error {
|
||||||
web := os.Getenv("MQ_BETA_ENABLE_WEB_SERVER")
|
enableWebServer := os.Getenv("MQ_ENABLE_EMBEDDED_WEB_SERVER")
|
||||||
if web == "true" || web == "1" {
|
if enableWebServer == "true" || enableWebServer == "1" {
|
||||||
// Configure the web server (if installed)
|
|
||||||
|
// Configure Single-Sign-On for the web server (if enabled)
|
||||||
|
enableSSO := os.Getenv("MQ_BETA_ENABLE_SSO")
|
||||||
|
if enableSSO == "true" || enableSSO == "1" {
|
||||||
|
err := configureSSO()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Configure the web server (if enabled)
|
||||||
err := configureWebServer()
|
err := configureWebServer()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -23,9 +23,12 @@ import (
|
|||||||
"os/user"
|
"os/user"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/ibm-messaging/mq-container/internal/command"
|
"github.com/ibm-messaging/mq-container/internal/command"
|
||||||
|
"github.com/ibm-messaging/mq-container/internal/keystore"
|
||||||
|
"github.com/ibm-messaging/mq-container/internal/mqtemplate"
|
||||||
)
|
)
|
||||||
|
|
||||||
func startWebServer() error {
|
func startWebServer() error {
|
||||||
@@ -88,6 +91,103 @@ func CopyFile(src, dest string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func configureSSO() error {
|
||||||
|
|
||||||
|
// Ensure all required environment variables are set for SSO
|
||||||
|
requiredEnvVars := []string{
|
||||||
|
"MQ_WEB_ADMIN_USERS",
|
||||||
|
"MQ_OIDC_CLIENT_ID",
|
||||||
|
"MQ_OIDC_CLIENT_SECRET",
|
||||||
|
"MQ_OIDC_UNIQUE_USER_IDENTIFIER",
|
||||||
|
"MQ_OIDC_AUTHORIZATION_ENDPOINT",
|
||||||
|
"MQ_OIDC_TOKEN_ENDPOINT",
|
||||||
|
"MQ_OIDC_JWK_ENDPOINT",
|
||||||
|
"MQ_OIDC_ISSUER_IDENTIFIER",
|
||||||
|
"MQ_OIDC_CERTIFICATE",
|
||||||
|
}
|
||||||
|
for _, envVar := range requiredEnvVars {
|
||||||
|
if len(os.Getenv(envVar)) == 0 {
|
||||||
|
return fmt.Errorf("%v must be set when MQ_BETA_ENABLE_SSO=true", envVar)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check mqweb directory exists
|
||||||
|
const mqwebDir string = "/etc/mqm/web/installations/Installation1/servers/mqweb"
|
||||||
|
_, err := os.Stat(mqwebDir)
|
||||||
|
if err != nil {
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Process SSO template for generating file mqwebuser.xml
|
||||||
|
adminUsers := strings.Split(os.Getenv("MQ_WEB_ADMIN_USERS"), "\n")
|
||||||
|
err = mqtemplate.ProcessTemplateFile(mqwebDir+"/mqwebuser.xml.tpl", mqwebDir+"/mqwebuser.xml", map[string][]string{"AdminUser": adminUsers}, log)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Configure SSO TLS
|
||||||
|
return configureSSO_TLS()
|
||||||
|
}
|
||||||
|
|
||||||
|
func configureSSO_TLS() error {
|
||||||
|
|
||||||
|
// Create tls directory
|
||||||
|
dir := "/run/tls"
|
||||||
|
mntdir := "/mnt/tls/"
|
||||||
|
_, err := os.Stat(dir)
|
||||||
|
if err != nil {
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
err = os.MkdirAll(dir, 0770)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
mqmUID, mqmGID, err := command.LookupMQM()
|
||||||
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = os.Chown(dir, mqmUID, mqmGID)
|
||||||
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setup key store & trust store
|
||||||
|
ks := keystore.NewJKSKeyStore(filepath.Join(dir, "key.jks"), "password")
|
||||||
|
ts := keystore.NewJKSKeyStore(filepath.Join(dir, "trust.jks"), "password")
|
||||||
|
|
||||||
|
log.Debug("Creating key store")
|
||||||
|
err = ks.Create(log)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
log.Debug("Creating trust store")
|
||||||
|
err = ts.Create(log)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
log.Debug("Generating PKCS12 file")
|
||||||
|
err = ks.GeneratePKCS12(filepath.Join(mntdir, "tls.key"), filepath.Join(mntdir, "tls.crt"), filepath.Join(dir, "tls.p12"), "default", "password")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
log.Debug("Importing certificate into key store")
|
||||||
|
err = ks.Import(filepath.Join(dir, "tls.p12"), "password")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
log.Debug("Adding OIDC certificate to trust store")
|
||||||
|
err = ts.Add(os.Getenv("MQ_OIDC_CERTIFICATE"), "OIDC")
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
func configureWebServer() error {
|
func configureWebServer() error {
|
||||||
_, err := os.Stat("/opt/mqm/bin/strmqweb")
|
_, err := os.Stat("/opt/mqm/bin/strmqweb")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -52,4 +52,4 @@ If you choose to accept the security warning, you will be presented with the log
|
|||||||
|
|
||||||
If you wish to change the password for the admin user, this can be done using the `MQ_ADMIN_PASSWORD` environment variable. If you supply a PKCS#12 keystore using the `MQ_TLS_KEYSTORE` environment variable, then the web console will be configured to use the certificate inside the keystore for HTTPS operations.
|
If you wish to change the password for the admin user, this can be done using the `MQ_ADMIN_PASSWORD` environment variable. If you supply a PKCS#12 keystore using the `MQ_TLS_KEYSTORE` environment variable, then the web console will be configured to use the certificate inside the keystore for HTTPS operations.
|
||||||
|
|
||||||
If you do not wish the web console to run, you can disable it by setting the environment variable `MQ_BETA_ENABLE_WEB_SERVER` to `false`.
|
If you do not wish the web console to run, you can disable it by setting the environment variable `MQ_ENABLE_EMBEDDED_WEB_SERVER` to `false`.
|
||||||
|
|||||||
@@ -59,11 +59,12 @@ if ($UBUNTU); then
|
|||||||
procps \
|
procps \
|
||||||
sed \
|
sed \
|
||||||
tar \
|
tar \
|
||||||
util-linux
|
util-linux \
|
||||||
|
openssl
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ($RPM); then
|
if ($RPM); then
|
||||||
EXTRA_RPMS="bash bc ca-certificates coreutils file findutils gawk glibc-common grep passwd procps-ng sed shadow-utils tar util-linux which"
|
EXTRA_RPMS="bash bc ca-certificates coreutils file findutils gawk glibc-common grep passwd procps-ng sed shadow-utils tar util-linux which openssl"
|
||||||
# Install additional packages required by MQ, this install process and the runtime scripts
|
# Install additional packages required by MQ, this install process and the runtime scripts
|
||||||
$YUM && yum -y install --setopt install_weak_deps=false ${EXTRA_RPMS}
|
$YUM && yum -y install --setopt install_weak_deps=false ${EXTRA_RPMS}
|
||||||
$MICRODNF && microdnf install --nodocs ${EXTRA_RPMS}
|
$MICRODNF && microdnf install --nodocs ${EXTRA_RPMS}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
© Copyright IBM Corporation 2018
|
© Copyright IBM Corporation 2018, 2019
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -13,7 +13,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
package main
|
|
||||||
|
// Package keystore contains code to create and update keystores
|
||||||
|
package keystore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
@@ -23,6 +25,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/ibm-messaging/mq-container/internal/command"
|
"github.com/ibm-messaging/mq-container/internal/command"
|
||||||
|
"github.com/ibm-messaging/mq-container/internal/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
// KeyStore describes information about a keystore file
|
// KeyStore describes information about a keystore file
|
||||||
@@ -54,7 +57,7 @@ func NewCMSKeyStore(filename, password string) *KeyStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create a key store, if it doesn't already exist
|
// Create a key store, if it doesn't already exist
|
||||||
func (ks *KeyStore) Create() error {
|
func (ks *KeyStore) Create(log *logger.Logger) error {
|
||||||
_, err := os.Stat(ks.Filename)
|
_, err := os.Stat(ks.Filename)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
// Keystore already exists so we should refresh it by deleting it.
|
// Keystore already exists so we should refresh it by deleting it.
|
||||||
@@ -111,7 +114,7 @@ func (ks *KeyStore) Create() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CreateStash creates a key stash, if it doesn't already exist
|
// CreateStash creates a key stash, if it doesn't already exist
|
||||||
func (ks *KeyStore) CreateStash() error {
|
func (ks *KeyStore) CreateStash(log *logger.Logger) error {
|
||||||
extension := filepath.Ext(ks.Filename)
|
extension := filepath.Ext(ks.Filename)
|
||||||
stashFile := ks.Filename[0:len(ks.Filename)-len(extension)] + ".sth"
|
stashFile := ks.Filename[0:len(ks.Filename)-len(extension)] + ".sth"
|
||||||
log.Debugf("TLS stash file: %v", stashFile)
|
log.Debugf("TLS stash file: %v", stashFile)
|
||||||
@@ -138,6 +141,15 @@ func (ks *KeyStore) CreateStash() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GeneratePKCS12 generates a PKCS12 file
|
||||||
|
func (ks *KeyStore) GeneratePKCS12(keyFile, crtFile, pkcs12File, label, password string) error {
|
||||||
|
out, _, err := command.Run("openssl", "pkcs12", "-export", "-inkey", keyFile, "-in", crtFile, "-out", pkcs12File, "-name", label, "-passout", "pass:"+password)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("error running \"openssl pkcs12 -export\": %v %s", err, out)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Import imports a certificate file in the keystore
|
// Import imports a certificate file in the keystore
|
||||||
func (ks *KeyStore) Import(inputFile, password string) error {
|
func (ks *KeyStore) Import(inputFile, password string) error {
|
||||||
out, _, err := command.Run(ks.command, "-cert", "-import", "-file", inputFile, "-pw", password, "-target", ks.Filename, "-target_pw", ks.Password, "-target_type", ks.keyStoreType)
|
out, _, err := command.Run(ks.command, "-cert", "-import", "-file", inputFile, "-pw", password, "-target", ks.Filename, "-target_pw", ks.Password, "-target_type", ks.keyStoreType)
|
||||||
@@ -147,6 +159,24 @@ func (ks *KeyStore) Import(inputFile, password string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CreateSelfSignedCertificate creates a self-signed certificate in the keystore
|
||||||
|
func (ks *KeyStore) CreateSelfSignedCertificate(label, dn string) error {
|
||||||
|
out, _, err := command.Run(ks.command, "-cert", "-create", "-db", ks.Filename, "-pw", ks.Password, "-label", label, "-dn", dn)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("error running \"%v -cert -create\": %v %s", ks.command, err, out)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add adds a CA certificate to the keystore
|
||||||
|
func (ks *KeyStore) Add(inputFile, label string) error {
|
||||||
|
out, _, err := command.Run(ks.command, "-cert", "-add", "-db", ks.Filename, "-type", ks.keyStoreType, "-pw", ks.Password, "-file", inputFile, "-label", label)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("error running \"%v -cert -add\": %v %s", ks.command, err, out)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// GetCertificateLabels returns the labels of all certificates in the key store
|
// GetCertificateLabels returns the labels of all certificates in the key store
|
||||||
func (ks *KeyStore) GetCertificateLabels() ([]string, error) {
|
func (ks *KeyStore) GetCertificateLabels() ([]string, error) {
|
||||||
out, _, err := command.Run(ks.command, "-cert", "-list", "-type", ks.keyStoreType, "-db", ks.Filename, "-pw", ks.Password)
|
out, _, err := command.Run(ks.command, "-cert", "-list", "-type", ks.keyStoreType, "-db", ks.Filename, "-pw", ks.Password)
|
||||||
@@ -13,7 +13,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
package main
|
|
||||||
|
// Package mqtemplate contains code to process template files
|
||||||
|
package mqtemplate
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
@@ -21,11 +23,12 @@ import (
|
|||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
"github.com/ibm-messaging/mq-container/internal/command"
|
"github.com/ibm-messaging/mq-container/internal/command"
|
||||||
|
"github.com/ibm-messaging/mq-container/internal/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
// processTemplateFile takes a Go templateFile, and processes it with the
|
// ProcessTemplateFile takes a Go templateFile, and processes it with the
|
||||||
// supplied data, writing to destFile
|
// supplied data, writing to destFile
|
||||||
func processTemplateFile(templateFile, destFile string, data interface{}) error {
|
func ProcessTemplateFile(templateFile, destFile string, data interface{}, log *logger.Logger) error {
|
||||||
// Re-configure channel if app password not set
|
// Re-configure channel if app password not set
|
||||||
t, err := template.ParseFiles(templateFile)
|
t, err := template.ParseFiles(templateFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -86,6 +86,7 @@ buildah run ${ctr_mq} -- microdnf ${microdnf_opts} install \
|
|||||||
shadow-utils \
|
shadow-utils \
|
||||||
tar \
|
tar \
|
||||||
util-linux \
|
util-linux \
|
||||||
|
openssl \
|
||||||
which
|
which
|
||||||
|
|
||||||
# Install "sudo" if using MQ Advanced for Developers
|
# Install "sudo" if using MQ Advanced for Developers
|
||||||
@@ -121,6 +122,13 @@ buildah run --user root $ctr_mq -- chmod 0660 /run/termination-log
|
|||||||
install --mode 0550 --owner root --group root ./mq-advanced-server-rhel/writePackages.sh ${mnt_mq}/usr/local/bin/writePackages
|
install --mode 0550 --owner root --group root ./mq-advanced-server-rhel/writePackages.sh ${mnt_mq}/usr/local/bin/writePackages
|
||||||
buildah run --user root $ctr_mq -- /usr/local/bin/writePackages
|
buildah run --user root $ctr_mq -- /usr/local/bin/writePackages
|
||||||
|
|
||||||
|
# Copy web XML files
|
||||||
|
cp -R web ${mnt_mq}/etc/mqm/web
|
||||||
|
|
||||||
|
# Make "mqm" the owner of all the config files
|
||||||
|
chown --recursive ${mqm_uid}:${mqm_gid} ${mnt_mq}/etc/mqm/*
|
||||||
|
chmod --recursive 0750 ${mnt_mq}/etc/mqm/*
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Final Buildah commands
|
# Final Buildah commands
|
||||||
###############################################################################
|
###############################################################################
|
||||||
@@ -138,6 +146,7 @@ fi
|
|||||||
buildah config \
|
buildah config \
|
||||||
--port 1414/tcp \
|
--port 1414/tcp \
|
||||||
--port 9157/tcp \
|
--port 9157/tcp \
|
||||||
|
--port 9443/tcp \
|
||||||
--os linux \
|
--os linux \
|
||||||
--label architecture=x86_64 \
|
--label architecture=x86_64 \
|
||||||
--label io.openshift.tags="$OSTAG" \
|
--label io.openshift.tags="$OSTAG" \
|
||||||
|
|||||||
@@ -78,8 +78,7 @@ install --directory --mode 0775 --owner ${mqm_uid} --group 0 ${mnt_mq}/run/runmq
|
|||||||
cp ./incubating/mqadvanced-server-dev/*.tpl ${mnt_mq}/etc/mqm/
|
cp ./incubating/mqadvanced-server-dev/*.tpl ${mnt_mq}/etc/mqm/
|
||||||
|
|
||||||
# Copy web XML files for default developer configuration
|
# Copy web XML files for default developer configuration
|
||||||
mkdir --parents ${mnt_mq}/etc/mqm/web
|
cp -R incubating/mqadvanced-server-dev/web/ ${mnt_mq}/etc/mqm/web
|
||||||
cp --recursive ./incubating/mqadvanced-server-dev/web/* ${mnt_mq}/etc/mqm/web/
|
|
||||||
|
|
||||||
# Make "mqm" the owner of all the config files
|
# Make "mqm" the owner of all the config files
|
||||||
chown --recursive ${mqm_uid}:${mqm_gid} ${mnt_mq}/etc/mqm/*
|
chown --recursive ${mqm_uid}:${mqm_gid} ${mnt_mq}/etc/mqm/*
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ func TestDevWebDisabled(t *testing.T) {
|
|||||||
Env: []string{
|
Env: []string{
|
||||||
"LICENSE=accept",
|
"LICENSE=accept",
|
||||||
"MQ_QMGR_NAME=qm1",
|
"MQ_QMGR_NAME=qm1",
|
||||||
"MQ_BETA_ENABLE_WEB_SERVER=false",
|
"MQ_ENABLE_EMBEDDED_WEB_SERVER=false",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
id := runContainer(t, cli, &containerConfig)
|
id := runContainer(t, cli, &containerConfig)
|
||||||
|
|||||||
25
web/installations/Installation1/servers/mqweb/mqwebuser.xml
Normal file
25
web/installations/Installation1/servers/mqweb/mqwebuser.xml
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<server>
|
||||||
|
<featureManager>
|
||||||
|
<feature>appSecurity-2.0</feature>
|
||||||
|
</featureManager>
|
||||||
|
<enterpriseApplication id="com.ibm.mq.console">
|
||||||
|
<application-bnd>
|
||||||
|
<security-role name="MQWebAdmin">
|
||||||
|
<group name="MQWebUI" realm="defaultRealm"/>
|
||||||
|
</security-role>
|
||||||
|
</application-bnd>
|
||||||
|
</enterpriseApplication>
|
||||||
|
<enterpriseApplication id="com.ibm.mq.rest">
|
||||||
|
<application-bnd>
|
||||||
|
<security-role name="MQWebAdmin">
|
||||||
|
<group name="MQWebUI" realm="defaultRealm"/>
|
||||||
|
</security-role>
|
||||||
|
<security-role name="MQWebUser">
|
||||||
|
<group name="MQWebMessaging" realm="defaultRealm"/>
|
||||||
|
</security-role>
|
||||||
|
</application-bnd>
|
||||||
|
</enterpriseApplication>
|
||||||
|
<variable name="httpHost" value="*"/>
|
||||||
|
<include location="tls.xml"/>
|
||||||
|
</server>
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<server>
|
||||||
|
<featureManager>
|
||||||
|
<feature>openidConnectClient-1.0</feature>
|
||||||
|
<feature>ssl-1.0</feature>
|
||||||
|
</featureManager>
|
||||||
|
<enterpriseApplication id="com.ibm.mq.console">
|
||||||
|
<application-bnd>
|
||||||
|
<security-role name="MQWebAdmin">
|
||||||
|
<group name="MQWebUI" realm="defaultRealm"/>
|
||||||
|
{{- range $index, $element := .AdminUser}}
|
||||||
|
<user name="admin{{$index}}" access-id="{{.}}"/>
|
||||||
|
{{- end}}
|
||||||
|
</security-role>
|
||||||
|
</application-bnd>
|
||||||
|
</enterpriseApplication>
|
||||||
|
<enterpriseApplication id="com.ibm.mq.rest">
|
||||||
|
<application-bnd>
|
||||||
|
<security-role name="MQWebAdmin">
|
||||||
|
<group name="MQWebUI" realm="defaultRealm"/>
|
||||||
|
</security-role>
|
||||||
|
<security-role name="MQWebUser">
|
||||||
|
<group name="MQWebMessaging" realm="defaultRealm"/>
|
||||||
|
</security-role>
|
||||||
|
</application-bnd>
|
||||||
|
</enterpriseApplication>
|
||||||
|
<openidConnectClient id="mqclient"
|
||||||
|
clientId="${env.MQ_OIDC_CLIENT_ID}"
|
||||||
|
clientSecret="${env.MQ_OIDC_CLIENT_SECRET}"
|
||||||
|
uniqueUserIdentifier="${env.MQ_OIDC_UNIQUE_USER_IDENTIFIER}"
|
||||||
|
authorizationEndpointUrl="${env.MQ_OIDC_AUTHORIZATION_ENDPOINT}"
|
||||||
|
tokenEndpointUrl="${env.MQ_OIDC_TOKEN_ENDPOINT}"
|
||||||
|
scope="openid profile email"
|
||||||
|
inboundPropagation="supported"
|
||||||
|
jwkEndpointUrl="${env.MQ_OIDC_JWK_ENDPOINT}"
|
||||||
|
signatureAlgorithm="RS256"
|
||||||
|
issuerIdentifier="${env.MQ_OIDC_ISSUER_IDENTIFIER}">
|
||||||
|
</openidConnectClient>
|
||||||
|
<variable name="httpHost" value="*"/>
|
||||||
|
<variable name="managementMode" value="externallyprovisioned"/>
|
||||||
|
<jndiEntry jndiName="xframeAllowedSourceList" value="${env.MQ_HOSTS}"/>
|
||||||
|
<keyStore id="MQWebKeyStore" location="/run/tls/key.jks" type="JKS" password="password"/>
|
||||||
|
<keyStore id="MQWebTrustStore" location="/run/tls/trust.jks" type="JKS" password="password"/>
|
||||||
|
<ssl id="thisSSLConfig" clientAuthenticationSupported="true" keyStoreRef="MQWebKeyStore" trustStoreRef="MQWebTrustStore" sslProtocol="TLSv1.2" serverKeyAlias="default"/>
|
||||||
|
<sslDefault sslRef="thisSSLConfig"/>
|
||||||
|
<httpDispatcher enableWelcomePage="false" appOrContextRootMissingMessage='<script>document.location.href="/ibmmq/console";</script>' />
|
||||||
|
</server>
|
||||||
Reference in New Issue
Block a user