Skip to content

Commit

Permalink
add basic proto generation
Browse files Browse the repository at this point in the history
  • Loading branch information
pbacon-blaber committed Apr 29, 2024
1 parent ec58031 commit 3d0fe3d
Show file tree
Hide file tree
Showing 16 changed files with 1,311 additions and 3 deletions.
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,13 @@ format license-check lint test: ci

doc:
cd lib && npm run doc

toolcheck:
@echo "Checking for required tools..."
@which buf > /dev/null || (echo "buf not found, please install it from https://docs.buf.build/installation" && exit 1)
@which protoc-gen-grpc-gateway-ts > /dev/null || (echo "protoc-gen-grpc-gateway-ts not found, run 'go install github.com/grpc-ecosystem/[email protected]'" && exit 1)
@golangci-lint --version | grep "version v\?1.5[67]" > /dev/null || (echo "golangci-lint version must be v1.55 [$$(golangci-lint --version)]" && exit 1)

proto-generate:
rm -rf lib/proto
buf generate https://github.com/opentdf/platform.git\#branch\=main,subdir\=service --exclude-path authorization/idp_plugin.proto
6 changes: 6 additions & 0 deletions buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: v1
managed:
enabled: false
plugins:
- plugin: grpc-gateway-ts
out: lib/proto
93 changes: 93 additions & 0 deletions lib/proto/authorization/authorization.pb.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/* eslint-disable */
// @ts-nocheck
/*
* This file is a generated Typescript file for GRPC Gateway, DO NOT MODIFY
*/

import * as fm from "../fetch.pb"
import * as GoogleProtobufAny from "../google/protobuf/any.pb"
import * as PolicyObjects from "../policy/objects.pb"

type Absent<T, K extends keyof T> = { [k in Exclude<keyof T, K>]?: undefined };
type OneOf<T> =
| { [k in keyof T]?: undefined }
| (
keyof T extends infer K ?
(K extends string & keyof T ? { [k in K]: T[K] } & Absent<T, K>
: never)
: never);

export enum DecisionResponseDecision {
DECISION_UNSPECIFIED = "DECISION_UNSPECIFIED",
DECISION_DENY = "DECISION_DENY",
DECISION_PERMIT = "DECISION_PERMIT",
}


type BaseEntity = {
id?: string
}

export type Entity = BaseEntity
& OneOf<{ emailAddress: string; userName: string; remoteClaimsUrl: string; jwt: string; claims: GoogleProtobufAny.Any; custom: EntityCustom; clientId: string }>

export type EntityCustom = {
extension?: GoogleProtobufAny.Any
}

export type EntityChain = {
id?: string
entities?: Entity[]
}

export type DecisionRequest = {
actions?: PolicyObjects.Action[]
entityChains?: EntityChain[]
resourceAttributes?: ResourceAttribute[]
}

export type DecisionResponse = {
entityChainId?: string
resourceAttributesId?: string
action?: PolicyObjects.Action
decision?: DecisionResponseDecision
obligations?: string[]
}

export type GetDecisionsRequest = {
decisionRequests?: DecisionRequest[]
}

export type GetDecisionsResponse = {
decisionResponses?: DecisionResponse[]
}


type BaseGetEntitlementsRequest = {
entities?: Entity[]
}

export type GetEntitlementsRequest = BaseGetEntitlementsRequest
& OneOf<{ scope: ResourceAttribute }>

export type EntityEntitlements = {
entityId?: string
attributeValueFqns?: string[]
}

export type ResourceAttribute = {
attributeValueFqns?: string[]
}

export type GetEntitlementsResponse = {
entitlements?: EntityEntitlements[]
}

export class AuthorizationService {
static GetDecisions(req: GetDecisionsRequest, initReq?: fm.InitReq): Promise<GetDecisionsResponse> {
return fm.fetchReq<GetDecisionsRequest, GetDecisionsResponse>(`/v1/authorization`, {...initReq, method: "POST"})
}
static GetEntitlements(req: GetEntitlementsRequest, initReq?: fm.InitReq): Promise<GetEntitlementsResponse> {
return fm.fetchReq<GetEntitlementsRequest, GetEntitlementsResponse>(`/v1/entitlements`, {...initReq, method: "POST"})
}
}
30 changes: 30 additions & 0 deletions lib/proto/common/common.pb.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* eslint-disable */
// @ts-nocheck
/*
* This file is a generated Typescript file for GRPC Gateway, DO NOT MODIFY
*/

import * as GoogleProtobufTimestamp from "../google/protobuf/timestamp.pb"

export enum MetadataUpdateEnum {
METADATA_UPDATE_ENUM_UNSPECIFIED = "METADATA_UPDATE_ENUM_UNSPECIFIED",
METADATA_UPDATE_ENUM_EXTEND = "METADATA_UPDATE_ENUM_EXTEND",
METADATA_UPDATE_ENUM_REPLACE = "METADATA_UPDATE_ENUM_REPLACE",
}

export enum ActiveStateEnum {
ACTIVE_STATE_ENUM_UNSPECIFIED = "ACTIVE_STATE_ENUM_UNSPECIFIED",
ACTIVE_STATE_ENUM_ACTIVE = "ACTIVE_STATE_ENUM_ACTIVE",
ACTIVE_STATE_ENUM_INACTIVE = "ACTIVE_STATE_ENUM_INACTIVE",
ACTIVE_STATE_ENUM_ANY = "ACTIVE_STATE_ENUM_ANY",
}

export type Metadata = {
createdAt?: GoogleProtobufTimestamp.Timestamp
updatedAt?: GoogleProtobufTimestamp.Timestamp
labels?: {[key: string]: string}
}

export type MetadataMutable = {
labels?: {[key: string]: string}
}
Loading

0 comments on commit 3d0fe3d

Please sign in to comment.