Posts

Showing posts from November, 2022

Sty -OPA - Rego : Basic Rego Rules

Image
 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++  Boolean Rules & Evaluation OPA Policy Authorization : Through out we will be using API policy evaluation . This is very simple use case and a common use case.  Boolean Rules : Remember that every rule is an IF statement . When you are going to write an IF statement you are going to assign a value . Multiple Rules : In all of those rules we were thinking of them in Isolation . But with OPA you can goahead and write multiple rule and if you do that you will end up with writing a logical OR. Even though you can write multiple . What happens when non of the Rules Succeed. Then the value of that rule is undefined. But in some cases you do not want the default "undefined" result and - if non of the rules succeed. default is_read = false This is achieved by defining the result as - false This says that non of the value s

Sty -OPA - Rego : Comparing and Constructing Values

Image
 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++   +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++  How to do some Equality Checks Equality Expressions : Array is above one , below is sets . Sets are sometimes surprising to people.     These two sets has got all the same element . The order in which they appear is Irrelevant and the number of times each of this appears is irrelevant.   There is another kind of Equality operator. The x in the first bracket , it finds x is not  the same as the one on the right and it assume x as variable and assigns the value 2 on the right to x on the left. Rego Build in Functions : Build in functions do a loads of comparisons and functions .

Sty -OPA - Rego : Expressions

Image
 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++   +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++  Single Value : There are  a number of design princples that we can put in place when we design Rego, But here are the top three. Syntax : In terms is Rego syntax we have designed it to mirror those real world polices that you find in PDFs , E-Mails,  So the idea of Rego statement is that it is a simple IF Statements, Something are true if the other things are true . For example , allow this request if this user is actually alice 2. Semantics : The second design principle is more symantic . The idea here was the hierarchical data JSON/YAML and so on are pervasive so we wanted Rego to support that hierarchical data in a first class way and so 3. Algorithm : OPA coould automatically optimize performance so the policy can often focus on correctness and make retain able polices Rego Overview   one you write those rules you organize t

Sty -OPA - Rego : OPA features

Image
 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Rego languages comes with in build functions too. These are just rego functions that handles some special kind of functionality . Over 50 buildin today in Rego Composition delegations , very powerful There is a concept of modules . so you can write as many modules as you like. You can arrange them hierarchically sought of delegate policy decisions from one module to another . There is also a growing number of performance optimizations here as part of our design goals of our OPA is to allow the policy  to focus on correctness and maintainability . And evaluate the performance of valuating those policies .  There are a couple of powerful algorithms that we have integrated today one of which is  Rule Indexing  : Statically analyze whatever policies that will create a try and that will sought of organizes that kind of state wherein new

Sty -OPA - Rego : What is OPA

Image
 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++   OPA is a general purpose policy engine . All these software that we see on the right at some point of time understands that it needs a policy decision.  So what it is does it cobles on whatever policy decision that it needs about as a policy query and hands that query over to OPA . And OPA makes the decision and returns into the service , it is the services responsibility to enforce that decision . It is OPA responsibility to make that decision. For example if that service was a kubernetes API server . Kubernetes will decide that some user is trying to create a new resource on it , POD or ingress lets say on the kubernetes cluster . Kubernetes would take that 100 or 500 line of code of JSON or YAMLthat describes the new resource the user trying to deploy on to the cluster and it will hand that entire JSON or YAML code to OPA - OPA

Styra -OPA - Rego : Overview of OPA

Image
 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ All Credits to the creators of this course. ..I am just taking notes from this video tutorial for my knowledge so it helps me remember them later   https://academy.styra.com/courses/take/opa-rego/lessons/15312900-welcome-video sreejith.cloudme@gmail.com App  +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Welcome : How to use this course ? The Problem OPA solves . When we started OPA the problem that we saw that we have all kinds of different pieces of software in this could native eco-system all of which implements Policy and Authorization in it own unique way. You can think about kubernetes, when every time someone is trying to deploy a new resource on Kubernetes , there needs to be a policy or authorization problem that needs to be solved there.   Every time a microservice runs in an API call and another microservice to run there is a policy decision that needs to be made. Is