clients

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 26, 2023 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HydraPublicDefault = "http://127.0.0.1:4444"
	HydraAdminDefault  = "http://127.0.0.1:4445"
	HydraEnvPublic     = "HYDRA_PUBLIC_URL"
	HydraEnvAdmin      = "HYDRA_ADMIN_URL"
)
View Source
const (
	KetoReadRemoteDefault  = "127.0.0.1:4466"
	KetoWriteRemoteDefault = "127.0.0.1:4467"
	KetoEnvReadRemote      = "KETO_READ_REMOTE"
	KetoEnvWriteRemote     = "KETO_WRITE_REMOTE"
	KetoEnvAuthToken       = "KETO_BEARER_TOKEN" // nosec G101 -- just the key, not the value
	KetoEnvAuthority       = "KETO_AUTHORITY"

	ContextKeyTimeout ketoContextKeys = "timeout"
)
View Source
const (
	KratosPublicDefault = "http://127.0.0.1:4433"
	KratosAdminDefault  = "http://127.0.0.1:4434"
	KratosEnvPublic     = "KRATOS_PUBLIC_URL"
	KratosEnvAdmin      = "KRATOS_ADMIN_URL"
)

Variables

This section is empty.

Functions

func ClientIDInListOfOAuth2Clients

func ClientIDInListOfOAuth2Clients(clients []*model.OAuth2Client, clientID string) bool

function that checks if a client id is in a []*model.OAuth2Client

func KetoConn

func KetoConn(ctx context.Context, remote string, cd *KetoConnectionDetails) (*grpc.ClientConn, error)

func NewControllerClient

func NewControllerClient() (*controller.Clientset, error)

func NewHydraAdminClient

func NewHydraAdminClient() (*hydra.APIClient, error)

func NewKratosAdminClient

func NewKratosAdminClient() (*kratos.APIClient, error)

func NewKratosPublicClient

func NewKratosPublicClient() (*kratos.APIClient, error)

Types

type ClientWrapper

type ClientWrapper struct {
	ControllerClient   *controller.Clientset
	KratosAdminClient  *kratos.APIClient
	KratosPublicClient *kratos.APIClient
	KetoClient         *KetoGrpcClient
	HydraClient        *hydra.APIClient
	Log                logr.Logger
}

func (*ClientWrapper) AcceptOAuth2ConsentRequest

func (c *ClientWrapper) AcceptOAuth2ConsentRequest(ctx context.Context, challenge string, grantAccessTokenAudience []string, grantScope []string, remember *bool, rememberFor *int64, session *model.AcceptOAuth2ConsentRequestSession) (*model.OAuth2RedirectTo, error)

AcceptOAuth2ConsentRequest accepts the OAuth2 consent request for the given challenge.

func (*ClientWrapper) AddAdminToOrganization

func (c *ClientWrapper) AddAdminToOrganization(ctx context.Context, orgName string, adminId string) error

function that adds an admin to an organization in keto

func (*ClientWrapper) AddGroupToLoginBindings

func (c *ClientWrapper) AddGroupToLoginBindings(ctx context.Context, clientID string, group string) error

function that adds a group to the login bindings of an oauth2 client

func (*ClientWrapper) AddGroupsToLoginBindings

func (c *ClientWrapper) AddGroupsToLoginBindings(ctx context.Context, clientID string, groups []string) error

function that adds groups to the login bindings of an oauth2 client

func (*ClientWrapper) AddUserToGroupInKeto

func (c *ClientWrapper) AddUserToGroupInKeto(ctx context.Context, groupName string, userId string) error

func that adds a user to a group in keto

func (*ClientWrapper) AddUserToLoginBindings

func (c *ClientWrapper) AddUserToLoginBindings(ctx context.Context, clientID string, userId string) error

function that adds a user to the login bindings of an oauth2 client

func (*ClientWrapper) AddUsersToLoginBindings

func (c *ClientWrapper) AddUsersToLoginBindings(ctx context.Context, clientID string, users []string) error

function that adds users to the login bindings of an oauth2 client

func (*ClientWrapper) CreateGroupInKeto

func (c *ClientWrapper) CreateGroupInKeto(ctx context.Context, name string) error

function that creates a group in keto

