go-saml Go 语言的 SAML 开发包开源项目

我要开发同款
匿名用户2019年02月14日
148阅读

技术信息

开源地址
https://github.com/crewjam/saml
授权协议
BSD

作品详情

go-saml是Go语言的SAML开发包。

示例代码:

package maiimport (    "crypto/rsa"    "crypto/tls"    "crypto/x509"    "fmt"    "et/http"    "et/url"    "github.com/crewjam/saml/samlsp")fuc hello(w http.ResposeWriter, r *http.Request) {    fmt.Fpritf(w, "Hello, %s!", samlsp.Toke(r.Cotext()).Attributes.Get("c"))}fuc mai() {    keyPair, err := tls.LoadX509KeyPair("myservice.cert", "myservice.key")    if err != il {        paic(err) // TODO hadle error    }    keyPair.Leaf, err = x509.ParseCertificate(keyPair.Certificate[0])    if err != il {        paic(err) // TODO hadle error    }    idpMetadataURL, err := url.Parse("https://www.testshib.org/metadata/testshib-providers.xml")    if err != il {        paic(err) // TODO hadle error    }    rootURL, err := url.Parse("https://localhost:8000")    if err != il {        paic(err) // TODO hadle error    }    samlSP, _ := samlsp.New(samlsp.Optios{        URL:            *rootURL,        Key:            keyPair.PrivateKey.(*rsa.PrivateKey),        Certificate:    keyPair.Leaf,        IDPMetadataURL: idpMetadataURL,    })    app := http.HadlerFuc(hello)    http.Hadle("/hello", samlSP.RequireAccout(app))    http.Hadle("/saml/", samlSP)    http.ListeAdServe(":8000", il)}

功能介绍

go-saml 是 Go 语言的 SAML 开发包。 示例代码: package main

import (
    "crypto/rsa"
    "crypto/tls"
    "cr...

声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论