-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add Policy Protobufs #268
Closed
Closed
Changes from 4 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
3d0fe3d
add basic proto generation
pbacon-blaber 95d6252
strategy all
pbacon-blaber 6b38509
lint ignore proto
pbacon-blaber ed46e21
don't ignore idp
pbacon-blaber 7b11794
add to readme
pbacon-blaber b88ad47
remove abc.ts
pbacon-blaber c6b77a6
add make command
pbacon-blaber 39262d8
use newer tool
pbacon-blaber 7583683
remove platform
pbacon-blaber File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,3 +46,14 @@ 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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
version: v1 | ||
managed: | ||
enabled: false | ||
plugins: | ||
- plugin: grpc-gateway-ts | ||
out: lib/proto | ||
strategy: all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* eslint-disable */ | ||
// @ts-nocheck | ||
/* | ||
* This file is a generated Typescript file for GRPC Gateway, DO NOT MODIFY | ||
*/ | ||
|
||
import * as GoogleProtobufAny from "../google/protobuf/any.pb" | ||
import * as GoogleProtobufStruct from "../google/protobuf/struct.pb" | ||
import * as AuthorizationAuthorization from "./authorization.pb" | ||
export type IdpConfig = { | ||
config?: GoogleProtobufStruct.Struct | ||
} | ||
|
||
export type IdpPluginRequest = { | ||
entities?: AuthorizationAuthorization.Entity[] | ||
} | ||
|
||
export type IdpEntityRepresentation = { | ||
additionalProps?: GoogleProtobufStruct.Struct[] | ||
originalId?: string | ||
} | ||
|
||
export type IdpPluginResponse = { | ||
entityRepresentations?: IdpEntityRepresentation[] | ||
} | ||
|
||
export type EntityNotFoundError = { | ||
code?: number | ||
message?: string | ||
details?: GoogleProtobufAny.Any[] | ||
entity?: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, it seems that this package marks every field as optional when generating code.
There is a very old / stale issue on this which doesn't appear to have any progress in the last two years: grpc-ecosystem/protoc-gen-grpc-gateway-ts#26
Is this a dealbreaker for us using
protoc-gen-grpc-gateway-ts
@strantalis?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also getting the following error message when building the protos:
Pretty new to all this protobuf stuff so wondering if this is something that's easily fixed by adding another plugin? Or is it more complicated than that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm kinda surprised optional is a feature of proto3. I've been outta the loop. https://stackoverflow.com/a/62566052/23894185