Skip to content

Commit 545c012

Browse files
committed
feat: add helper funcs to check abilities and create auth header
1 parent 1fc483b commit 545c012

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

provider.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,22 @@ func (p *Provider) getWellKnown() (*WellKnown, error) {
119119

120120
return p.wellKnown, nil
121121
}
122+
123+
// CanRevoke checks if token can be revoked for this Provider
124+
func (p *Provider) CanRevoke() bool {
125+
return p.wellKnown.RevokeURI != ""
126+
}
127+
128+
// CanSignOut checks if token can be signed out for this Provider
129+
func (p *Provider) CanSignOut() bool {
130+
return p.wellKnown.SignOutURI != ""
131+
}
132+
133+
// AuthBasicHeader gives a string ready to use as Authorization header
134+
// The returned value contains "Basic " prefix already
135+
func (p *Provider) AuthBasicHeader() string {
136+
id := url.PathEscape(url.QueryEscape(p.clientID))
137+
pass := url.PathEscape(url.QueryEscape(p.clientSecret))
138+
139+
return "Basic " + base64.StdEncoding.EncodeToString([]byte(id+":"+pass))
140+
}

0 commit comments

Comments
 (0)