Git Product home page Git Product logo

Introduction

Atlas UI App (atlas-us-app) includes two parts:

  • atlas-ui-frontend
  • atlas-ui-server side

Front End Content (atlas-ui-frontend)

Front end content comes from atlas-ui-frontend project.

This is a self-contained AngularJS single application. Developer can work on UI code independent from ui-server side.

Build

In development mode

   npm install -- first time
   npm start 

It can also be automatically triggered by atlas-ui-sever as part of the maven build.

Server Side(atlas-ui-server)

Server side provides security authentication capacity, configuration, package and deployment capabity.

Build

Maven build automatically pulls from atlas-ui-frontend project dist and public static content, puts those under resources/static. Spring boot automatically packages all content underneath into one jar.

Modify the following lines in pom.xml in case you have different local project folder structure other than default

    <uiResourcesDir>${basedir}}/../atlas-ui-frontend</uiResourcesDir>

Run “mvn clean install” as usual to generate final uberjar atlas-ui-app-.jar

   production mode: Build atlas-ui-frontend and atlas-ui-server side, then start atlas-ui-server application
   mvn spring-boot:run 
   
   development mode: build atlas-ui-server side only, then start atlas-ui-server application
   mvn spring-boot:run -Pdevelop
   
   commandline run application jar
   java -jar atlas-ui-server-0.0.1-SNAPSHOT.jar

   Commandline run with externalized application.yml
   java -jar atlas-ui-server-0.0.1-SNAPSHOT.jar --spring.config.location=classpath:/application.yml,file:<override_file_path>.yml   

   A windows sample below
   java -jar atlas-ui-server-0.0.1-SNAPSHOT.jar --spring.config.location=classpath:/application.yml,file:C:/atlas-repo/atlas-ui-app-develop/config/application_dev.yml   

Handle security with oAuth2 + OpenId

For this to work we need some changes on the server side. The "home" controller needs an endpoint at "/user" that describes the currently authenticated user. That's quite easy to do, e.g. in our main class:

.Application [source,java]

@SpringBootApplication
@EnableOAuth2Sso
@RestController
@Configuration
public class Application {
  
  @RequestMapping("/user")
  public Principal user(Principal principal) {
    return principal;
  }

  public static void main(String[] args) {
    SpringApplication.run(SocialApplication.class, args);
  }

}

Note the use of @RestController and @RequestMapping and the java.util.Principal we inject into the handler method.

WARNING: It's not a great idea to return a whole Principal in a /user endpoint like that (it might contain information you would rather not reveal to a browser client). We only did it to get something working quickly. Later in the guide we will convert the endpoint to hide the information we don't need the browser to have.

To make the link visible we also need to switch off the security on the home page by adding a WebSecurityConfigurer:

.Wso2Application [source,java]

@SpringBootApplication
@EnableOAuth2Sso
@RestController
@Configuration
public class Application extends WebSecurityConfigurerAdapter {
    ...

   @Override
   protected void configure(HttpSecurity http) throws Exception {
      ... 
       http.antMatcher("/**").authorizeRequests()
                .antMatchers("/", "/login**", "/webjars/**", "/styles.css").permitAll()
                .anyRequest().authenticated()
                .and().logout().logoutSuccessUrl("/").permitAll()
                .and().csrf().csrfTokenRepository(csrfTokenRepository())
                .and().addFilterAfter(csrfHeaderFilter(), CsrfFilter.class);
   }
}

Spring Boot attaches a special meaning to a WebSecurityConfigurer on the class that carries the @EnableOAuth2Sso annotation: it uses it to configure the security filter chain that carries the OAuth2 authentication processor. So all we need to do to make out home page visible is to explicitly authorizeRequests() to the home page and the static resources it contains (we also include access to the login endpoints which handle the authentication). All other requests (e.g. to the /user endpoint) require authentication.

With that change in place the application is complete, and if you run it and visit the home page you should see a nicely styled HTML link to "login with Wso2 Identity Server". The link takes you not directly to Wso2 Identity server, but to the local path that processes the authentication (and sends a redirect to Wso2 Identity Server). Once you have authenticated you get redirected back to the local app, where it now displays your name (assuming you have set up your permissions in wso2 identity server to allow access to that data).

Introduce "profile"