func (*ClientWrapper) CreateOAuth2Client

func (c *ClientWrapper) CreateOAuth2Client(ctx context.Context, mode HydraOperation, allowedCorsOrigins []string, audience []string, authorizationCodeGrantAccessTokenLifespan *string, authorizationCodeGrantIDTokenLifespan *string, authorizationCodeGrantRefreshTokenLifespan *string, backChannelLogoutSessionRequired *bool, backChannelLogoutURI *string, clientCredentialsGrantAccessTokenLifespan *string, clientID *string, clientName *string, clientSecret *string, clientSecretExpiresAt *int64, clientURI *string, contacts []string, frontchannelLogoutSessionRequired *bool, frontchannelLogoutURI *string, grantTypes []string, implicitGrantAccessTokenLifespan *string, implicitGrantIDTokenLifespan *string, jwks map[string]interface{}, jwksURI *string, jwtBearerGrantAccessTokenLifespan *string, logoURI *string, metadata map[string]interface{}, policyURI *string, postLogoutRedirectUris []string, redirectUris []string, responseTypes []string, scope *string, sectorIdentifierURI *string, subjectType *string, tokenEndpointAuthMethod *string, tokenEndpointAuthSigningAlgorithm *string, tosURI *string, userinfoSignedResponseAlgorithm *string, loginBindings *model.LoginBindingsInput) (*model.OAuth2Client, error)

func (*ClientWrapper) CreateOAuth2ClientInKeto

func (c *ClientWrapper) CreateOAuth2ClientInKeto(ctx context.Context, id string) error

function that creates an oauth2client in keto

func (*ClientWrapper) CreateRecoveryLinkForIdentity

func (c *ClientWrapper) CreateRecoveryLinkForIdentity(ctx context.Context, id string) (*string, error)

function that create a recovery link for a user

func (*ClientWrapper) CreateUser

func (c *ClientWrapper) CreateUser(ctx context.Context, email string, name *model.NameInput) (*model.User, error)

func (*ClientWrapper) CreateUserInKeto

func (c *ClientWrapper) CreateUserInKeto(ctx context.Context, id string) error

function that creates a user in keto

func (*ClientWrapper) DeleteGroup

func (c *ClientWrapper) DeleteGroup(ctx context.Context, groupName string) (*model.Group, error)

function that deletes a group in keto

func (*ClientWrapper) DeleteOAuth2Client

func (c *ClientWrapper) DeleteOAuth2Client(ctx context.Context, clientID string) (*model.OAuth2Client, error)

function that deletes an oauth2 client

func (*ClientWrapper) DeleteOAuth2ClientInKeto

func (c *ClientWrapper) DeleteOAuth2ClientInKeto(ctx context.Context, id string) error

function that deletes an oauth2client in keto

func (*ClientWrapper) DeleteTenant

func (c *ClientWrapper) DeleteTenant(ctx context.Context, name string) (*model.ObservabilityTenant, error)

function that deletes an observability tenant using the controller client

func (*ClientWrapper) DeleteUser

func (c *ClientWrapper) DeleteUser(ctx context.Context, id string) (*model.User, error)

func (*ClientWrapper) DeleteUserInKeto

func (c *ClientWrapper) DeleteUserInKeto(ctx context.Context, id string) error

function that deletes a user from keto

func (*ClientWrapper) ExpandTenantRelation

func (c *ClientWrapper) ExpandTenantRelation(ctx context.Context, id string, relation consts.ObservabilityTenantRelation) (users []*model.User, groups []*model.Group, clients []*model.OAuth2Client, err error)

function that expands everybody with permissions on a tenant

func (*ClientWrapper) GetGroupFromName

func (c *ClientWrapper) GetGroupFromName(ctx context.Context, groupName string) (*model.Group, error)

function that gets a group from keto

func (*ClientWrapper) GetGroupMembersInKeto

func (c *ClientWrapper) GetGroupMembersInKeto(ctx context.Context, groupName string) ([]*model.User, error)

function that gets all members of a group in keto

func (*ClientWrapper) GetLoginBindingsInKeto

func (c *ClientWrapper) GetLoginBindingsInKeto(ctx context.Context, clientID string) ([]string, []string, error)

function that get the current users and groups in the login bindings of an oauth2 client

