routes

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PublicAPIRoute = "/public"
)

Variables

This section is empty.

Functions

func GetStandardTimetableData

func GetStandardTimetableData(data *DataTemplate, timetabletype string, query *ent.TimetableQuery, client *ent.Client, ctx context.Context, location *time.Location) (int, error)

func HasPublicRoute

func HasPublicRoute(routes []string) bool

func RegisterOAuthAPI

func RegisterOAuthAPI(r *chi.Mux, srv *Server) *chi.Mux

Types

type DataTemplate

type DataTemplate struct {
	Title             string
	Locale            string
	TimetableTypeData []TimetableData
}

type Server

type Server struct {
	Client      *ent.Client
	OAuthServer *oauth.BearerServer
}

func NewServer

func NewServer(client *ent.Client) *Server

func (*Server) CheckUser

func (s *Server) CheckUser(next http.Handler) http.Handler

func (*Server) Timetables

func (s *Server) Timetables(w http.ResponseWriter, r *http.Request)

type TimetableData

type TimetableData struct {
	TimetableType string
	CSSTop        template.CSS
	CSSBottom     template.CSS
	HTMLTop       template.HTML
	HTMLBottom    template.HTML
	Data          []*ent.Timetable
}

type UserVerifier

type UserVerifier struct {
	Client *ent.Client
	// contains filtered or unexported fields
}

UserVerifier provides user credentials verifier for testing.

func (*UserVerifier) AddClaims

func (t *UserVerifier) AddClaims(tokenType oauth.TokenType, credential, tokenID, scope string, r *http.Request) (map[string]string, error)

AddClaims provides additional claims to the token

func (*UserVerifier) AddProperties

func (t *UserVerifier) AddProperties(tokenType oauth.TokenType, credential, tokenID, scope string, r *http.Request) (map[string]string, error)

AddProperties provides additional information to the token response

func (*UserVerifier) StoreTokenID

func (*UserVerifier) StoreTokenID(tokenType oauth.TokenType, credential, tokenID, refreshTokenID string) error

StoreTokenID saves the token id generated for the user

func (*UserVerifier) ValidateClient

func (*UserVerifier) ValidateClient(clientID, clientSecret, scope string, r *http.Request) error

ValidateClient validates clientID and secret returning an error if the client credentials are wrong

func (*UserVerifier) ValidateCode

func (*UserVerifier) ValidateCode(clientID, clientSecret, code, redirectURI string, r *http.Request) (string, error)

ValidateCode validates token ID

func (*UserVerifier) ValidateTokenID

func (*UserVerifier) ValidateTokenID(tokenType oauth.TokenType, credential, tokenID, refreshTokenID string) error

ValidateTokenID validates token ID

func (*UserVerifier) ValidateUser

func (t *UserVerifier) ValidateUser(username, password, scope string, r *http.Request) error

ValidateUser validates username and password returning an error if the user credentials are wrong

Jump to

Keyboard shortcuts

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