identity

package
v1.2.9 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Well known locations of kratos services within this namespace.
	KratosPubURL   string = "http://kratos-public"
	KratosAdminURL string = "http://kratos-admin"
)
View Source
var (
	// The sole user that is always in charge of identity and is an admin.
	// The bootstrap portal identity.
	Admin string = "ops"
)

Functions

func GetNextPageToken added in v1.2.8

func GetNextPageToken(response *http.Response) (string, error)

GetNextPageToken parses the link header in the response to get the next page of the API See: https://www.ory.sh/docs/ecosystem/api-design#pagination Stolen from Ory Slack

func KratosAdminCli added in v1.1.22

func KratosAdminCli() *ory.APIClient

func KratosPublicCli added in v1.1.22

func KratosPublicCli() *ory.APIClient

func SessionFromToken added in v1.1.22

func SessionFromToken(token string, tk TokenKind) (*ory.Session, error)

Types

type Identity

type Identity struct {
	Id     string         `json:"id"`
	Traits IdentityTraits `json:"traits"`
}

func GetIdForUser added in v1.1.22

func GetIdForUser(username string) (*Identity, error)

func NetIdentity added in v1.1.22

func NetIdentity() *Identity

Make a new Identity

func NewIdentity added in v1.1.22

func NewIdentity() *Identity

func OrySessionToId added in v1.1.22

func OrySessionToId(s *ory.Session) (*Identity, error)

func (*Identity) FromOryID added in v1.1.22

func (i *Identity) FromOryID(oryId *ory.Identity) error

type IdentityTraits

type IdentityTraits struct {
	Email    string            `json:"email"`
	Username string            `json:"username"`
	Admin    bool              `json:"admin"`
	Traits   map[string]string `json:"traits"`
}

These stucts must match the identity schemas given to kratos.

Here is Kratos internally generating this data and passing it around. API yaml Identity Traits: https://github.com/ory/kratos-client-go/blob/master/api/openapi.yaml && https://github.com/ory/kratos-client-go/blob/master/api/openapi.yaml#L2815. This generates: https://github.com/ory/kratos-client-go/blob/master/model_admin_create_identity_body.go#L31 The type of these Traits are `map[string]interface{}`. This type is set by the Open API generator.

The values that Merge Portal uses are here: https://gitlab.com/mergetb/portal/helm/-/blob/main/auth/values.yaml#L152

func GRPCCaller added in v1.1.22

func GRPCCaller(ctx context.Context) (*IdentityTraits, error)

func GRPCCallerAllowInactive added in v1.1.24

func GRPCCallerAllowInactive(ctx context.Context) (*IdentityTraits, error)

func GetUserAndTraits added in v1.1.48

func GetUserAndTraits(ctx context.Context) (*portal.User, *IdentityTraits, error)

func (*IdentityTraits) Read added in v1.1.22

func (i *IdentityTraits) Read(oryTraits map[string]interface{}) error

type TokenKind added in v1.1.22

type TokenKind int
const (
	NoToken TokenKind = iota
	Cookie
	Bearer
	Basic
)

func AccessTokenFromGrpcContext added in v1.1.22

func AccessTokenFromGrpcContext(ctx context.Context) (string, TokenKind, error)

func AccessTokenFromHTTPRequest added in v1.1.22

func AccessTokenFromHTTPRequest(r *http.Request) (string, TokenKind, error)

func (TokenKind) String added in v1.1.22

func (t TokenKind) String() string

Jump to

Keyboard shortcuts

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