To switch on/off authentication wiring to ease development effort

 application.yml
    profile: production 
if profile = develop, security wiring will be short-wired, hence skip any wso2 authentication
otherwise –authentication flow will be enforced.

Development Workflow

There are two profiles added in in atlas-ui-server/pom.xml • develop: only start the spring-boot services(without UI) • production: will start the spring-boot with UI inside a single jar

Suggested workflow under development mode 1.start “atlas-ui-frontend” using “npm start” 2.start “atlas-ui-server” using “mvn spring-boot:run –Pdevelop” which only starts backend service

when edit frontend code, the webpack-dev-server will auto refresh the page; when edit the backend code, the spring-boot-dev-tool will auto restart the embed tomcat server;

To switch to development mode, one needs to: *change the “profile=develop” property in atlas-ui-server\src\main\resources\application.yml *change the “backend” in constants.ts

 export var CONSTANTS = {
    "atlas": {
        "ui": {
            //change it to "" in production mode
            //change it absolute url of the atlas ui backedn, i.e. http://localhost:7001 when in development mode
            "backend": "",
            //change it to true in frontend development only mode 
            "frontendOnly": false
       }
    }
 }

When one prefer working on front-end code only, one can

  1. modify constants.ts
 export var CONSTANTS = {
    "atlas": {
        "ui": {
            //change it to "" in production mode
            //change it absolute url of the atlas ui backedn, i.e. http://localhost:7001 when in development mode
            "backend": "",
            //change it to true in frontend development only mode 
            "frontendOnly": true
       }
    }
 }

2.change app.module.ts

if(!CONSTANTS.atlas.ui.frontendOnly){
   ... 
 });
}
else{
   console.log(" frontendOnly - mock constant uiconfig....");
   
   //Define services end-points as constants in frontendOnly mode
   var mockserviceEndpoints ={
    "dataconnector":"http://appatlas1:8080",
   "storage":"http://localhost:8080",
   "mapping":"http://appatlas3:8081",
   "frd":"http://appatlas1:8083"};
   
    angular.module("app.configs.endpoint").constant("endpoints", mockserviceEndpoints);
    angular.bootstrap(document, ['app']);
}

chenhenry's Projects

ahanlp icon ahanlp

啊哈自然语言处理包,提供包括分词、依存句法分析、自动摘要、语义相似度计算、LDA 主题预测、词云等服务。

docs icon docs

TensorFlow documentation

emotional-china icon emotional-china

Chinese language sentiment analysis engine, extracting corpus from Chinese Weibo

flink-learning icon flink-learning

flink learning blog. http://www.54tianzhisheng.cn 含 Flink 入门、概念、原理、实战、性能调优、源码解析等内容。涉及 Flink Connector、Metrics、Library、DataStream API、Table API & SQL 等内容的学习案例,还有 Flink 落地应用的大型项目案例(PVUV、日志存储、百亿数据实时去重、监控告警)分享。欢迎大家支持我的专栏《大数据实时计算引擎 Flink 实战与性能优化》

go-ethereum icon go-ethereum

Official Go implementation of the Ethereum protocol

goagent-original icon goagent-original

原始的goagent版本,是从https://github.com/goagent/goagent 删除前拉取的,此处作为备份

hands-on-machine-learning icon hands-on-machine-learning

A series of Jupyter notebooks with Chinese comment that walk you through the fundamentals of Machine Learning and Deep Learning in python using Scikit-Learn and TensorFlow.

hanlda icon hanlda

对 Hankcs 编写的 LDA4j 项目的进一步包装。添加了对训练出的 LDA 模型的存储和读取,简化了 LDA 的使用到 2 个步骤:训练 和 预测。

keyword_extraction icon keyword_extraction

利用Python实现中文文本关键词抽取,分别采用TF-IDF、TextRank、Word2Vec词聚类三种方法。

newsrecommendsystem icon newsrecommendsystem

个性化新闻推荐系统,A news recommendation system involving collaborative filtering,content-based recommendation and hot news recommendation, can be adapted easily to be put into use in other circumstances.

nlp icon nlp

各种nlp 工具的使用包括 word2vec nltk textblob crf++ 等

szt-bigdata icon szt-bigdata

深圳地铁大数据客流分析系统🚇🚄🌟

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.