GithubHelp home page GithubHelp logo

shgopher / medu-sdk-go Goto Github PK

View Code? Open in Web Editor NEW

This project forked from marmotedu/medu-sdk-go

0.0 1.0 0.0 32 KB

marmotedu 另一种sdk实现思路(仿照:tencentcloud-sdk-go、aws-sdk-go、ucloud-sdk-go、jdcloud-sdk-go等)

Go 100.00%

medu-sdk-go's Introduction

medu-sdk-go介绍

marmotedu另一种sdk实现思路(仿照:tencentcloud-sdk-go、aws-sdk-go、ucloud-sdk-go、jdcloud-sdk-go等)。 medu-sdk-go提供iam-authz-server组件/v1/authz接口的go版SDK。

使用方法为:

package main

import (
	"fmt"

	"github.com/marmotedu/medu-sdk-go/sdk"
	"github.com/marmotedu/medu-sdk-go/services/iam"
	"github.com/ory/ladon"
)

func main() {
	client, _ := iam.NewClientWithSecret("XhbY3aCrfjdYcP1OFJRu9xcno8JzSbUIvGE2", "bfJRvlFwsoW9L30DlG87BBW0arJamSeK")

	req := iam.NewAuthzRequest()
	req.Resource = sdk.String("resources:articles:ladon-introduction")
	req.Action = sdk.String("delete")
	req.Subject = sdk.String("users:peter")
	ctx := ladon.Context(map[string]interface{}{"remoteIP": "192.168.0.5"})
	req.Context = &ctx

	resp, err := client.Authz(req)
	if err != nil {
		fmt.Println("err1", err)
		return
	}
	fmt.Printf("get response body: `%s`\n", resp.String())
	fmt.Printf("allowed: %v\n", resp.Allowed)
}

输出如下:

get response body: `{"code":0,"allowed":true}`
allowed: true

其它参考

参考项目

medu-sdk-go's People

Contributors

colin404 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.