Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare Release #81

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
6ebff34
Update to use subdomain rather than region
not-ol-github Apr 25, 2022
967237c
Merge pull request #51 from onelogin/subdomain-readme-fix
not-ol-github Apr 25, 2022
f5f0e11
Include openapi-generator SDK.
gkhaburzaniya-onelogin Aug 8, 2022
762843f
Fix GIT_REPO_ID and GIT_USER_ID
gkhaburzaniya-onelogin Aug 11, 2022
53a30db
Update go mod/sum
bzvestey Aug 11, 2022
10034fc
Add makefile back
bzvestey Aug 11, 2022
5cb9835
Merge pull request #60 from onelogin/bryan-test-2
bzvestey Aug 11, 2022
59a2130
Merge pull request #58 from onelogin/openapi
gkhaburzaniya-onelogin Aug 11, 2022
76cf9e1
v3.1.0 (#66)
Jmfwolf Mar 20, 2023
9ae6eb6
changelog
Jmfwolf Mar 20, 2023
bcb54f9
changelog
Jmfwolf Mar 20, 2023
417b2ab
release changes
Jmfwolf Mar 20, 2023
3a09eca
revert
Jmfwolf Mar 20, 2023
e21e1cb
Major Overhaul: New Version of Go SDK - v0.4.0 (#67)
Jmfwolf Jun 21, 2023
0026acc
Create changelog.md
Jmfwolf Jun 21, 2023
aefa4bb
update config
Jmfwolf Jun 26, 2023
bdbffff
Merge branch 'master' into develop
Jmfwolf Jun 26, 2023
7cac89c
v4
Jmfwolf Jun 27, 2023
83751a2
Merge branch 'develop' of https://github.com/onelogin/onelogin-go-sdk…
Jmfwolf Jun 27, 2023
1500b7e
Update Makefile
Jmfwolf Jun 27, 2023
130b440
V4 (#71)
Jmfwolf Jul 12, 2023
cf20670
Fix authentication (#73)
stijndcl Jul 17, 2023
2ead1a0
updated authenticator test
Jmfwolf Jul 17, 2023
cd301ae
Update release.yml
Jmfwolf Jul 17, 2023
5a96162
Timeouts (#75)
Jmfwolf Jul 31, 2023
faabb12
Update usage_examples.md
Jmfwolf Aug 1, 2023
61e6d58
Devex 1399 (#76)
Jmfwolf Aug 7, 2023
99de7ac
Patch GetRoles() URL builder
dbourdrez Oct 9, 2023
7995bb9
fix unmarshal json issue when setting user
melchiormoulin Apr 23, 2024
84fb825
Merge pull request #78 from dbourdrez/patch-1
Subterrane Apr 24, 2024
304c27f
Merge pull request #80 from melchiormoulin/fix-jsonunmarshal
Subterrane Apr 24, 2024
f0908a8
Merge branch 'master' into develop
Subterrane Apr 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
4 changes: 0 additions & 4 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,5 @@ jobs:
run: go build ./...
- name: Vet
run: go vet ./...
- name: Test
uses: cedrickring/golang-action@master
with:
args: make test
- name: Secure
run: make secure
20 changes: 11 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@ jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Unshallow
run: git fetch --prune --unshallow
- name: Set up Go
uses: actions/setup-go@v2
- uses: actions/checkout@v3
with:
go-version: 1.14
- name: Release
uses: docker://antonyurchenko/git-release:latest
fetch-depth: 0
- run: git fetch --force --tags
- uses: actions/setup-go@v4
with:
go-version: stable
- uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DRAFT_RELEASE: "false"
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2010-2021 OneLogin, Inc.
Copyright (c) 2010-2023 OneLogin, Inc.

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
Expand Down
2 changes: 1 addition & 1 deletion config.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version: "4.0.0"
version: "4.0.1"
2 changes: 1 addition & 1 deletion docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ The `Authenticator` interface is used for handling authentication. It uses the `

The `Authenticator` is initialized with the `NewAuthenticator` function and the token is generated with the `GenerateToken` method within the `NewClient` function. If a request is unauthorized (HTTP 401), the token is refreshed using the `GenerateToken` method in the `sendRequest` function.

In summary, the API module simplifies the process of interacting with the OneLogin API by encapsulating the details of creating, sending, and processing HTTP requests. It uses environment variables for the API credentials and handles error scenarios such as unauthorized requests and token refresh. It forms the backbone of the OneLogin Go SDK, providing a streamlined interface for making API calls.
In summary, the API module simplifies the process of interacting with the OneLogin API by encapsulating the details of creating, sending, and processing HTTP requests. It uses environment variables for the API credentials and handles error scenarios such as unauthorized requests and token refresh. It forms the backbone of the OneLogin Go SDK, providing a streamlined interface for making API calls.
8 changes: 4 additions & 4 deletions docs/authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ type Authenticator struct {

## NewAuthenticator Function

The `NewAuthenticator` function is used to create a new `Authenticator` instance. It does not require any arguments and it initializes a new Authenticator with an empty `accessToken`.
The `NewAuthenticator` function is used to create a new `Authenticator` instance. It requires the subdomain as an argument, and it initializes a new Authenticator with an empty `accessToken`.

```go
func NewAuthenticator() *Authenticator {
return &Authenticator{}
func NewAuthenticator(subdomain string) *Authenticator {
return &Authenticator{subdomain: subdomain}
}
```

Expand All @@ -37,7 +37,7 @@ func (a *Authenticator) GenerateToken() error {
The `RevokeToken` function is used to revoke an existing access token. It reads the `ONELOGIN_CLIENT_ID` and `ONELOGIN_CLIENT_SECRET` environment variables, creates a revocation request, sends it, and handles the response. If the revocation is successful, a confirmation message is printed.

```go
func (a *Authenticator) RevokeToken(token, domain *string) error {
func (a *Authenticator) RevokeToken(token *string) error {
// implementation details
}
```
Expand Down
171 changes: 149 additions & 22 deletions docs/usage_examples.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,106 @@
1. **User model**

```go
package main

import (
"fmt"
"github.com/onelogin/onelogin-go-sdk/v4/pkg/onelogin/models"
"github.com/onelogin/onelogin-go-sdk/v4/pkg/onelogin"
)

func main() {
var (
email string = "[email protected]"
username string = "testuser"
)

client, err := onelogin.NewOneloginSDK()
if err != nil {
fmt.Println(err)
}

user, err := client.CreateUser(models.User{
Email: &email,
Username: &username,
})
if err != nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", user)
}
```

"github.com/onelogin/onelogin-go-sdk/internal/models"
"github.com/onelogin/onelogin-go-sdk/pkg/onelogin"
2. **Role model**

```go
package main

import (
"fmt"
"github.com/onelogin/onelogin-go-sdk/v4/pkg/onelogin/models"
"github.com/onelogin/onelogin-go-sdk/v4/pkg/onelogin"
)

func main() {
var testSSO = models.SSOOpenId{ClientID: "1234567890"}
var testConfig = models.ConfigurationOpenId{
RedirectURI: "https://example.com",
LoginURL: "https://example.com/login",
OidcApplicationType: 1,
TokenEndpointAuthMethod: 1,
AccessTokenExpirationMinutes: 60,
RefreshTokenExpirationMinutes: 60,
var (
name string = "Admin"
)

client, err := onelogin.NewOneloginSDK()
if err != nil {
fmt.Println(err)
}

role, err := client.CreateRole(models.Role{
Name: &name,
})
if err != nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", role)
}
```

3. **Event model**

```go
package main

import (
"fmt"
"github.com/onelogin/onelogin-go-sdk/v4/pkg/onelogin/models"
"github.com/onelogin/onelogin-go-sdk/v4/pkg/onelogin"
)

func main() {
client, err := onelogin.NewOneloginSDK()
if err != nil {
fmt.Println(err)
}

eventQ := models.EventQuery{}
eventList, err := client.GetEvents(&eventQ)
if err != nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", eventList)
}
```


4. **App model**

```go
package main

import (
"fmt"
"github.com/onelogin/onelogin-go-sdk/v4/pkg/onelogin/models"
"github.com/onelogin/onelogin-go-sdk/v4/pkg/onelogin"
)

func main() {
var (
connetorid int32 = 108419
name string = "Bow wow wow yippy yo yippy yay"
Expand All @@ -29,24 +111,69 @@ func main() {
if err != nil {
fmt.Println(err)
}
appQ := models.AppQuery{}
applist, err := client.GetApps(&appQ)

app, err := client.CreateApp(models.App{
ConnectorID: &connetorid,
Name: &name,
Description: &descr,
})
if err != nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", applist)
fmt.Printf("%+v\n", app)
}
```

appT, err := client.CreateApp(models.App{
ConnectorID: &connetorid,
Name: &name,
Description: &descr,
SSO: testSSO,
Configuration: testConfig,
})
5. **UserMappings model**

```go
package main

import (
"fmt"
"github.com/onelogin/onelogin-go-sdk/v4/pkg/onelogin/models"
"github.com/onelogin/onelogin-go-sdk/v4/pkg/onelogin"
)

func main() {
client, err := onelogin.NewOneloginSDK()
if err != nil {
fmt.Println(err)
}

userMappingsQuery := models.UserMappingsQuery{}
userMappings, err := client.GetUserMappings(&userMappingsQuery)
if err != nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", userMappings)
}
```

6. **AppRule model**

```go
package main

import (
"fmt"
"github.com/onelogin/onelogin-go-sdk/v4/pkg/onelogin/models"
"github.com/onelogin/onelogin-go-sdk/v4/pkg/onelogin"
)

func main() {
client, err := onelogin.NewOneloginSDK()
if err != nil {
fmt.Println(err)
}

appRuleQuery := models.AppRuleQuery{}
appRules, err := client.GetAppRules(&appRuleQuery)
if err != nil {
fmt.Println(err)
}
fmt.Printf("%+v\n", appT)
fmt.Printf("%+v\n", appRules)
}
```

```
Please note that these are basic examples and may not work as expected without proper setup and context. You may need to adjust them according to your needs.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/onelogin/onelogin-go-sdk
module github.com/onelogin/onelogin-go-sdk/v4

go 1.18
38 changes: 38 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package main

import (
"fmt"
"os"

"github.com/onelogin/onelogin-go-sdk/v4/pkg/onelogin"
"github.com/onelogin/onelogin-go-sdk/v4/pkg/onelogin/models"
)

func main() {

// Set environment variables for OneLogin API credentials
os.Setenv("ONELOGIN_CLIENT_ID", "client_id")
os.Setenv("ONELOGIN_CLIENT_SECRET", "client_secret")
os.Setenv("ONELOGIN_SUBDOMAIN", "your-api-subdomain")

// Create a user object with the specified attributes
UserTwo := models.User{Firstname: "Mikhail", Lastname: "Beaverton", Email: "[email protected]"}

// Create a user query object with the specified email
UserQueryOne := models.UserQuery{Email: &UserTwo.Email}

// Create a new OneLogin SDK client
Client, err := onelogin.NewOneloginSDK()
if err != nil {
fmt.Println(err)
}

// Create a new user with the specified attributes
Client.CreateUser(models.User{Firstname: "Jane", Lastname: "Pukalava", Email: "[email protected]"})

// Create a new user with the specified attributes
Client.CreateUser(UserTwo)

// Get a list of users that match the specified query
Client.GetUsers(&UserQueryOne)
}
Loading
Loading