Skip to content

Commit

Permalink
Rename core-go/auth to core-go/authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
minhduc140583 committed Jul 13, 2024
1 parent 1246ded commit 3a55d02
Show file tree
Hide file tree
Showing 45 changed files with 71 additions and 73 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
Please make sure to initialize a Go module before installing core-go/auth:

```shell
go get -u github.com/core-go/auth
go get -u github.com/core-go/authentication
```

Import:
```go
import "github.com/core-go/auth"
import "github.com/core-go/authentication"
```

## Models
Expand Down
8 changes: 5 additions & 3 deletions azure/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"fmt"
"strings"

"github.com/core-go/auth"
auth "github.com/core-go/authentication"
"github.com/golang-jwt/jwt"
"github.com/lestrrat-go/jwx/jwa"
"github.com/lestrrat-go/jwx/jwk"
Expand Down Expand Up @@ -42,14 +42,16 @@ func NewAzureAuthenticator(
config Config,
tokenConfig auth.TokenConfig,
privileges func(ctx context.Context, id string) ([]auth.Privilege, error),
id string,
id string,
) *Authenticator {
if len(id) == 0 {
id = "id"
}
return &Authenticator{getUserByToken, userPort,privileges, generateToken, tokenConfig, config, id}
return &Authenticator{getUserByToken, userPort, privileges, generateToken, tokenConfig, config, id}
}

const expired = "Token is expired"

// Authenticate authorization jwt here doesn't contain prefix bearer
func (a Authenticator) Authenticate(ctx context.Context, authorization string) (*auth.UserAccount, bool, error) {
if len(authorization) == 0 {
Expand Down
2 changes: 1 addition & 1 deletion azure/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"strings"
"time"

"github.com/core-go/auth"
auth "github.com/core-go/authentication"
)

const internalServerError = "Internal Server Error"
Expand Down
2 changes: 1 addition & 1 deletion azure/sql/user_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"database/sql"
"fmt"
"github.com/core-go/auth/azure"
"github.com/core-go/authentication/azure"
"reflect"
"strconv"
"strings"
Expand Down
2 changes: 1 addition & 1 deletion cassandra/user_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"
"time"

a "github.com/core-go/auth"
a "github.com/core-go/authentication"
"github.com/gocql/gocql"
)

Expand Down
2 changes: 1 addition & 1 deletion dynamodb/user_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/aws/aws-sdk-go/service/dynamodb"
"github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute"
"github.com/aws/aws-sdk-go/service/dynamodb/expression"
"github.com/core-go/auth"
auth "github.com/core-go/authentication"
"reflect"
"strconv"
"strings"
Expand Down
2 changes: 1 addition & 1 deletion echo/authencation_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"encoding/json"
"errors"
a "github.com/core-go/auth"
a "github.com/core-go/authentication"
"github.com/labstack/echo/v4"
"net"
"net/http"
Expand Down
2 changes: 1 addition & 1 deletion echo/privileges_by_entity_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package echo

