summaryrefslogtreecommitdiff
path: root/vendor/github.com/superseriousbusiness/oauth2/v4/const.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2025-03-02 16:42:51 +0100
committerLibravatar GitHub <noreply@github.com>2025-03-02 16:42:51 +0100
commit8488ac928651656c6f7bebf5eaabce62c2b9fb66 (patch)
tree94357311026e5ed96862a647400375a4543dd815 /vendor/github.com/superseriousbusiness/oauth2/v4/const.go
parent[chore] go-swagger -> codeberg (#3856) (diff)
downloadgotosocial-8488ac928651656c6f7bebf5eaabce62c2b9fb66.tar.xz
[chore] migrate oauth2 -> codeberg (#3857)
Diffstat (limited to 'vendor/github.com/superseriousbusiness/oauth2/v4/const.go')
-rw-r--r--vendor/github.com/superseriousbusiness/oauth2/v4/const.go76
1 files changed, 0 insertions, 76 deletions
diff --git a/vendor/github.com/superseriousbusiness/oauth2/v4/const.go b/vendor/github.com/superseriousbusiness/oauth2/v4/const.go
deleted file mode 100644
index 193e839fd..000000000
--- a/vendor/github.com/superseriousbusiness/oauth2/v4/const.go
+++ /dev/null
@@ -1,76 +0,0 @@
-package oauth2
-
-import (
- "crypto/sha256"
- "encoding/base64"
- "strings"
-)
-
-// ResponseType the type of authorization request
-type ResponseType string
-
-// define the type of authorization request
-const (
- Code ResponseType = "code"
- Token ResponseType = "token"
-)
-
-func (rt ResponseType) String() string {
- return string(rt)
-}
-
-// GrantType authorization model
-type GrantType string
-
-// define authorization model
-const (
- AuthorizationCode GrantType = "authorization_code"
- PasswordCredentials GrantType = "password"
- ClientCredentials GrantType = "client_credentials"
- Refreshing GrantType = "refresh_token"
- Implicit GrantType = "__implicit"
-)
-
-func (gt GrantType) String() string {
- if gt == AuthorizationCode ||
- gt == PasswordCredentials ||
- gt == ClientCredentials ||
- gt == Refreshing {
- return string(gt)
- }
- return ""
-}
-
-// CodeChallengeMethod PCKE method
-type CodeChallengeMethod string
-
-const (
- // CodeChallengePlain PCKE Method
- CodeChallengePlain CodeChallengeMethod = "plain"
- // CodeChallengeS256 PCKE Method
- CodeChallengeS256 CodeChallengeMethod = "S256"
-)
-
-func (ccm CodeChallengeMethod) String() string {
- if ccm == CodeChallengePlain ||
- ccm == CodeChallengeS256 {
- return string(ccm)
- }
- return ""
-}
-
-// Validate code challenge
-func (ccm CodeChallengeMethod) Validate(cc, ver string) bool {
- switch ccm {
- case CodeChallengePlain:
- return cc == ver
- case CodeChallengeS256:
- s256 := sha256.Sum256([]byte(ver))
- // trim padding
- a := strings.TrimRight(base64.URLEncoding.EncodeToString(s256[:]), "=")
- b := strings.TrimRight(cc, "=")
- return a == b
- default:
- return false
- }
-}