Skip to content

The oauth package is a simple wrapper around the egothic package and provides a few syntactic niceties.

License

Notifications You must be signed in to change notification settings

agentstation/oauth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

                          ___   __ _  _   _  _    _     
                         / _ \ / _` || | | || |_ | |__  
                        | (_) | (_| || |_| || __|| '_ \ 
                         \___/ \__,_| \__,_| \__||_| |_|

oauth

import "github.com/agentstation/oauth"

Index

Variables

var (
    // GetState gets the state from the oauth session.
    GetState = egothic.GetState
    // SetState sets the state in the oauth session.
    SetState = egothic.SetState
    // GetProviderName gets the provider name from the oauth session.
    GetProviderName = egothic.GetProviderName
)

func Begin

func Begin(e echo.Context, opts ...Options) error

Begin starts the authentication process for a given provider.

func GetSession(e echo.Context, key string) (string, error)

GetSession retrieves a value from the session by key. It returns an error if the key doesn't exist.

func Logout

func Logout(e echo.Context) error

Logout invalidates a user session.

func ProviderURL(e echo.Context, opts ...Options) (string, error)

ProviderURL returns the authentication URL for the specified provider.

func SetProviders(providers ...goth.Provider)

SetProviders sets the goth oauth providers.

You can find the list of supported providers here: https://github.com/markbates/goth?tab=readme-ov-file#supported-providers

func SetSession(e echo.Context, key string, value string) error

SetSession stores a key/value pair in the session.

func SetStore(store sessions.Store)

SetStore sets the store for the oauth session.

func Store

func Store() sessions.Store

Store returns the store for the oauth session.

type Options

Options is a function that configures the oauth package.

type Options func(*oauthConfig)

func WithDebug() Options

WithDebug sets the debug mode for the oauth package.

func WithLogger(logger *log.Logger) Options

WithLogger sets the logger for the oauth package.

Provider represents an OAuth provider

type Provider string

Provider constants

const (
    Amazon          Provider = "amazon"
    Apple           Provider = "apple"
    Auth0           Provider = "auth0"
    AzureAD         Provider = "azuread"
    BattleNet       Provider = "battlenet"
    Bitbucket       Provider = "bitbucket"
    Box             Provider = "box"
    Dailymotion     Provider = "dailymotion"
    Deezer          Provider = "deezer"
    DigitalOcean    Provider = "digitalocean"
    Discord         Provider = "discord"
    Dropbox         Provider = "dropbox"
    EveOnline       Provider = "eveonline"
    Facebook        Provider = "facebook"
    Fitbit          Provider = "fitbit"
    Gitea           Provider = "gitea"
    GitHub          Provider = "github"
    GitLab          Provider = "gitlab"
    Google          Provider = "google"
    GPlus           Provider = "gplus"
    Heroku          Provider = "heroku"
    Instagram       Provider = "instagram"
    Intercom        Provider = "intercom"
    Kakao           Provider = "kakao"
    LastFM          Provider = "lastfm"
    Line            Provider = "line"
    LinkedIn        Provider = "linkedin"
    Mastodon        Provider = "mastodon"
    Meetup          Provider = "meetup"
    MicrosoftOnline Provider = "microsoftonline"
    Naver           Provider = "naver"
    Nextcloud       Provider = "nextcloud"
    Okta            Provider = "okta"
    OneDrive        Provider = "onedrive"
    OpenIDConnect   Provider = "openidconnect"
    Patreon         Provider = "patreon"
    PayPal          Provider = "paypal"
    Salesforce      Provider = "salesforce"
    SeaTalk         Provider = "seatalk"
    Shopify         Provider = "shopify"
    Slack           Provider = "slack"
    SoundCloud      Provider = "soundcloud"
    Spotify         Provider = "spotify"
    Steam           Provider = "steam"
    Strava          Provider = "strava"
    Stripe          Provider = "stripe"
    TikTok          Provider = "tiktok"
    Twitch          Provider = "twitch"
    Twitter         Provider = "twitter"
    TwitterV2       Provider = "twitterv2"
    Typetalk        Provider = "typetalk"
    Uber            Provider = "uber"
    VK              Provider = "vk"
    WeCom           Provider = "wecom"
    WePay           Provider = "wepay"
    Xero            Provider = "xero"
    Yahoo           Provider = "yahoo"
    Yammer          Provider = "yammer"
    Yandex          Provider = "yandex"
    Zoom            Provider = "zoom"
)

ProviderConfigMap is a map of providers to configuration key values.

type ProviderConfigMap map[Provider]ProviderKeyValues

func NewProviderConfigMap() ProviderConfigMap

NewProviderConfigMap creates a new provider configuration map.

func (ProviderConfigMap) Get

func (pc ProviderConfigMap) Get(provider Provider) ProviderKeyValues

Get returns the ProviderKeyValues for the given provider name.

func (ProviderConfigMap) Set

func (pc ProviderConfigMap) Set(provider Provider, keyValues ...string) error

Set sets the ProviderKeyValues for the given provider name.

ProviderKeyValues is the configuration for a goth oauth provider.

type ProviderKeyValues map[string]string

type User

User represents an oauth user that has authenticated.

type User struct {
    RawData           map[string]interface{}
    Provider          string
    Email             string
    Name              string
    FirstName         string
    LastName          string
    NickName          string
    Description       string
    UserID            string
    AvatarURL         string
    Location          string
    AccessToken       string
    AccessTokenSecret string
    RefreshToken      string
    ExpiresAt         time.Time
    IDToken           string
}

func Complete(e echo.Context, opts ...Options) (User, error)

Complete completes the authentication process and returns the user.

func (*User) Validate

func (u *User) Validate() error

Validate validates the user

Generated by gomarkdoc

About

The oauth package is a simple wrapper around the egothic package and provides a few syntactic niceties.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages