Skip to content

Commit 8a55865

Browse files
committed
docs: for signout
1 parent b1783b4 commit 8a55865

File tree

1 file changed

+28
-6
lines changed

1 file changed

+28
-6
lines changed

README.md

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,18 @@ when GOIC has new features.
146146

147147
> The example and discussion here assume `localhost` domain so adjust that accordingly for your domains.
148148
149+
### Signing out
150+
151+
For signing out you need to manually invoke `g.SignOut()` from within http context. See the [API](#signout) below.
152+
149153
---
150154
## GOIC API
151155

152156
GOIC supports full end-to-end for Authorization Code Flow, however if you want to manually interact, here's summary of API:
153157

154-
#### Check Provider
158+
#### Supports
159+
160+
Use it to check if a provider is supported.
155161

156162
```go
157163
g := goic.New("/auth/o8", false)
@@ -161,7 +167,7 @@ g.Supports("abc") // true
161167
g.Supports("xyz") // false
162168
```
163169

164-
#### Refresh Token
170+
#### RefreshToken
165171

166172
Use it to request Access token by using refresh token.
167173

@@ -173,9 +179,9 @@ tok, err := g.RefreshToken(t)
173179
// Do something with tok.AccessToken
174180
```
175181

176-
#### Auth Request
182+
#### RequestAuth
177183

178-
Manually request authentication from OpenID Provider.
184+
Manually request authentication from OpenID Provider. Must be called from within http context.
179185

180186
```go
181187
g := goic.New("/auth/o8", false)
@@ -193,7 +199,7 @@ redir := "https://localhost/auth/o8/" + p.Name
193199
err := g.RequestAuth(p, state, nonce, redir, res, req)
194200
```
195201

196-
#### Authentication
202+
#### Authenticate
197203

198204
Manually attempt to authenticate after the request comes back from OpenID Provider.
199205

@@ -211,9 +217,10 @@ redir := "https://localhost/auth/o8/" + p.Name
211217
tok, err := g.Authenticate(p, code, nonce, redir)
212218
```
213219

214-
### Userinfo
220+
#### Userinfo
215221

216222
Manually request Userinfo by using the token returned by Authentication above.
223+
217224
```go
218225
g := goic.New("/auth/o8", false)
219226
p := g.NewProvider("abc", "...").WithCredential("...", "...")
@@ -223,6 +230,21 @@ user := g.UserInfo(tok)
223230
err := user.Error
224231
```
225232

233+
#### SignOut
234+
235+
Use it to sign out the user from OpenID Provider. Must be called from within http context.
236+
Ideally, you would clear the session and logout user from your own system first and then invoke SignOut.
237+
238+
```go
239+
g := goic.New("/auth/o8", false)
240+
p := g.NewProvider("abc", "...").WithCredential("...", "...")
241+
// ...
242+
tok := &goic.Token{AccessToken: "current session token", Provider: p.Name}
243+
err := g.SignOut(tok, "http://some/preconfigured/redir/uri", res, req)
244+
// redir uri is optional
245+
err := g.SignOut(tok, "", res, req)
246+
```
247+
226248
---
227249
### Demo
228250

0 commit comments

Comments
 (0)