func (*ClientWrapper) GetOAuth2Client

func (c *ClientWrapper) GetOAuth2Client(ctx context.Context, id string) (*model.OAuth2Client, error)

GetOAuth2Client is the resolver for the listOAuth2Clients field.

func (*ClientWrapper) GetOAuth2ClientGroupLoginBindings

func (c *ClientWrapper) GetOAuth2ClientGroupLoginBindings(ctx context.Context, obj *model.LoginBindings) ([]*model.Group, error)

function that gets all groups that can login to the oauth2 client

func (*ClientWrapper) GetOAuth2ClientLoginBindings

func (c *ClientWrapper) GetOAuth2ClientLoginBindings(ctx context.Context, id string) (*model.LoginBindings, error)

function that gets all login bindings for an oauth2 client from keto

func (*ClientWrapper) GetOAuth2ClientUserLoginBindings

func (c *ClientWrapper) GetOAuth2ClientUserLoginBindings(ctx context.Context, obj *model.LoginBindings) ([]*model.User, error)

function that gets all users that can login to the oauth2 client

func (*ClientWrapper) GetOAuth2ConsentRequest

func (c *ClientWrapper) GetOAuth2ConsentRequest(ctx context.Context, challenge string) (*model.OAuth2ConsentRequest, error)

GetOAuth2ConsentRequest returns the OAuth2 consent request for the given challenge.

func (*ClientWrapper) GetObservabilityTenantGroups

func (c *ClientWrapper) GetObservabilityTenantGroups(ctx context.Context, groups []*model.Group) ([]*model.Group, error)

function that gets group objects from a list of group names

func (*ClientWrapper) GetObservabilityTenantOauth2Clients

func (c *ClientWrapper) GetObservabilityTenantOauth2Clients(ctx context.Context, clients []*model.OAuth2Client) ([]*model.OAuth2Client, error)

function that gets oauth2 client objects from a list of oauth2 client ids

func (*ClientWrapper) GetObservabilityTenantUsers

func (c *ClientWrapper) GetObservabilityTenantUsers(ctx context.Context, users []*model.User) ([]*model.User, error)

function that gets user objects from a list of user ids

func (*ClientWrapper) GetOrganization

func (c *ClientWrapper) GetOrganization(ctx context.Context, orgName string) (*model.Organization, error)

function that lists all organizations in keto

func (*ClientWrapper) GetOrganizationAdmins

func (c *ClientWrapper) GetOrganizationAdmins(ctx context.Context, orgName string) ([]*model.User, error)

function that returns all admins for an organization

func (*ClientWrapper) GetTenant

func (c *ClientWrapper) GetTenant(ctx context.Context, name string) (*model.ObservabilityTenant, error)

function that gets an observability tenant using the controller client

func (*ClientWrapper) GetUserFromId

func (c *ClientWrapper) GetUserFromId(ctx context.Context, id string) (*model.User, error)

function that gets a user from the Kratos API

func (*ClientWrapper) GetUserGroups

func (c *ClientWrapper) GetUserGroups(ctx context.Context, id string) ([]*model.Group, error)

function that will get all the groups a user is in

func (*ClientWrapper) GroupChangeset

func (c *ClientWrapper) GroupChangeset(ctx context.Context, groupName string, members []string) (toAdd []string, toRemove []string, err error)

function that determines which users to add or remove from a group

func (*ClientWrapper) GroupExistsInKeto

func (c *ClientWrapper) GroupExistsInKeto(ctx context.Context, groupName string) (bool, error)

function that checks if a group exists in keto

func (*ClientWrapper) IsUserInGroup

func (c *ClientWrapper) IsUserInGroup(ctx context.Context, groupName string, userId string) (bool, error)

function that checks if a user is part of a group

func (*ClientWrapper) ListGroupsInKeto

func (c *ClientWrapper) ListGroupsInKeto(ctx context.Context) ([]*model.Group, error)

function that lists all groups in keto

func (*ClientWrapper) ListOAuth2Clients

func (c *ClientWrapper) ListOAuth2Clients(ctx context.Context) ([]*model.OAuth2Client, error)

ListOAuth2Clients is the resolver for the listOAuth2Clients field.

func (*ClientWrapper) ListOrganizations

func (c *ClientWrapper) ListOrganizations(ctx context.Context) ([]*model.Organization, error)

function that lists all organizations in keto

func (*ClientWrapper) ListTenants

func (c *ClientWrapper) ListTenants(ctx context.Context) ([]*model.ObservabilityTenant, error)

function that uses the controller client to list all observability tenants

func (*ClientWrapper) ListUsers

func (c *ClientWrapper) ListUsers(ctx context.Context) ([]*model.User, error)

function that will list all users using the kratos api

func (*ClientWrapper) LoginBindingsChangeset

func (c *ClientWrapper) LoginBindingsChangeset(ctx context.Context, clientId string, bindings *model.LoginBindingsInput) (usersToAdd []string, usersToRemove []string, groupsToAdd []string, groupsToRemove []string, err error)

function that determines which users or groups to add or remove from the login bindings of an oauth2 client

func (*ClientWrapper) MutateGroup

func (c *ClientWrapper) MutateGroup(ctx context.Context, name string, members []string) (*model.Group, error)

func (*ClientWrapper) MutateObservabilityTenantInKeto

func (c *ClientWrapper) MutateObservabilityTenantInKeto(ctx context.Context, id string, tenantRelations []ObservabilityTenantRelation) error

func (*ClientWrapper) OAuth2ClientExistsInKeto

func (c *ClientWrapper) OAuth2ClientExistsInKeto(ctx context.Context, id string) (bool, error)

function that checks if an oauth2 client exists in keto

func (*ClientWrapper) OrgAdminChangeset

func (c *ClientWrapper) OrgAdminChangeset(ctx context.Context, orgName string, admins []string) (toAdd []string, toRemove []string, err error)

function that determines which admins to add or remove from an organization

func (*ClientWrapper) OrganizationExistsInKeto

func (c *ClientWrapper) OrganizationExistsInKeto(ctx context.Context, orgName string) (bool, error)

function that checks if an organization exists in keto

func (*ClientWrapper) OsTenantChangeset

func (c *ClientWrapper) OsTenantChangeset(ctx context.Context, id string, bindings *model.ObservabilityTenantPermissionBindingsInput, relation consts.ObservabilityTenantRelation) (toAdd []*rts.RelationTuple, toRemove []*rts.RelationTuple, err error)

function that determines which users or groups to add or remove from the observability tenant of an oauth2 client

func (*ClientWrapper) RejectOAuth2ConsentRequest

func (c *ClientWrapper) RejectOAuth2ConsentRequest(ctx context.Context, challenge string) (*model.OAuth2RedirectTo, error)

RejectOAuth2ConsentRequest rejects the OAuth2 consent request for the given challenge.

func (*ClientWrapper) RemoveAdminFromOrganization

func (c *ClientWrapper) RemoveAdminFromOrganization(ctx context.Context, orgName string, adminId string) error

function that removes an admin from an organization in keto

func (*ClientWrapper) RemoveGroupFromLoginBindings

func (c *ClientWrapper) RemoveGroupFromLoginBindings(ctx context.Context, clientID string, group string) error

function that removes a group from the login bindings of an oauth2 client

func (*ClientWrapper) RemoveGroupsFromLoginBindings

func (c *ClientWrapper) RemoveGroupsFromLoginBindings(ctx context.Context, clientID string, groups []string) error

function that removes groups from the login bindings of an oauth2 client

func (*ClientWrapper) RemoveUserFromGroupInKeto

func (c *ClientWrapper) RemoveUserFromGroupInKeto(ctx context.Context, groupName string, userId string) error

function that removes a user from a group in keto

func (*ClientWrapper) RemoveUserFromLoginBindings

func (c *ClientWrapper) RemoveUserFromLoginBindings(ctx context.Context, clientID string, userId string) error

function that removes a user from the login bindings of an oauth2 client

func (*ClientWrapper) RemoveUsersFromLoginBindings

func (c *ClientWrapper) RemoveUsersFromLoginBindings(ctx context.Context, clientID string, users []string) error

function that removes users from the login bindings of an oauth2 client

func (*ClientWrapper) ResolveTenantBindings

func (c *ClientWrapper) ResolveTenantBindings(ctx context.Context, id string, relation consts.ObservabilityTenantRelation) (bindings *model.ObservabilityTenantPermissionBindings, err error)

function that resolves an ObservabilityTenantPermissionBindings

func (*ClientWrapper) UnmarshalUserTraits

func (c *ClientWrapper) UnmarshalUserTraits(user *kratos.Identity) (*model.User, error)

func (*ClientWrapper) UpdateOrganization

func (c *ClientWrapper) UpdateOrganization(ctx context.Context, name string, admins []string) (*model.Organization, error)

func (*ClientWrapper) UserExistsInKeto

func (c *ClientWrapper) UserExistsInKeto(ctx context.Context, id string) (bool, error)

function that checks if a user exists in keto

type HydraOperation

type HydraOperation string
const (
	HydraOperationCreate HydraOperation = "create"
	HydraOperationUpdate HydraOperation = "update"
)

type KetoConnectionDetails

type KetoConnectionDetails struct {
	// contains filtered or unexported fields
}

func NewKetoConnectionDetailsFromEnv

func NewKetoConnectionDetailsFromEnv() KetoConnectionDetails

func (*KetoConnectionDetails) ReadConn

func (cd *KetoConnectionDetails) ReadConn(ctx context.Context) (*grpc.ClientConn, error)

func (*KetoConnectionDetails) WriteConn

func (cd *KetoConnectionDetails) WriteConn(ctx context.Context) (*grpc.ClientConn, error)

type KetoGrpcClient

type KetoGrpcClient struct {
	ConnDetails KetoConnectionDetails
	// contains filtered or unexported fields
}

func NewKetoGrpcClient

func NewKetoGrpcClient(ctx Context, cd KetoConnectionDetails) (*KetoGrpcClient, error)

func (*KetoGrpcClient) Check

func (g *KetoGrpcClient) Check(ctx Context, r *rts.RelationTuple) (bool, error)

func (*KetoGrpcClient) CreateTuple

func (g *KetoGrpcClient) CreateTuple(ctx Context, r *rts.RelationTuple) error

func (*KetoGrpcClient) CreateTuples

func (g *KetoGrpcClient) CreateTuples(ctx Context, r []*rts.RelationTuple) error

func (*KetoGrpcClient) DeleteAllTuples

func (g *KetoGrpcClient) DeleteAllTuples(ctx Context, q *rts.RelationQuery) error

func (*KetoGrpcClient) DeleteTuple

func (g *KetoGrpcClient) DeleteTuple(ctx Context, r *rts.RelationTuple) error

func (*KetoGrpcClient) DeleteTuples

func (g *KetoGrpcClient) DeleteTuples(ctx Context, r []*rts.RelationTuple) error

func (*KetoGrpcClient) Expand

func (g *KetoGrpcClient) Expand(ctx Context, ss *rts.Subject, depth int) (*rts.SubjectTree, error)

func (*KetoGrpcClient) QueryAllTuples

func (g *KetoGrpcClient) QueryAllTuples(ctx Context, q *rts.RelationQuery, pagesize int) ([]*rts.RelationTuple, error)

func (*KetoGrpcClient) QueryTuple

func (g *KetoGrpcClient) QueryTuple(ctx Context, q *rts.RelationQuery, opts ...PaginationOptionSetter) (*rts.ListRelationTuplesResponse, error)

func (*KetoGrpcClient) TransactTuples

func (g *KetoGrpcClient) TransactTuples(ctx Context, ins []*rts.RelationTuple, del []*rts.RelationTuple) error

func (*KetoGrpcClient) WaitUntilLive

func (g *KetoGrpcClient) WaitUntilLive(ctx Context) error

TODO: not sure if this is the correct thing to do

type PaginationOptionSetter

type PaginationOptionSetter func(*PaginationOptions) *PaginationOptions

func KetoWithSize

func KetoWithSize(size int) PaginationOptionSetter

func KetoWithToken

func KetoWithToken(t string) PaginationOptionSetter

type PaginationOptions

type PaginationOptions struct {
	Token string `json:"page_token"`
	Size  int    `json:"page_size"`
}

func GetPaginationOptions

func GetPaginationOptions(modifiers ...PaginationOptionSetter) *PaginationOptions

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL