tokenauth

package
v0.0.0-...-4c78285 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Overview

* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreatePolicy

func CreatePolicy(c echo.Context) error

func CreateToken

func CreateToken(c echo.Context) error

func DeletePolicy

func DeletePolicy(c echo.Context) error

func GetPolicies

func GetPolicies(c echo.Context) error

func GetPolicy

func GetPolicy(c echo.Context) error

func RenewToken

func RenewToken(c echo.Context) error

func ValidateEmbargoToken

func ValidateEmbargoToken(next echo.HandlerFunc) echo.HandlerFunc

Middleware function to validate Embargo token

Types

type EmbargoPolicy

type EmbargoPolicy struct {
	PolicyID   uuid.UUID    `json:"policy_id"`
	PolicyName string       `json:"policy_name"`
	Created_at time.Time    `json:"created_at"`
	Updated_at time.Time    `json:"updated_at"`
	Paths      []PolicyPath `json:"paths"`
}

type EmbargoToken

type EmbargoToken struct {
	TokenID     uuid.UUID
	TokenHash   string
	DisplayName string
	CreatedAt   time.Time
	UpdatedAt   time.Time
	Ttl         int
	Renewable   bool
	Root        bool
	Orphan      bool
	Parent      uuid.UUID
	Policies    []uuid.UUID
	Metadata    map[string]string
}

func CreateEmbargoToken

func CreateEmbargoToken(name string, ttl int, renewable bool, root bool, orphen bool, parent uuid.UUID, policies []uuid.UUID, metadata map[string]string) (EmbargoToken, string)

Create a new Embaro token

func ValidateToken

func ValidateToken(token string) (EmbargoToken, bool)

Check if a token is valid

type EmbargoTokenResponse

type EmbargoTokenResponse struct {
	Token       string            `json:"token"`
	DisplayName string            `json:"display_name"`
	CreatedAt   time.Time         `json:"created_at"`
	UpdatedAt   time.Time         `json:"updated_at"`
	Ttl         int               `json:"ttl"`
	Renewable   bool              `json:"renewable"`
	Root        bool              `json:"root"`
	Orphan      bool              `json:"orphan"`
	Parent      uuid.UUID         `json:"parent"`
	Policies    []uuid.UUID       `json:"policies"`
	Metadata    map[string]string `json:"metadata"`
}

type GetPoliciesResponse

type GetPoliciesResponse struct {
	Data  []EmbargoPolicy `json:"data"`
	Total int             `json:"total"`
}

type PolicyPath

type PolicyPath struct {
	Path   string `json:"path" validate:"required"`
	Method string `json:"method" validate:"required"`
}

type PostedPolicyRequest

type PostedPolicyRequest struct {
	PolicyName string       `json:"policy_name" validate:"required"`
	Paths      []PolicyPath `json:"paths" validate:"required"`
}

type PostedTokenRenewRequest

type PostedTokenRenewRequest struct {
	Ttl int `json:"duration"`
}

type PostedTokenRequest

type PostedTokenRequest struct {
	DisplayName string            `json:"display_name"`
	Ttl         int               `json:"ttl"`
	Renewable   bool              `json:"renewable"`
	Root        bool              `json:"root"`
	Orphan      bool              `json:"orphan"`
	Policies    []uuid.UUID       `json:"policies"`
	Metadata    map[string]string `json:"metadata"`
}

Jump to

Keyboard shortcuts

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