auth

package module
v0.0.0-...-84de065 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 10, 2020 License: MIT Imports: 10 Imported by: 0

README

gin-oidc

golan oidc middleware - an OIDC client for a relying party web server

example usage

  package main

import (
	"context"
	"net/http"
	"golang.org/x/oauth2"
	auth "gitlab.beopenit.com/mody/oidc-middleware"
)

var mux *http.ServeMux = http.NewServeMux()

......

func main() {

	.....

	ctx := context.Background()
	provider, err := oidc.NewProvider(ctx, "http://localhost:9080/auth/realms/jhipster")
	if err != nil {
		panic(err)
	}
	config := oauth2.Config{
		ClientID:     "web_app",
		ClientSecret: "web_app",
		Endpoint:     provider.Endpoint(),
		RedirectURL:  "http://localhost:8080/token",
		Scopes:       []string{oidc.ScopeOpenID, "profile", "email"},
	}
	auth.Init(config, "http://localhost:9080/auth/realms/jhipster", mux)

	.....

}

  

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthMiddleware

func AuthMiddleware(req *restful.Request, resp *restful.Response, chain *restful.FilterChain)

func Init

func Init(c Config, container *restful.Container)

Types

type Claims

type Claims struct {
	Sub                string
	Email_verified     bool
	Roles              []string
	Name               string
	Preferred_username string
	Given_name         string
	Family_name        string
	Email              string
}

type Config

type Config struct {
	ClientID     string
	ClientSecret string
	ServeurURL   string
	HostUrl      string
	Scopes       []string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL