...

Package authremote

import "golang.conradwood.net/go-easyops/authremote"
Overview
Index

Overview ▾

This package provides access to user information which require network I/O, for example lookup of users by email.

It also provides some wrappers to create a new context. That is for historic reasons. Developers should use and port code to use the ctx package instead.

Index ▾

func Context() context.Context
func ContextForUser(user *apb.User) (context.Context, error)
func ContextForUserID(userid string) (context.Context, error)
func ContextForUserIDWithTimeout(userid string, to time.Duration) (context.Context, error)
func ContextForUserWithTimeout(user *apb.User, secs uint64) (context.Context, error)
func ContextWithTimeout(t time.Duration) context.Context
func ContextWithTimeoutAndTags(t time.Duration, rt *ge.CTXRoutingTags) context.Context
func DIS_ContextV2WithTimeoutAndTags(t time.Duration, rt *ge.CTXRoutingTags) context.Context
func DIS_ContextV2WithTimeoutAndTagsForUser(t time.Duration, reqid string, user *apb.SignedUser, rt *ge.CTXRoutingTags) (context.Context, context.CancelFunc)
func DIS_build_new_ctx_meta_struct(requestid string, user, sudo *apb.SignedUser) *ge.InContext
func DIS_contextFromStruct(ctx context.Context, inctx *ge.InContext) context.Context
func DerivedContextWithRouting(cv context.Context, kv map[string]string, fallback bool) context.Context
func GetAuthClient() apb.AuthenticationServiceClient
func GetAuthManagerClient() apb.AuthManagerServiceClient
func GetAuthenticationService() apb.AuthenticationServiceClient
func GetAuthenticationServiceClient() apb.AuthenticationServiceClient
func GetByToken(ctx context.Context, token string) *apb.User
func GetLocalServiceAccount() *apb.SignedUser
func GetLocalUsers() (*apb.SignedUser, *apb.SignedUser)
func GetSignedUserByID(ctx context.Context, userid string) (*apb.SignedUser, error)
func GetUserByEmail(ctx context.Context, email string) (*apb.User, error)
func GetUserByID(ctx context.Context, userid string) (*apb.User, error)
func NewContextWithRouting(kv map[string]string, fallback bool) context.Context
func NewContextWithRoutingTags(rt *ge.CTXRoutingTags) context.Context
func PartitionID(ctx context.Context) (uint64, error)
func SignedGetByEmail(ctx context.Context, email string) *apb.SignedUser
func SignedGetByToken(ctx context.Context, token string) *apb.SignedUser
func WhoAmI() *apb.User
type CallStateV2

Package files

auth_remote.go context.go create_context.go local_account.go metadata.go partitions.go standalone.go user_cache.go

func Context

func Context() context.Context

func ContextForUser

func ContextForUser(user *apb.User) (context.Context, error)

create an outbound context for a given user. user must be valid and signed this is an expensive call this is not privileged (user must be signed)

func ContextForUserID

func ContextForUserID(userid string) (context.Context, error)

create an outbound context for a given user by id (with current service token) this is an expensive call it is also privileged

func ContextForUserIDWithTimeout

func ContextForUserIDWithTimeout(userid string, to time.Duration) (context.Context, error)

func ContextForUserWithTimeout

func ContextForUserWithTimeout(user *apb.User, secs uint64) (context.Context, error)

func ContextWithTimeout

func ContextWithTimeout(t time.Duration) context.Context
this context gives a context with a full userobject

todo so it _has_ to call external servers to get a signed userobject. if started_by_autodeployer will use getContext() else if environment variable with context, will use auth.Context() (with variable) else create context by asking auth service for a signed user object

func ContextWithTimeoutAndTags

func ContextWithTimeoutAndTags(t time.Duration, rt *ge.CTXRoutingTags) context.Context

create a new context with routing tags. This is an EXPERIMENTAL API and very likely to change in future

func DIS_ContextV2WithTimeoutAndTags

func DIS_ContextV2WithTimeoutAndTags(t time.Duration, rt *ge.CTXRoutingTags) context.Context

func DIS_ContextV2WithTimeoutAndTagsForUser

func DIS_ContextV2WithTimeoutAndTagsForUser(t time.Duration, reqid string, user *apb.SignedUser, rt *ge.CTXRoutingTags) (context.Context, context.CancelFunc)

creates a new context for a user, with a timeout and routing tags and a cancel function userid may be "" (empty).

func DIS_build_new_ctx_meta_struct

func DIS_build_new_ctx_meta_struct(requestid string, user, sudo *apb.SignedUser) *ge.InContext

build the struct we need to add to the context. used to create new contexts (e.g. in h2gproxy or in command line clients) it will determine the service itself. user and sudo may be nil. this is intented to be used as outbound context to other services

func DIS_contextFromStruct

func DIS_contextFromStruct(ctx context.Context, inctx *ge.InContext) context.Context

func DerivedContextWithRouting

func DerivedContextWithRouting(cv context.Context, kv map[string]string, fallback bool) context.Context

derive a context with routing tags (routing criteria to route to specific instances of a service) if fallback is true, fallback to any service without tags if none is found (default was false)

func GetAuthClient

func GetAuthClient() apb.AuthenticationServiceClient

func GetAuthManagerClient

func GetAuthManagerClient() apb.AuthManagerServiceClient

func GetAuthenticationService

func GetAuthenticationService() apb.AuthenticationServiceClient

compat with 'create', synonym for GetAuthClient()

func GetAuthenticationServiceClient

func GetAuthenticationServiceClient() apb.AuthenticationServiceClient

compat with 'create', synonym for GetAuthClient()

func GetByToken

func GetByToken(ctx context.Context, token string) *apb.User

func GetLocalServiceAccount

func GetLocalServiceAccount() *apb.SignedUser

the local service's useraccount (nil if on commandline or service without useraccount)

func GetLocalUsers

func GetLocalUsers() (*apb.SignedUser, *apb.SignedUser)

get the user and service we are running as. Do not cache this result! (on boot the result may change once auth comes available)

func GetSignedUserByID

func GetSignedUserByID(ctx context.Context, userid string) (*apb.SignedUser, error)

func GetUserByEmail

func GetUserByEmail(ctx context.Context, email string) (*apb.User, error)

func GetUserByID

func GetUserByID(ctx context.Context, userid string) (*apb.User, error)

func NewContextWithRouting

func NewContextWithRouting(kv map[string]string, fallback bool) context.Context

create a new context with routing tags (routing criteria to route to specific instances of a service) if fallback is true, fallback to any service without tags if none is found (default was false)

func NewContextWithRoutingTags

func NewContextWithRoutingTags(rt *ge.CTXRoutingTags) context.Context

get a context with routing tags, specified by proto

func PartitionID

func PartitionID(ctx context.Context) (uint64, error)

returns the partitionid for the user in this context. a partition is either:

the information in the context determines which partition will be returned a context without user information will always use partition 0

Note: currently this is a bit of a stub. it only resolves the userid to a partition and does not consider the organisation

PartitionIDs start from 100 upwards. this is meant to make it easier for tools to support custom partitions, such as "any user" or "no user" or so

func SignedGetByEmail

func SignedGetByEmail(ctx context.Context, email string) *apb.SignedUser

func SignedGetByToken

func SignedGetByToken(ctx context.Context, token string) *apb.SignedUser

func WhoAmI

func WhoAmI() *apb.User

type CallStateV2

a local context value

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