Git Product home page Git Product logo

liberty-aad-oidc's Introduction

liberty-aad-oidc's People

Contributors

edburns avatar m-reza-rahman avatar majguo avatar

Watchers

 avatar  avatar  avatar

Forkers

edburns

liberty-aad-oidc's Issues

Use CDI instead of EJB

In your CafeRepositor.java, you define it as a Stateless bean. I recommend you not to use EJB but to CDI as EJB is very bulky and the future is CDI.

You can simply replace Stateless with @Dependent

A questiion on Cafe.init() to build baseUri

I see you tried to work out the uri via InetAddress. I am wondering how it will function in Kubernetes. MicroProfile Rest Client offers a good service binding approach, which allows you to override the backend url under a different environment. Can you take a look at this guide to see whether you can use MicroProfile Rest Client. You can define an interface with getAllCoffees() and then annotated with @RegisterRestClient. In your Coffee.java, you can inject that via @Inject @RestClient AInterface.

@PostConstruct
	private void init() {
		try {
			HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext()
					.getRequest();

			InetAddress inetAddress = InetAddress.getByName(request.getServerName());

			baseUri = FacesContext.getCurrentInstance().getExternalContext().getRequestScheme() + "://"
					+ inetAddress.getHostName() + ":"
					+ FacesContext.getCurrentInstance().getExternalContext().getRequestServerPort()
					+ "/javaee-cafe/rest/coffees";
			this.client = ClientBuilder.newBuilder().hostnameVerifier(new HostnameVerifier() {
				public boolean verify(String hostname, SSLSession session) {
					return true;
				}
			}).build();
			this.getAllCoffees();
		} catch (IllegalArgumentException | NullPointerException | WebApplicationException | UnknownHostException ex) {
			logger.severe("Processing of HTTP response failed.");
			ex.printStackTrace();
		}
	}

Further feedback on code structure

  • Run against Java 11

I checked out your gitrepo and tried to build with Java 11. However it failed because jaxb was deleted from JDK11. I added the following

javax.xml.bind
jaxb-api
2.3.1

        </dependency>
        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-core</artifactId>
            <version>2.3.0.1</version>
            
        </dependency>
        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-impl</artifactId>
            <version>2.3.2</version>   
        </dependency>
  • I changed the pom.xml to add liberty maven plugin so that you can start your app when running mvn clean package

    [20.0.0.1,) 3.2
io.openliberty.tools liberty-maven-plugin ${openliberty.maven.version} package-server package create install-feature deploy package target/wlp-package
      </plugin>

You can even do mvn liberty:dev to start you app in dev mode so that you can watch the changes as you code along.
I also moved server.xml from the root to src/main and then under liberty/config so that the server.xml can be picked up automatically. I think it is neater that. You can config the location to server.xml if you like. See here for more info.

  • server.xml
    At the moment, you packaged javaee-8.0, which is the full Java EE8 stack. Liberty is composable. It will only load the necessary runtime based on your server.xml. I have trimmed down your server.xml to the necessary features so that the runtime is much smaller.
cdi-2.0 jaxb-2.2 jpa-2.2 jsf-2.3 jaxrs-2.1 ejbLite-3.2 openidConnectClient-1.0 transportSecurity-1.0 appSecurity-2.0

By the way, I have not set up all the necessary credentials, so I did not do the full test. Please try the suggestions out to see whether you hit any issues.

Blog post review comments

Just some minor comments:

  1. There is a switch between Java EE and Jakarta EE without any explanation. I think it's an opportunity to promote Jakarta EE as the future of Java EE.
  2. "only user's with role" -> "only users with role"
  3. This seemed a little weird - "with the AtInject standard @Inject annotations"
  4. Could mention that this is to be done in AAD. It's not clear until you get to the end of the paragraph - "To add a groups claim into the ID token, you will need to create a group with type as Security and add one or more members. "

Dockerfile feedback

Please use the following best practices for authoring Dockerfile.

The key is to run configure.sh.

You can find Open Liberty's docker images from here.

WebSphere Liberty docker image

Please demonstrate both Java8 and Java11 versions.

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.