import (
"context"
a "github.com/core-go/auth"
a "github.com/core-go/authentication"
"github.com/labstack/echo/v4"
"net/http"
"strings"
Expand Down
2 changes: 1 addition & 1 deletion echo/privileges_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package echo

import (
"context"
a "github.com/core-go/auth"
a "github.com/core-go/authentication"
"github.com/labstack/echo/v4"
"net/http"
)
Expand Down
2 changes: 1 addition & 1 deletion echo_v3/authencation_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"encoding/json"
"errors"
a "github.com/core-go/auth"
a "github.com/core-go/authentication"
"github.com/labstack/echo"
"net"
"net/http"
Expand Down
2 changes: 1 addition & 1 deletion echo_v3/privileges_by_entity_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package echo

import (
"context"
a "github.com/core-go/auth"
a "github.com/core-go/authentication"
"github.com/labstack/echo"
"net/http"
"strings"
Expand Down
2 changes: 1 addition & 1 deletion echo_v3/privileges_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package echo

import (
"context"
a "github.com/core-go/auth"
a "github.com/core-go/authentication"
"github.com/labstack/echo"
"net/http"
)
Expand Down
3 changes: 1 addition & 2 deletions elasticsearch/user_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import (
"context"
"encoding/json"
"errors"
"github.com/core-go/auth"
"github.com/elastic/go-elasticsearch/v7"
auth "github.com/core-go/authentication"
"github.com/elastic/go-elasticsearch/v7/esapi"
"github.com/elastic/go-elasticsearch/v7/esutil"
"reflect"
Expand Down
2 changes: 1 addition & 1 deletion firestore/user_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"context"
"errors"
"fmt"
a "github.com/core-go/auth"
a "github.com/core-go/authentication"
"google.golang.org/api/iterator"
"strconv"
"time"
Expand Down
2 changes: 1 addition & 1 deletion gin/authencation_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"encoding/json"
"errors"
a "github.com/core-go/auth"
a "github.com/core-go/authentication"
"github.com/gin-gonic/gin"
"net"
"net/http"
Expand Down
2 changes: 1 addition & 1 deletion gin/privileges_by_entity_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package gin

import (
"context"
a "github.com/core-go/auth"
a "github.com/core-go/authentication"
"github.com/gin-gonic/gin"
"net/http"
"strings"
Expand Down
2 changes: 1 addition & 1 deletion gin/privileges_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package gin

import (
"context"
a "github.com/core-go/auth"
a "github.com/core-go/authentication"
"github.com/gin-gonic/gin"
"net/http"
)
Expand Down
2 changes: 1 addition & 1 deletion handler/authencation_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"strings"
"time"

a "github.com/core-go/auth"
a "github.com/core-go/authentication"
)

const expired = "Token is expired"
Expand Down
2 changes: 1 addition & 1 deletion handler/privileges_by_entity_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"net/http"
"strings"

. "github.com/core-go/auth"
. "github.com/core-go/authentication"
)

type PrivilegesByEntityHandler struct {
Expand Down
2 changes: 1 addition & 1 deletion handler/privileges_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"net/http"

. "github.com/core-go/auth"
. "github.com/core-go/authentication"
)

type PrivilegesHandler struct {
Expand Down
3 changes: 1 addition & 2 deletions ldap/ldap_authenticator.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import (
"strings"
"time"

"github.com/core-go/auth"
"github.com/go-ldap/ldap/v3"
auth "github.com/core-go/authentication"
)

type LDAPAuthenticator struct {
Expand Down
2 changes: 1 addition & 1 deletion mail/auth_mail_config.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package mail

import (
"github.com/core-go/auth"
auth "github.com/core-go/authentication"
"github.com/core-go/mail"
)

Expand Down
4 changes: 2 additions & 2 deletions mock/mock_ldap_authenticator.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ package mock

import (
"context"
"github.com/core-go/auth"
l "github.com/core-go/auth/ldap"
l "github.com/core-go/authentication/ldap"
"strings"
)

Expand All @@ -17,6 +16,7 @@ type MockLDAPAuthenticator struct {
type IAuthenticator interface {
Authenticate(ctx context.Context, info auth.AuthInfo) (auth.AuthResult, error)
}

func NewDAPAuthenticatorByConfig(conf l.LDAPConfig, status auth.Status) (IAuthenticator, error) {
s := conf.Users
if len(s) > 0 {
Expand Down
2 changes: 1 addition & 1 deletion mongo/user_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package mongo
import (
"context"
"fmt"
a "github.com/core-go/auth"
a "github.com/core-go/authentication"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo"
Expand Down
2 changes: 1 addition & 1 deletion oauth2/cassandra/configuration_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package cassandra
import (
"context"
"fmt"
"github.com/core-go/auth/oauth2"
"github.com/core-go/authentication/oauth2"
"github.com/gocql/gocql"
"reflect"
)
Expand Down
11 changes: 5 additions & 6 deletions oauth2/cassandra/user_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import (
"strings"
"time"

"github.com/core-go/auth"
"github.com/core-go/auth/oauth2"
"github.com/core-go/authentication/oauth2"
"github.com/gocql/gocql"
)

Expand All @@ -18,10 +17,10 @@ type UserRepository struct {
ActivatedStatus string
Services []string

Status *auth.UserStatusConfig
GenderMapper oauth2.OAuth2GenderMapper
Schema *oauth2.OAuth2SchemaConfig
BuildParam func(i int) string
Status *auth.UserStatusConfig
GenderMapper oauth2.OAuth2GenderMapper
Schema *oauth2.OAuth2SchemaConfig
BuildParam func(i int) string
}

func NewUserRepositoryByConfig(session *gocql.Session, tableName, prefix string, activatedStatus string, services []string, c oauth2.OAuth2SchemaConfig, status *auth.UserStatusConfig, options ...oauth2.OAuth2GenderMapper) *UserRepository {
Expand Down
2 changes: 1 addition & 1 deletion oauth2/dynamodb/configuration_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/aws/aws-sdk-go/service/dynamodb"
"github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute"
"github.com/aws/aws-sdk-go/service/dynamodb/expression"
"github.com/core-go/auth/oauth2"
"github.com/core-go/authentication/oauth2"
)

type ConfigurationRepository struct {
Expand Down
13 changes: 6 additions & 7 deletions oauth2/dynamodb/user_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ import (
"github.com/aws/aws-sdk-go/service/dynamodb"
"github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute"
"github.com/aws/aws-sdk-go/service/dynamodb/expression"
"github.com/core-go/auth"
dyn "github.com/core-go/dynamodb"
"strings"
"time"

"github.com/core-go/auth/oauth2"
"github.com/core-go/authentication/oauth2"
)

type UserRepository struct {
Expand All @@ -21,9 +20,9 @@ type UserRepository struct {
ActivatedStatus string
Services []string

Status *auth.UserStatusConfig
GenderMapper oauth2.OAuth2GenderMapper
Schema *oauth2.OAuth2SchemaConfig
Status *auth.UserStatusConfig
GenderMapper oauth2.OAuth2GenderMapper
Schema *oauth2.OAuth2SchemaConfig
}

func NewUserRepositoryByConfig(db *dynamodb.DynamoDB, userTableName, prefix string, activatedStatus string, services []string, c oauth2.OAuth2SchemaConfig, status *auth.UserStatusConfig, options ...oauth2.OAuth2GenderMapper) *UserRepository {
Expand Down Expand Up @@ -164,8 +163,8 @@ func (r *UserRepository) Update(ctx context.Context, id, email, account string)
user[r.Schema.UpdatedBy] = id
}

result, err:= dyn.PatchOne(ctx,r.DB,r.UserTableName,[]string{"id"},user)
return result > 0 , err
result, err := dyn.PatchOne(ctx, r.DB, r.UserTableName, []string{"id"}, user)
return result > 0, err

}

Expand Down
3 changes: 1 addition & 2 deletions oauth2/echo/oauth2_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ package echo
import (
"context"
"encoding/json"
"github.com/labstack/echo/v4"
"io/ioutil"
"net"
"net/http"
"strings"

"github.com/core-go/auth/oauth2"
"github.com/core-go/authentication/oauth2"
)

type OAuth2Handler struct {
Expand Down
2 changes: 1 addition & 1 deletion oauth2/echo_v3/oauth2_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"net/http"
"strings"

"github.com/core-go/auth/oauth2"
"github.com/core-go/authentication/oauth2"
)

type OAuth2Handler struct {
Expand Down
2 changes: 1 addition & 1 deletion oauth2/firestore/configuration_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"google.golang.org/api/iterator"
"strings"

"github.com/core-go/auth/oauth2"
"github.com/core-go/authentication/oauth2"
)

type ConfigurationRepository struct {
Expand Down
3 changes: 1 addition & 2 deletions oauth2/firestore/user_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import (
"cloud.google.com/go/firestore"
"context"
"fmt"
"github.com/core-go/auth"
"github.com/core-go/auth/oauth2"
"github.com/core-go/authentication/oauth2"
"strings"
)

Expand Down
2 changes: 1 addition & 1 deletion oauth2/gin/oauth2_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"net/http"
"strings"

"github.com/core-go/auth/oauth2"
"github.com/core-go/authentication/oauth2"
)

type OAuth2Handler struct {
Expand Down
2 changes: 1 addition & 1 deletion oauth2/mongo/configuration_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package mongo
import (
"context"
"fmt"
"github.com/core-go/auth/oauth2"
"github.com/core-go/authentication/oauth2"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
"strings"
Expand Down
Loading

0 comments on commit 3a55d02

Please sign in to comment.