<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Okera - Medium]]></title>
        <description><![CDATA[Our mission is to empower all consumers of data to have easy, timely, and secure access to data in order to create greater business value. - Medium]]></description>
        <link>https://medium.com/cerebro-data?source=rss----5e20db8f7279---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Okera - Medium</title>
            <link>https://medium.com/cerebro-data?source=rss----5e20db8f7279---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 09:05:22 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/cerebro-data" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Reusable Redux with REST]]></title>
            <link>https://medium.com/cerebro-data/reusable-redux-with-rest-86dc70f53747?source=rss----5e20db8f7279---4</link>
            <guid isPermaLink="false">https://medium.com/p/86dc70f53747</guid>
            <category><![CDATA[redux]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[rest]]></category>
            <dc:creator><![CDATA[Mike Papale]]></dc:creator>
            <pubDate>Thu, 01 Mar 2018 23:04:23 GMT</pubDate>
            <atom:updated>2018-05-15T21:20:48.424Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gxqw7u0CPPngLQyJeHEJVQ.png" /></figure><p>At <strong>Cerebro</strong>, our goal is to give our users as many tools as possible for accessing data. The types of users we target vary, from the technical IT administrator, to the data analyst, to the curious developer, or even the less technical user who wants to access data to be able to visualize it in a tool of their choice.</p><p>These requirements immediately evoke the need for varying types of interfaces to this data. The two we will highlight in this article are the <strong>Cerebro Web UI</strong> and the <strong>Cerebro REST API.</strong></p><p>The <strong>Cerebro Web UI</strong> is tailored to less technical users or technical users that want fast, easy access to a dead-simple, usable interface. The <strong>Cerebro REST API </strong>is for users that want to take it a step further to either script their own data access logic or gain full access to features not yet exposed in the UI.</p><p>Modularity is key for technologies to not only work well together, but also to be developed independently, to be properly assured of quality, to enforce useful APIs, and possibly to be shipped independently.</p><p>Thus, we instituted an internal development requirement that the <strong>Cerebro Web UI</strong> make direct use of the <strong>Cerebro REST API</strong>, for all the reasons stated above.</p><p>This requirement means we, the <strong>Cerebro Web Team,</strong> needed a modern solution to interfacing web technologies with a REST API.</p><h3>Background Knowledge</h3><p>In the rest of this article, I’ll gloss over some important details and assume you have some prerequisite knowledge. If you’re not already familiar, make sure you have at least a basic understanding of the following concepts:</p><ul><li>React <a href="https://reactjs.org/">https://reactjs.org/</a></li><li>React Containers vs. Pure Components <a href="https://medium.com/@dan_abramov/smart-and-dumb-components-7ca2f9a7c7d0">https://medium.com/@dan_abramov/smart-and-dumb-components-7ca2f9a7c7d0</a></li><li>Redux <a href="https://redux.js.org/">https://redux.js.org/</a></li><li>Redux-Thunk <a href="https://github.com/gaearon/redux-thunk">https://github.com/gaearon/redux-thunk</a></li><li>Modular Redux <a href="https://github.com/erikras/ducks-modular-redux">https://github.com/erikras/ducks-modular-redux</a></li><li>Basic REST APIs</li><li>ES6 Promises and async/await keywords</li></ul><h3>Redux: modern state management</h3><p>The <strong>Cerebro Web UI</strong> is a technology developed in React, following modern guidelines for creating unidirectional data flow for view rendering. A natural counterpart to React is Redux, which is what we use for client-side state storage.</p><p>Since our backend is a REST API, Redux became our client-side cache of data retrieved from the REST API.</p><p>We found lacking guidance in the developer community for exactly how to implement asynchronous Redux actions in a <strong>reusable</strong> way for codebases that require multiple types of REST calls to be stored in the Redux state tree, with common states: <strong>fetching</strong>, <strong>error</strong>, and <strong>data loaded</strong>. Our first approach rapidly morphed into a ton of boilerplate code, with our Redux actions and reducers duplicating a lot of similar code, leading to poor unit testability, code maintainability, reuse, and ease of development.</p><h3>A Proposal for Reusable Redux Modules for REST APIs</h3><p>We needed a solution that allowed us to create React views from data driven by our REST API. Here’s what we came up with.</p><p>In the following, assume we have two REST APIs we want to connect to our Redux state store:</p><ol><li>GET /api/users/&lt;id&gt;. This endpoint returns data about a user.</li><li>GET /api/posts?owner=&lt;user_id&gt;. This endpoint returns a list of blog posts owned by a user.</li></ol><p><strong>Have a service layer</strong></p><p>First and foremost, create a module that allows access to the REST API, regardless of how it’s used. This can ideally be used outside of Redux, and can be used to make other facilities like authentication caching easier.</p><p>Example:</p><pre>// File: service/api.js</pre><pre>export function getUser(id) {<br>  return fetch(`/api/users/${id}`);<br>}</pre><pre>export function getPosts(userId) {<br>  return fetch(`/api/posts?owner=${userId}`);<br>}</pre><p>The above code is very basic, but typically will include other functions like parsing and error handling.</p><p><strong>Create Redux modules for each endpoint</strong></p><p>Following the approach proposed in <a href="https://github.com/erikras/ducks-modular-redux">https://github.com/erikras/ducks-modular-redux</a>, our solution involves keeping actions and reducers for a single endpoint in a single file.</p><p>The crux of our solution involves a special module, the <strong>fetch module</strong>. It is the generic module we use to ensure we can create new modules quickly.</p><pre>// File: modules/fetch.js</pre><pre>// Actions<br>export const REQUEST = &#39;modules/fetch/REQUEST&#39;;<br>export const SUCCESS = &#39;modules/fetch/SUCCESS&#39;;<br>export const ERROR = &#39;modules/fetch/ERROR&#39;;</pre><pre>// Reducer<br>export default function reducer(state, action={}) {<br>  const { storePath, data } = action;</pre><pre>  const fetchState = {<br>    fetching: false,<br>    error: false,<br>    data: null,<br>  };</pre><pre>  switch (action.type) {<br>    case REQUEST:<br>      fetchState.fetching = true;<br>      fetchState.error = false;<br>    case SUCCESS:<br>      fetchState.fetching = false;<br>      fetchState.error = false;<br>      fetchState.data = data;<br>    case ERROR:<br>      fetchState.fetching = false;<br>      fetchState.error = true;<br> }</pre><pre> // Replace the current state at `storePath` with the new<br> // computed `fetchState`.<br> return {<br>    ...state,<br>    [storePath]: {<br>      ...state[storePath],<br>      ...fetchState,<br>    }<br>  };<br>}</pre><pre>// Action creators</pre><pre>// Create a fetch action flow.<br>// * storePath: JSON key for location in the store, e.g. &#39;user&#39;.<br>// * api: function that makes a REST call, return a promise<br>// * apiArgs: list of args to send to `api`<br>export function createFetch(storePath, api, apiArgs) {<br>  // Use Thunk middleware to dispatch asynchronously<br>  return async (dispatch) =&gt; {<br>    dispatch({ type: REQUEST, storePath });<br>    <br>    try {<br>      const data = await api(...apiArgs);<br>      dispatch({ type: SUCCESS, storePath, data });<br>    } catch (e) {<br>      dispatch({ type: ERROR, storePath });<br>    }<br>  };<br>}</pre><p>Now we can implement as many new fetch modules on this pattern as we want.</p><p>Let’s start with the users module.</p><pre>// File: modules/user.js</pre><pre>import { getUser } from &#39;service/api&#39;;<br>import { createFetch } from &#39;modules/fetch.js&#39;;</pre><pre>const STORE_PATH = &#39;user&#39;;</pre><pre>// Action creators<br>export function load(id) {<br>  return createFetch(STORE_PATH, getUser, id);<br>}</pre><pre>// Selectors<br>export function selectUser(state) {<br>  return state[STORE_PATH].data;<br>}<br>export function selectFetching(state) {<br>  return state[STORE_PATH].fetching;<br>}<br>export function selectError(state) {<br>  return state[STORE_PATH].error;<br>}</pre><pre>export function selectUsername(state) {<br>  return selectUser(state).username;<br>}</pre><p>This same pattern can be easily extended to the posts module.</p><pre>// File: modules/user.js</pre><pre>import { getPosts } from &#39;service/api&#39;;<br>import { createFetch } from &#39;modules/fetch.js&#39;;</pre><pre>const STORE_PATH = &#39;posts&#39;;</pre><pre>// Action creators<br>export function load(userId) {<br>  return createFetch(STORE_PATH, getPosts, userId);<br>}</pre><pre>// Selectors<br>export function selectPosts(state) {<br>  return state[STORE_PATH].data;<br>}<br>export function selectFetching(state) {<br>  return state[STORE_PATH].fetching;<br>}<br>export function selectError(state) {<br>  return state[STORE_PATH].error;<br>}</pre><pre>export function selectFirstPost(state) {<br>  return posts.length &gt; 0 ? posts[0] : null;<br>}</pre><p>In this way, we can eliminate a significant amount of boilerplate code for initiating and managing fetches that should be written to the Redux store.</p><h3>Basic Integration with React</h3><p>We make heavy use of the React container/component pattern, see <a href="https://medium.com/@dan_abramov/smart-and-dumb-components-7ca2f9a7c7d0">https://medium.com/@dan_abramov/smart-and-dumb-components-7ca2f9a7c7d0</a>.</p><p>With our Redux modules implement as above, we can have clean integrations with React containers, like this:</p><pre>// File: containers/UserPosts.js<br>import React, { Component } from &#39;react&#39;;<br>import { connect } from &#39;react-redux&#39;;</pre><pre>// 1. Import action creators and selectors from our modules<br>import {<br>  load as loadUser,<br>  selectFetching as selectUserLoading,<br>  selectError as selectUserError,<br>  selectUsername,<br>} from &#39;modules/user.js&#39;;</pre><pre>import {<br>  load as loadPosts,<br>  selectFetching as selectPostsLoading,<br>  selectError as selectPostsError,<br>  selectPosts,<br>} from &#39;modules/posts.js&#39;;</pre><pre>// 2. Use selectors to define username/loading/error props<br>const mapStateToProps = (state) =&gt; ({<br>  username: selectUsername(state),<br>  loading: selectUserLoading(state) || selectPostsLoading(state),<br>  error: selectUserError(state) || selectPostsError(state),<br>});</pre><pre>// 3. Use action creators to define how to load.<br>//    In this case, we want to load the `user` and the `posts`.<br>const mapDispatchToProps = (dispatch) =&gt; ({<br>  load: (userId) =&gt; {<br>    loadUser(userId);<br>    loadPosts(userId);<br>  }<br>});</pre><pre>// Note: we are hard-coding the user ID, for code simplicity.<br>const TEST_USER_ID = &#39;1234&#39;;</pre><pre>// 4. Use our loader and data in a pure React component<br>class UserPosts extends Component {<br>  render() {<br>    const content = this.renderContent();<br>    <br>    return (<br>      &lt;div&gt;<br>        &lt;button onClick={() =&gt; this.props.load(TEST_USER_ID)}&gt;<br>          Load posts!<br>        &lt;/button&gt;<br>        &lt;hr/&gt;<br>        {content}<br>      &lt;/div&gt;<br>    );<br>  }</pre><pre>  renderContent() {<br>    if (this.props.loading) {<br>      return &#39;Loading...&#39;;<br>    }</pre><pre>    if (this.props.error) {<br>      return &#39;There was an error :(&#39;;<br>    }</pre><pre>    return (<br>      &lt;div&gt;<br>        &lt;h2&gt;Hello {this.props.username}&lt;/h2&gt;<br>        These are your posts:<br>        &lt;ol&gt;<br>          {this.props.posts.map((post) =&gt; (<br>            &lt;li key={post.id}&gt;{post.name}&lt;/li&gt;<br>          ))}<br>        &lt;/ol&gt;<br>      &lt;/div&gt;<br>    );<br>  }<br>}</pre><pre>export default connect(mapStateToProps, mapDispatchToProps)(UserPosts);</pre><p>The key notes from above:</p><ol><li>In our React component file, we are importing the action creators and selectors from the Redux modules we defined above.</li><li>We map the selectors, which encapsulate our <strong>fetching</strong>, <strong>error</strong>, and <strong>data</strong> states to values on the React component’s props.</li><li>We map the action creators to a generic <strong>load</strong> function on the React component, that concisely fetches both the <em>user</em><strong><em> </em></strong>and the <em>posts</em><strong><em>.</em></strong></li><li>Finally, we use the <strong>loading</strong>, <strong>error</strong>, and <strong>username</strong> props to render the proper visual state for the React component, as well as use the <strong>load</strong> function to manage fetching new data.</li></ol><p>We can use this pattern to easily create thin React containers that map props into pure components, as seen in the code snippet. Just as easily we can add or remove data or loaders for new REST endpoints that we may wish to show. Imagine how straightforward it would be to display information from a new REST endpoint, e.g. one that shows a list of the user’s friends, by creating a new Redux module and importing it in the React view.</p><p>Finally, reusing these modules in other React containers is a simple matter of importing them!</p><h3>Looking Ahead</h3><p>The solution shown here is an example of how we approach the Redux/REST problem, but it is by no means complete. In our product code, we have additional logic dealing with authentication, more expressive ways to indicate the state’s location in the store, and logic to bootstrap the Redux store so it handles these actions/reducers properly.</p><p>We feel strongly that this general approach is extremely useful to build a strong codebase for Redux that can be continually refactored and enhanced to make an overall awesome product.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=86dc70f53747" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cerebro-data/reusable-redux-with-rest-86dc70f53747">Reusable Redux with REST</a> was originally published in <a href="https://medium.com/cerebro-data">Okera</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Modern Self-Service Data Platforms]]></title>
            <link>https://medium.com/cerebro-data/modern-self-service-data-platforms-c7c90a789068?source=rss----5e20db8f7279---4</link>
            <guid isPermaLink="false">https://medium.com/p/c7c90a789068</guid>
            <category><![CDATA[analytics]]></category>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[cloud]]></category>
            <dc:creator><![CDATA[Amandeep Khurana]]></dc:creator>
            <pubDate>Mon, 11 Dec 2017 04:40:07 GMT</pubDate>
            <atom:updated>2017-12-11T04:40:07.148Z</atom:updated>
            <content:encoded><![CDATA[<p>Last week at AWS re:Invent, I heard several customers talk about how they are building data platforms in the cloud. There were some clear trends and considerations that several people brought up. As a baseline, businesses are leveraging data and analytics to stay competitive and deliver better experiences for their customers. They want to adopt modern, advanced analytics capabilities and make it frictionless (self-service) for the data analysts and scientists. This modernization of data infrastructure has to be done without compromising on enterprise requirements.</p><p>Let’s look a little deeper into what a modern data platform is.</p><h4>From Traditional to Modern</h4><p>Companies have been using enterprise data warehouses and relational databases for decades which have served them well. While important, they aren’t sufficient any more. A modern data platform needs to be able to handle new requirements of scale, more workloads, flexibility of tools — and all of that faster than ever before, without increasing the cost or risk to the business.</p><p>A modern data platform is not a single technology. It’s a way of building a comprehensive data platform that may use several different technologies that are best of breed at what they do but having them all work in unison to serve the business user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2TOH19FeUy3JcHf0." /></figure><p>A modern data platform is all about flexibility across all layers. This includes:</p><ul><li><strong>Storage and Streaming</strong>: Ability to ingest and store and preserve original data as well as derived and analyzed data assets in systems that are most appropriate for the given workload and data type. For example, some workloads may be suited for blob stores in AWS S3 and others might be better suited for streaming systems like Kafka. A modern data platform should work with multiple kinds of external storage system and not assume all data to be moved into a single system.</li><li><strong>Flexible Analytics</strong>: Users can use any kind of analytics tool that they want for the workload they are trying to do. The tools they pick should not be limited to or influenced by where and how the data is stored.</li><li><strong>Hybrid Cloud</strong>: A modern data platform should be able to run and support workloads in the data center as well as in the cloud. It should be able to scale elastically and work with ephemeral (short lived and transitory) workloads on-demand.</li></ul><p>This presents a major data management challenge for the enterprise due to all the various technologies and patterns involved.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/362/1*EHAElwaRE1AJILHHqTbY6Q.png" /></figure><p>Over the last few years, data management has ended up being the job of the data engineering teams that spend long cycles doing bespoke, undifferentiated plumbing work for every workload. They need to do this to provide their users data in a usable fashion. They don’t get to focus on higher value tasks such as on-boarding new data assets, enabling and optimizing advanced workloads such as machine learning.</p><p>For an enterprise to build a modern data platform, these data management and engineering efforts are critical. Let’s look into this further.</p><h4>What is Data Management?</h4><p>Data management consists of the following:</p><ul><li><strong>Metadata Management</strong>: Ability to define technical, operational and business metadata for data stored in different kinds of systems.</li><li><strong>Lifecycle Management</strong>: Ability to define data lifecycle rules and configurations without having to write complex processing and data movement programs.</li><li><strong>Performance Management</strong>: Ability to define the desired performance characteristics regardless of the storage or streaming system, without having to create different version of the data for different performance requirements. This also entails managing file formats, compression, partitioning and caching behind the scenes.</li><li><strong>User Management</strong>: Ability to work with the user and identity management system that the enterprise is using, such as AD, LDAP, Okta etc.</li><li><strong>Security</strong>: Ability to define rich, fine-grained access control rules that are not only limited to the roles and groups to which users belong but also a function of the metadata like tags.</li><li><strong>Data Quality</strong>: Ability to define and understand data quality characteristics for data coming from different sources.</li><li><strong>Governance</strong>: This entails auditing access and tracking lineage of data assets as they are created.</li></ul><p>All of these are required to enable the consumer of the data, the data analyst or scientist, to get access to data so they can do their analytics. In essence, these are the foundations for a <em>modern, self-service data platform</em>.</p><h4>Data Management for the Modern Data Platform</h4><p>Relational databases have data management functionality and there’s rich tooling available around them to augment their functionality. The modern data platforms that we are trying to build go beyond relational systems and include technologies with different kinds of abstractions and maturity. To enable an enterprise-grade modern data platform that provides data analysts with the ability to get access to data in an easily consumable manner, we need the data management functionality available outside of any of the storage or analytics platforms. That’s how you get the flexibility on both those layers, thereby making the modern data platform a reality for the enterprise and the mainstream analyst.</p><p>The goal is to decouple the task of staging data, and consuming it. We used to see the complex chain described above, in which a project team is responsible to establish the entire data processing pipeline, including ingest, ETL jobs, processing and delivery of the final product. This is turned upside down in a modern, self-service data platform, which provides the data and tooling to build micro pipelines. They differ in that a single person, the analyst or scientist, is set up to write any necessary processing to deliver the final product. This cuts project times into fractions of what used to be common: instead of 6 to 12 months, we see turnaround times of mere days or weeks.</p><h4>Summary</h4><p>Enabling users to establish their own data pipelines with a tool of their choice is a powerful feature. Hiding the nature of the underlying data source simplifies the processing functionality, and allows to merge data from many distinct storage types, including file and object stores, as well as stream systems. It’s obvious that there are many technical challenges that need to be solved when introducing the modern, self-service data platform into an organization. With a suitable architecture and approach, it is possible to solve these so you can start to reap the benefits of all the cutting edge data processing and analytics technology that has been built over the last decade.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c7c90a789068" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cerebro-data/modern-self-service-data-platforms-c7c90a789068">Modern Self-Service Data Platforms</a> was originally published in <a href="https://medium.com/cerebro-data">Okera</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Kerberize your Grizzly REST Server]]></title>
            <link>https://medium.com/cerebro-data/kerberos-grizzly-part-1-ef1227b59b31?source=rss----5e20db8f7279---4</link>
            <guid isPermaLink="false">https://medium.com/p/ef1227b59b31</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[grizzlies]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[kerberos]]></category>
            <dc:creator><![CDATA[Saurabh Verma]]></dc:creator>
            <pubDate>Thu, 02 Nov 2017 21:25:31 GMT</pubDate>
            <atom:updated>2017-11-08T01:01:26.984Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wU1wmhShIdyUZ6em9plSRw.png" /></figure><blockquote>tl;dr: If you are already aware of the Grizzly framework, you can skip forward to the Kerberization process<em>.</em></blockquote><p>The <a href="https://javaee.github.io/grizzly/index.html">Grizzly NIO framework</a> has become a popular choice for creating scalable web applications in Java. Amongst the many reasons for its growing popularity is the following:</p><ol><li>NIO capabilities</li><li>Easy to use web framework</li><li>Built in support for SSL</li><li>Thrift support as part of the core framework</li></ol><p>Security is of the utmost importance for enterprise software, and one feature that keeps enterprise software developers from using Grizzly is the lack of out-of-the-box support for Kerberos — a widely-used, but complex network authentication protocol.</p><p>We recently made an attempt to Kerberize one of our REST API servers which was written using the Grizzly framework. Currently, the most widely used Kerberos filter is the <a href="https://github.com/apache/cxf/blob/master/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/security/KerberosAuthenticationFilter.java">KerberosAuthenticationFilter</a> included with <a href="http://cxf.apache.org/docs/jaxrs-kerberos.html">Apache CXF</a>.</p><blockquote><strong>What are request filters?</strong></blockquote><blockquote>REST is based on HTTP, which is commonly served by a web framework. As a developer you can extend web-based applications by adding custom request filters which are invoked by the framework before processing takes place. These filters are used to perform tasks like user authentication.</blockquote><p>The filter has been known to play nice with most mature products, including JBoss, Spring and Tomcat. However, Grizzly is left out of the party. The gist of the problem here is the injection of the <a href="https://cxf.apache.org/javadoc/latest/org/apache/cxf/jaxrs/ext/MessageContext.html"><em>MessageContext</em></a> — CXF’s beefed-up implementation of SecurityContext, which Grizzly doesn’t handle gracefully..</p><p>At Cerebro, we are a justifiably tenacious bunch, so after evaluating our choices, we figured that the best solution is to solve the problem for everyone, once and for all — and decided to write the Kerberos filter for Grizzly using plain old JAAS constructs.</p><h3>The Process:</h3><p>We will break this down into four parts, not at all arranged according to complexity. This post covers only part one. The other three will be covered in the next post. The four parts are:</p><ol><li>Creating the KerberosFilter class</li><li>Creating the KerberosSecurityContext class</li><li>Creating the KerberosPrincipal class</li><li>Exposing a REST Endpoint</li></ol><h3>1. Creating the KerberosFilter class</h3><p>Grizzly registers filters just like any other resource. The steps that constitute the Kerberos authentication need to take place before the request reaches the REST endpoint. For this, the KerberosFilter needs to implement the <a href="https://docs.oracle.com/javaee/7/api/javax/ws/rs/container/ContainerRequestFilter.html">javax.ws.rs.container.ContainerRequestFilter</a> interface. The ContainerRequestFilter contract describes the filter() method that takes in a ContainerRequestContext, which is all we need at this point to authenticate an incoming client request.</p><blockquote>As per its own definition, the ContainerRequestContext class is “A mutable class that provides request-specific information for the filter, such as request URI, message headers, message entity or request-scoped properties”.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/647/1*gz2pbiV-tnGXHPye2esh-g.jpeg" /><figcaption>Kerberos Ticket Exchange Sequence. Details and Image Source: <a href="http://coewww.rutgers.edu/www1/linuxclass2011/lessons/Kerberos_auth/sec_1.php">Rutgers University</a></figcaption></figure><p>The first thing that needs to happen in a Kerberos handshake is ensuring that the incoming request has an AUTHORIZATION HTTP Header. In the absence of this, the server needs to send back a response with an HTTP 401 Unauthorized challenge header, containing the Authenticate: Negotiate status which shall elicit a response from the client that contains a well-formatted AUTHORIZATION HTTP Header as described below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/009b90a8bd92e7c9d73d4eb8153b356d/href">https://medium.com/media/009b90a8bd92e7c9d73d4eb8153b356d/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/69b3c91f099389b25908a21b63311b5f/href">https://medium.com/media/69b3c91f099389b25908a21b63311b5f/href</a></iframe><p>At this point, we expect the client (which has a TGT) to respond to the server’s Authenticate: Negotiate challenge, with a valid 2-part AUTHORIZATION header. A valid AUTHORIZATION header will have the following 2 components:</p><ol><li>The “Negotiate” string</li><li>Base64 encoded service ticket.</li></ol><p>Once again, if the required information is not found, the server can challenge the client again, requesting the required information and telling it is currently not authorized to access the resource.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fe1b8654357bca00521649d2ece40836/href">https://medium.com/media/fe1b8654357bca00521649d2ece40836/href</a></iframe><p>However, if we do receive the properly formatted AUTHORIZATION header, we can safely move to the next step, which is to use the JAAS Configuration object (javax.security.auth.login.Configuration) in order to instantiate a LoginContext. Make sure you use the same name here as your Login Configuration object, as the name serves as an index to the configuration we want to use in this Context. Call LoginContext.login() to perform the actual authentication at this point, and get back the subject using LoginContext.getSubject()<em>.</em></p><p>Before we proceed any further, let’s try and explain the new terms that have just been introduced, or will be introduced in this article:</p><blockquote><strong>What is JAAS?</strong></blockquote><blockquote><a href="https://docs.oracle.com/javase/8/docs/technotes/guides/security/jaas/JAASRefGuide.html">JAAS</a>, or <em>Java Authentication and Authorization Service</em> is Java’s integrated service for authentication and authorization purposes. It is written as an implementation of the <a href="https://en.wikipedia.org/wiki/Pluggable_authentication_module"><em>Pluggable Authentication Module (PAM)</em></a> framework, allowing applications to remain independent from the underlying authentication technologies.</blockquote><blockquote><strong>What is a Subject?</strong></blockquote><blockquote>A <a href="https://docs.oracle.com/javase/7/docs/api/javax/security/auth/Subject.html">Subject</a> represents a grouping on related information for a single entity. This information includes the Subject’s identities <em>(called </em><strong><em>Principals</em></strong><em>)</em>, as well as security-related attributes <em>(called </em><strong><em>Credentials</em></strong><em>)</em> (eg. passwords and cryptographic keys).</blockquote><blockquote><strong>What is a Principal?</strong></blockquote><blockquote>A Principal is a unique identity to which Kerberos can assign tickets. In the context of a Subject, each identity belonging to a subject is represented by a separate Principal.</blockquote><p>The next step is to associate the subject with the current AccessControlContext. For this, we need to get the GSSContext and Subject. Follow the steps in the code to get the GSSContext.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/adccd10b659345351c650ded0144ce3e/href">https://medium.com/media/adccd10b659345351c650ded0144ce3e/href</a></iframe><p>Once succesfully done, call the static method Subject.doAs() and associate the subject to the current GSSContext.</p><p>Be careful to dispose the GSSContext if the Credential Delegation is not allowed — this will make sure you don’t persist any client principal information if your server is not allowed to.</p><p>At this point, we can instantiate the SecurityContext, passing it the ContainerRequestContext and the KerberosPrincipal by calling ContainerRequestContest.setSecurityContext(). This SecurityContext will be injected into REST endpoints that have the <em>@Context SecurityContext</em> annotation description.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8123ce86e18062c012ddb6f5a7ef3eb8/href">https://medium.com/media/8123ce86e18062c012ddb6f5a7ef3eb8/href</a></iframe><h3>Conclusion</h3><p>In the next post, watch out for how to go about defining the <a href="https://docs.oracle.com/javaee/7/api/javax/ws/rs/core/SecurityContext.html">javax.ws.rs.core.SecurityContext</a> and <a href="https://docs.oracle.com/javase/7/docs/api/java/security/Principal.html">java.security.Principal</a> contracts in a simple way and exposing a Kerberos-enabled REST endpoint.</p><p>We are currently busy building a great data product and encounter many interesting challenges on a daily basis. If, like us, you enjoy solving interesting problems, mail us at careers@cerebrodata.com</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ef1227b59b31" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cerebro-data/kerberos-grizzly-part-1-ef1227b59b31">How to Kerberize your Grizzly REST Server</a> was originally published in <a href="https://medium.com/cerebro-data">Okera</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>