uauth

package module
v0.0.0-...-fa33ac8 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2024 License: MIT Imports: 16 Imported by: 0

README

GO-UAUTH

Minimalist Go library for Google Oauth authentication using Gin. You can read the manual page for more info here.

Go documentation

package uauth // import "github.com/harkaitz/go-uauth"

func CLIAuthorizationFile() (file string)
func CLIConfigurationFile() (file string)
func CLIPleaseAuthenticateError() (err error)
func GetLanguage(ctx *gin.Context, accepted ...string) (language string)
func LoadJSON(s *Settings, file string) (err error)
func RedirectToLogin(ctx *gin.Context)
func RedirectToLogout(ctx *gin.Context, page string)
type Authority struct{ ... }
type Message struct{ ... }
type Settings struct{ ... }
type UID string
type User goth.User
    func CLIGetAuthentication() (user User, found bool, err error)
    func VerifyUser(ctx *gin.Context) (user User, found bool)

Go struct Authority

package uauth // import "."

type Authority struct {
    Settings   *Settings
    CLIChannel chan User
}
    Authority is the main object to be used to authenticate.

func (u Authority) CLIAuthenticate() (user User, err error)
func (u Authority) CLIAuthenticateURL() (url string)

Go programs

Usage: uauth -fp

Authenticate using Google Oauth, more in man "uauth(1)".

Copyright (c) 2023 - Harkaitz Agirre - All rights reserved.

Collaborating

For making bug reports, feature requests and donations visit one of the following links:

  1. gemini://harkadev.com/oss/
  2. https://harkadev.com/oss/

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CLIAuthorizationFile

func CLIAuthorizationFile() (file string)

CLIAuthorizationFile returns the file where the authorization information is stored.

func CLIConfigurationFile

func CLIConfigurationFile() (file string)

CLIConfigurationFile returns the file where the configuration information is stored.

func CLIPleaseAuthenticateError

func CLIPleaseAuthenticateError() (err error)

CLIPleaseAuthenticateError returns an error to ask the user to authenticate.

func GetLanguage

func GetLanguage(ctx *gin.Context, accepted ...string) (language string)

GetLanguage .

func LoadJSON

func LoadJSON(s *Settings, file string) (err error)

LoadJSON loads the required settings for uauth from a json file.

func RedirectToLogin

func RedirectToLogin(ctx *gin.Context)

RedirectToLogin .

func RedirectToLogout

func RedirectToLogout(ctx *gin.Context, page string)

RedirectToLogout .

Types

type Authority

type Authority struct {
	Settings   *Settings
	CLIChannel chan User
}

Authority is the main object to be used to authenticate.

func (Authority) CLIAuthenticate

func (u Authority) CLIAuthenticate() (user User, err error)

CLIAuthenticate opens a browser to authenticate the user.

func (Authority) CLIAuthenticateURL

func (u Authority) CLIAuthenticateURL() (url string)

CLIAuthenticateURL returns the URL to authenticate the user.

type Settings

type Settings struct {
	UseHTTPS           bool
	Domain             string
	GoogleClientID     string
	GoogleClientSecret string
	GoogleCallbackPage string
	RandomString       string
}

Settings contains the required settings for uauth.

func (*Settings) NewAuthority

func (s *Settings) NewAuthority(e *gin.Engine, useCLI bool) (u Authority, err error)

NewAuthority creates a main object to be used to authenticate the users. It also registers a session to be used by gin.

func (*Settings) SetDefaultsUauth

func (s *Settings) SetDefaultsUauth()

SetDefaultsUauth .

func (*Settings) VerifyUauth

func (s *Settings) VerifyUauth() (err error)

VerifyUauth verifies the settings are correct.

type UID

type UID string

func (UID) CheckFormat

func (u UID) CheckFormat() (UID, error)

type User

type User goth.User

User contains the user information.

func CLIGetAuthentication

func CLIGetAuthentication() (user User, found bool, err error)

CLIGetAuthentication gets the user from the saved file.

func VerifyUser

func VerifyUser(ctx *gin.Context) (user User, found bool)

VerifyUser verifies if the user is authenticated.

func (User) GetUID

func (u User) GetUID() UID

func (User) String

func (u User) String() (s string)

String returns the user information in a string.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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