<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    paulwong

    #

    12 Factor App Principles and Cloud-Native Microservices



    https://dzone.com/articles/12-factor-app-principles-and-cloud-native-microser

    posted @ 2022-05-18 15:59 paulwong 閱讀(120) | 評論 (0)編輯 收藏

    API接口中的敏感數據的加密與解密

         摘要: 簽名 為防止request中的json在傳輸過程中被更改, 需要在傳送雙方保存一個字符串sinature-key 用SHA256 hash請求中的json字符串,結果為hash1 {"payload":hash1}以此為字符和sinature-key用JWS HS256算法進行簽名,得到sinature1 在請求的json中加入字段:"sina...  閱讀全文

    posted @ 2022-05-11 14:37 paulwong 閱讀(970) | 評論 (0)編輯 收藏

    KEYCLOAK授權模式與實施


    https://stackoverflow.com/questions/42186537/resources-scopes-permissions-and-policies-in-keycloak

    posted @ 2022-04-21 15:32 paulwong 閱讀(160) | 評論 (0)編輯 收藏

    KEYCLOA+DMariaDB 在LINUX上的安裝

    下載KEYCLOAK與安裝,可參見:
    https://www.janua.fr/how-to-install-keycloak-with-mariadb/

    啟動時配置不通過localhost訪問控制臺:
    #! /bin/bash

    BIN_PATH=$(cd `dirname $0`; pwd)
    IP=10.10.27.69
    KEYCLOAK_OPT="-b ${IP} -Djboss.bind.address.management=${IP} -Dkeycloak.profile.feature.upload_scripts=enabled"
    KEYCLOAK_OPT="${KEYCLOAK_OPT} -Djboss.socket.binding.port-offset=100 -Dkeycloak.frontendUrl=http://${IP}:81/auth "
    #-Dkeycloak.hostname=${IP} -Dkeycloak.httpPort=81 -Dkeycloak.httpsPort=82

    nohup ${BIN_PATH}/bin/standalone.sh ${KEYCLOAK_OPT} > /dev/null &

    更改KEYCLOAK的DATASOURCE時,可直接更改默認的而無需重新配置:
    https://medium.com/@pratik.dandavate/setting-up-keycloak-standalone-with-mysql-database-7ebb614cc229

    KEYCLOAK的JBOSS管理界面地址改為非LOCALHOST:
    -Djboss.bind.address.management=${IP}

    如果是由NGINX過來的訪問,這樣前端的地址是和默認的不一樣,需配置前端URL:
    -Dkeycloak.frontendUrl=http://${IP}:81/auth

    更改JVM大小standalone.conf:
    #
    # Specify options to pass to the Java VM.
    #

    JBOSS_JAVA_SIZING="-server -Xms3G -Xmx3G -Xmn512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m"

    REFERENCE:
    https://www.keycloak.org/docs/latest/server_installation/index.html#_hostname

    posted @ 2022-04-14 15:15 paulwong 閱讀(231) | 評論 (0)編輯 收藏

    UML DIAGRAM資源

    https://www.uml-diagrams.org/uml-25-diagrams.html


    https://www.uml-diagrams.org/index-examples.html

    posted @ 2022-02-19 16:55 paulwong 閱讀(121) | 評論 (0)編輯 收藏

    JENKINS 部署 agularjs

    This article assumes that you have a running Jenkins instance on your Linux machine with a valid domain (not localhost), GitLab and that you are familiar with the Angular framework.

    For Jenkins, please install the GitLab and NodeJS plugins. For simplicity’s sake, this article is going to use simple shell commands to run automated tests and to deploy an app to production.

    ***Note. If you can’t decide where to test all this, there is an article I wrote that might help you: CI/CD Cloud Voyage with Jenkins.

    Configuring Gitlab and Jenkins

    Jenkins: Access Rights to GitLab

    In order to use GitLab with Jenkins, you’ll need to generate an access token in GitLab, which you can do in User menu > Settings > Access tokens

    and configure GitLab Connection on Jenkins by adding the newly generated token.

    In Jenkins, go to Manage Jenkins > Configure system and find the GitLab section.

    To add a token that you previously generated, click on Add by the Credentials input and choose Jenkins. In the credentials dialog, choose GitLab API token in the Kind input and paste your token from GitLab into the API token input field. 

    Jenkins: Configure NodeJSInstaller

    In order to be able to run npm scripts, it is necessary to configure NodeJSInstaller. In Jenkins, go to Manage Jenkins > Global Tool Configuration > NodeJS installations.

    Jenkins: Create CI build for Angular

    In order to be able to run Angular tests and check your code style in Jenkins on the created merge request in GitLab you’ll have to:

    1. Click on the New item link in the Jenkins dashboard

    2. Enter a job name and choose Freestyle project

    3. Choose the GitLab Connection that we’ve just created in the Gitlab Connection section.

    4. Choose Git as your source code management. Enter your repository URL. Create new credentials on Jenkins. These credentials are for cloning the project. You use them to log in to Gitlab.

    5. Next, configure build triggers, i.e. on which GitLab event to run a build. In this particular example, angular-ci-build is going to trigger when a new merge request gets created.

    In this step, we need to go back to GitLab and create a hook that will trigger this build under Settings > Integrations. Copy the URL provided by Jenkins and paste it into the project hook form and finally click Add webhook.

    6. Provide the configured NodeJsInstaller in the global configuration to be able to run npm commands.

    7. And finally, in the Build section choose Add build step > Execute shell. Write shell scripts to test the Angular app code and run tests.

    Click Save and we are good to go. At this point everything should work.

    When you create a new merge request, GitLab should trigger angular-ci-build on Jenkins and you should see status pending on that particular merge request page.

    When Jenkins is done, the status on GitLab should automatically be updated. Depending on whether the build passed or not, the merge button will change color.

    Jenkins: Create CD Build for Angular

    In order to be able to deploy Angular to another Linux machine, we need to:

    Repeat steps 1–4 from Jenkins: Create CI Build for Angular, changing only the name of the build. This time, it can be angular-deploy. 

    5. For step five, we now choose a different configuration for deployment. We are going to run this build when a merge request gets accepted.

    Just like for the CI build, we have to create a new GitLab hook that will hit the Jenkins build endpoint.

    6. This step is also the same as in CI; we need to provide the NodeJSInstaller we already configured globally.

    7. This step is different from CI; this time we don’t have to test and check linting, but only build the application and copy-paste it to another machine with ssh.

    If we are going to do it with ssh like in the example, we need to create a private and public key pair for the Jenkins user on the machine Jenkins is running on. The private key needs to stay on the Jenkins machine, and the public key needs to be copied to the remote machine.

    With the scp command we simply copy our build to the remote machine. In this case, Jenkins does not have permission to put it anywhere but in the user folder. In the last step, we need to ssh into the remote machine and move our files (in this case to /var/www/html).

    Voila, our app is deployed to the production server when the merge request is accepted via Jenkins.

    Angular: Karma Unit Test Runner Configuration

    To run Angular tests on Jenkins, we need to configure some parts of the karma.conf file. Below is the configuration that adds a custom launcher that runs ChromeHeadles.

    module.exports = function(config) {   config.set({     basePath: "",     frameworks: ["jasmine", "@angular-devkit/build-angular"],     plugins: [       require("karma-jasmine"),       require("karma-chrome-launcher"),       require("karma-jasmine-html-reporter"),       require("karma-coverage-istanbul-reporter"),       require("@angular-devkit/build-angular/plugins/karma")     ],     client: {       clearContext: false // leave Jasmine Spec Runner output visible in browser     },     coverageIstanbulReporter: {       dir: require("path").join(__dirname, "../coverage/jenkins-test-app"),       reports: ["html", "lcovonly", "text-summary"],       fixWebpackSourcePaths: true     },     reporters: ["progress", "kjhtml"],     port: 9876,     colors: true,     logLevel: config.LOG_INFO,     autoWatch: true,     browsers: ["Chrome", "ChromeHeadless"],     singleRun: false,     restartOnFileChange: true,     customLaunchers: {       ChromeHeadless: {         base: "Chrome",         flags: [           "--headless",           "--disable-gpu",           "--no-sandbox",           "--remote-debugging-port=9222"         ],                },     }   }); };

    We can then simply store our command in the package.json scripts property.

    On Jenkins, we would now run our tests with npm run test:ci.

     "scripts": {     "ng": "ng",     "start": "ng serve",     "build": "ng build",     "test": "ng test",     "test:ci": "ng test --browsers=ChromeHeadless --watch=false",     "lint": "ng lint",     "e2e": "ng e2e"   },

    I hope you enjoyed this article and that it was helpful in your quest for automating angular deployment and testing.

    posted @ 2022-01-25 11:02 paulwong 閱讀(141) | 評論 (0)編輯 收藏

    SPRING INTEGRATION - 集群選主、分布式鎖

    集群通常是有多個相同的實例,但對于定時任務場景,只希望有一個實例工作即可,如果這個實例掛了,其他實例可以頂替。

    這個問題的方案則是集群選主,一個集群中,只有一個LEADER,由LEADER負責執行定時任務工作。當LEADER被取消時,會在剩下的實例中再選LEADER。

    持有分布式鎖的實例則是LEADER。

    SPRING INTEGRATION JDBC 則已提供相關功能。

    pom.xml
            <dependency>
               <groupId>org.springframework.integration</groupId>
               <artifactId>spring-integration-jdbc</artifactId>
            </dependency>

            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-jdbc</artifactId>
            </dependency>

            <dependency>
               <groupId>org.flywaydb</groupId>
               <artifactId>flyway-core</artifactId>
            </dependency>
            
            <dependency>
                <groupId>org.mariadb.jdbc</groupId>
                <artifactId>mariadb-java-client</artifactId>
            </dependency>

    LeaderElectionIntegrationConfig.java
    import java.util.List;
    import java.util.concurrent.CopyOnWriteArrayList;

    import javax.sql.DataSource;

    import org.springframework.context.annotation.Bean;
    import org.springframework.context.annotation.Configuration;
    import org.springframework.integration.jdbc.lock.DefaultLockRepository;
    import org.springframework.integration.jdbc.lock.JdbcLockRegistry;
    import org.springframework.integration.jdbc.lock.LockRepository;
    import org.springframework.integration.support.leader.LockRegistryLeaderInitiator;

    import com.paul.integration.leader.ControlBusGateway;
    import com.paul.integration.leader.MyCandidate;

    @Configuration
    public class LeaderElectionIntegrationConfig {
        
        @Bean
        public List<String> needToStartupAdapterList(){
            return new CopyOnWriteArrayList<>();
        }
        
        @Bean
        public DefaultLockRepository defaultLockRepository(DataSource dataSource){
            DefaultLockRepository defaultLockRepository =
                    new DefaultLockRepository(dataSource);
    //        defaultLockRepository.setTimeToLive(60_000);
            return defaultLockRepository;
        }

        @Bean
        public JdbcLockRegistry jdbcLockRegistry(LockRepository lockRepository){
            return new JdbcLockRegistry(lockRepository);
        }
        
        @Bean
        public MyCandidate myCandidate(
            ControlBusGateway controlBusGateway,
            List<String> needToStartupAdapterList
        ) {
            return new MyCandidate(controlBusGateway, needToStartupAdapterList);
        }
        
        @Bean
        public LockRegistryLeaderInitiator leaderInitiator() {
            return new LockRegistryLeaderInitiator(
                        jdbcLockRegistry(null), myCandidate(nullnull)
                   );
        }
        
        
    }


    MyCandidate.java
    import java.util.List;

    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
    import org.springframework.integration.leader.Context;
    import org.springframework.integration.leader.DefaultCandidate;

    import com.novacredit.mcra.mcracommon.integration.gateway.ControlBusGateway;

    public class MyCandidate extends DefaultCandidate{
        
        private static final Logger LOG = LoggerFactory.getLogger(MyCandidate.class);
        
        private List<String> needToStartupAdapterList;
        
        private ControlBusGateway controlBusGateway;
        
        public MyCandidate(
            ControlBusGateway controlBusGateway,
            List<String> needToStartupAdapterList
        ) {
            this.controlBusGateway = controlBusGateway;
            this.needToStartupAdapterList = needToStartupAdapterList;
        }
        
        @Override
        public void onGranted(Context context) {
            super.onGranted(context);
            LOG.info("*** Leadership granted ***");
            LOG.info("STARTING MONGODB POLLER");
            needToStartupAdapterList
                .forEach(
                    c -> {
    //                    c = "@'testIntegrationFlow.org.springframework.integration.config."
    //                            + "SourcePollingChannelAdapterFactoryBean#0'";
                        String command = c + ".start()";
                        LOG.info("-----{}", command);
                        controlBusGateway.sendCommand(command);
                    }
                 );
            LOG.info("STARTUP MESSAGE SENT");

        }

        @Override
        public void onRevoked(Context context) {
            super.onRevoked(context);
            LOG.info("*** Leadership revoked ***");
            LOG.info("STOPPING MONGODB POLLER");
            needToStartupAdapterList
                .forEach(
                    c -> {
    //                    c = "@'testIntegrationConfig.testIntegrationFlow."
    //                            + "mongoMessageSource.inboundChannelAdapter'";
                        String command = c + ".stop()";
                        LOG.info("-----{}", command);
    //                    controlBusGateway.sendCommand(command);
                    }
                 );
            LOG.info("SHUTDOWN MESSAGE SENT");
        }

    }


    ControlBusIntegrationConfig.java
    import org.springframework.context.annotation.Bean;
    import org.springframework.context.annotation.Configuration;
    import org.springframework.integration.dsl.IntegrationFlow;
    import org.springframework.integration.dsl.IntegrationFlows;
    import org.springframework.integration.dsl.MessageChannels;
    import org.springframework.integration.gateway.GatewayProxyFactoryBean;
    import org.springframework.integration.handler.LoggingHandler;
    import org.springframework.messaging.MessageChannel;

    import com.paul.integration.gateway.ControlBusGateway;

    @Configuration
    public class ControlBusIntegrationConfig {
        
        @Bean
        public MessageChannel controlBusChannel() {
            return MessageChannels.direct().get();
        }
        
        @Bean
        public IntegrationFlow controlBusFlow() {
            return IntegrationFlows.from(controlBusChannel())
                        .log(LoggingHandler.Level.INFO, "controlBusChannel")
                        .controlBus()
                        .get();
        }
        
        @Bean
        public GatewayProxyFactoryBean controlBusGateway() {
            GatewayProxyFactoryBean gateway = new GatewayProxyFactoryBean(ControlBusGateway.class);
            gateway.setDefaultRequestChannel(controlBusChannel());
            gateway.setDefaultRequestTimeout(300l);
            gateway.setDefaultReplyTimeout(300l);
            return gateway;
        }
        
    }


    ControlBusGateway.java
    public interface ControlBusGateway {
        
        public void sendCommand(String command);

    }


    各個應用實例運行時,其中的LockRegistryLeaderInitiator會自動運行,搶奪LEADER數據,最終只有一個實例奪取。之后再執行MyCandidate中的代碼。







    posted @ 2022-01-20 13:49 paulwong 閱讀(547) | 評論 (0)編輯 收藏

    MONGODB SHELL

    mongo -u admin -p 123456 --authenticationDatabase admin
    use admin
    db.createUser({
     user : "paul",
     pwd : "123456",
     roles : [{role : "readWrite", db : "batch"}]
    })

    #增加權限
    db.grantRolesToUser( 
      "paul"
      [
        { "role" : "dbOwner",
          "db" : "mcra"
        }
      ]
    )

    posted @ 2022-01-10 11:10 paulwong 閱讀(223) | 評論 (0)編輯 收藏

    OAUTH2 - 4流程如何選擇?





    https://developer.okta.com/docs/concepts/oauth-openid/#what-kind-of-client-are-you-building

    posted @ 2022-01-06 13:37 paulwong 閱讀(141) | 評論 (0)編輯 收藏

    幾個好看的免費UI

    https://demos.creative-tim.com/light-bootstrap-dashboard-angular2/#/dashboard


    https://www.creative-tim.com/product/light-bootstrap-dashboard-angular2

    https://www.creative-tim.com/templates/angular-dashboard-bootstrap

    https://coreui.io/angular/demo/free/2.11.1/#/base/tables

    posted @ 2022-01-04 15:36 paulwong 閱讀(184) | 評論 (0)編輯 收藏

    僅列出標題
    共115頁: First 上一頁 3 4 5 6 7 8 9 10 11 下一頁 Last 
    主站蜘蛛池模板: 亚洲综合成人婷婷五月网址| 亚洲人成中文字幕在线观看| 亚洲综合久久1区2区3区| 久青草视频在线观看免费| 亚洲精品无码永久在线观看| 日韩免费码中文在线观看| 亚洲av无码国产精品色在线看不卡 | 久久精品国产亚洲Aⅴ蜜臀色欲| 成a人片亚洲日本久久| 大陆一级毛片免费视频观看| 久久国产亚洲精品| 大学生一级特黄的免费大片视频| 亚洲人成无码网站在线观看| 日本久久久免费高清| 无人视频在线观看免费播放影院| vvvv99日韩精品亚洲| a级黄色毛片免费播放视频| 久久精品亚洲综合| 无遮免费网站在线入口| 亚洲综合一区国产精品| 免费乱码中文字幕网站| 国产性生大片免费观看性| 亚洲精品午夜在线观看| 在线免费观看一级毛片| 特级无码毛片免费视频| 亚洲高清专区日韩精品| 国产免费毛不卡片| 日亚毛片免费乱码不卡一区| 亚洲无线码一区二区三区| 久久永久免费人妻精品| 久久精品国产亚洲AV忘忧草18| 日本xxwwxxww在线视频免费| 久久久久久久久久免免费精品| 亚洲一区二区在线免费观看| 四虎成人免费网站在线| 一区二区三区免费视频网站| 亚洲尹人九九大色香蕉网站| 日韩免费视频播播| 麻豆成人久久精品二区三区免费| 最新亚洲卡一卡二卡三新区 | 西西人体44rt高清亚洲 |