Makis Maropoulos 2016-06-22 12:45:57 +03:00
parent e6bc24b648
commit 56f78567a2
5 changed files with 24 additions and 26 deletions

View File

@ -112,7 +112,7 @@ func main() {
func myAuthMiddleware(c *iris.Context) {
s := c.Session()
if s.GetString("username") == "myusername" && s.GetString("passowrd") == "mypassword" {
if s.GetString("username") == "myusername" && s.GetString("password") == "mypassword" {
c.Next()
} else {
c.EmitError(iris.StatusUnauthorized)

View File

@ -11,3 +11,4 @@ Third party packages
- [formam as form binder](https://github.com/monoculum/formam)
- [i18n for internalization](https://github.com/Unknwon/i18n)
- [color for banner](https://github.com/fatih/color)
- [gothic](https://github.com/iris-contrib/gothic)/[goth for Multi-Provider OAuth, OAuth2](https://github.com/markbates/goth)

View File

@ -11,16 +11,6 @@ import (
"encoding/json"
"encoding/xml"
"fmt"
"github.com/iris-contrib/formBinder"
"github.com/iris-contrib/goth"
"github.com/iris-contrib/goth/gothic"
"github.com/kataras/iris/config"
"github.com/kataras/iris/context"
"github.com/kataras/iris/errors"
"github.com/kataras/iris/sessions/store"
"github.com/kataras/iris/utils"
"github.com/klauspost/compress/gzip"
"github.com/valyala/fasthttp"
"html/template"
"io"
"net"
@ -32,6 +22,17 @@ import (
"strings"
"sync"
"time"
"github.com/iris-contrib/formBinder"
"github.com/iris-contrib/gothic"
"github.com/kataras/iris/config"
"github.com/kataras/iris/context"
"github.com/kataras/iris/errors"
"github.com/kataras/iris/sessions/store"
"github.com/kataras/iris/utils"
"github.com/klauspost/compress/gzip"
"github.com/markbates/goth"
"github.com/valyala/fasthttp"
)
const (
@ -789,9 +790,9 @@ func (ctx *Context) Log(format string, a ...interface{}) {
// process and fetches all of the basic information about the user from the provider.
//
// It expects to be able to get the name of the provider from the named parameters
// as either "provider" or ":provider".
// as either "provider" or url query parameter ":provider".
//
// See https://github.com/iris-contrib/goth/examples/main.go to see this in action.
// See https://github.com/iris-contrib/gothic/blob/master/example/main.go to see this in action.
func (ctx *Context) CompleteUserAuth() (goth.User, error) {
return gothic.CompleteUserAuth(ctx)
}

View File

@ -2,12 +2,13 @@ package context
import (
"bufio"
"github.com/iris-contrib/goth"
"github.com/kataras/iris/sessions/store"
"github.com/valyala/fasthttp"
"html/template"
"io"
"time"
"github.com/kataras/iris/sessions/store"
"github.com/markbates/goth"
"github.com/valyala/fasthttp"
)
type (
@ -135,13 +136,8 @@ type (
// IContextAuth handles the authentication/authorization
IContextAuth interface {
// CompleteUserAuth does what it says on the tin. It completes the authentication
// process and fetches all of the basic information about the user from the provider.
//
// It expects to be able to get the name of the provider from the named parameters
// as either "provider" or ":provider".
//
// See https://github.com/iris-contrib/goth/examples/main.go to see this in action.
// CompleteUserAuth
// See https://github.com/iris-contrib/gothic/blob/master/example/main.go to see this in action.
CompleteUserAuth() (goth.User, error)
}
)

View File

@ -59,7 +59,7 @@ import (
"strings"
"time"
"github.com/iris-contrib/goth/gothic"
"github.com/iris-contrib/gothic"
"github.com/kataras/iris/config"
"github.com/kataras/iris/context"
"github.com/kataras/iris/errors"
@ -570,12 +570,12 @@ func (s *Framework) TemplateString(templateFile string, pageContext interface{},
// BeginAuthHandler is a convienence handler for starting the authentication process.
// It expects to be able to get the name of the provider from the named parameters
// as either "provider" or ":provider".
// as either "provider" or url query parameter ":provider".
//
// BeginAuthHandler will redirect the user to the appropriate authentication end-point
// for the requested provider.
//
// See https://github.com/iris-contrib/goth/examples/main.go to see this in action.
// See https://github.com/iris-contrib/gothic/blob/master/example/main.go to see this in action.
func BeginAuthHandler(ctx *Context) {
gothic.BeginAuthHandler(ctx)
}