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

Feature: Change Authorize to use UserID instead of Token #2065

Open
Musilah opened this issue Jan 25, 2024 · 1 comment
Open

Feature: Change Authorize to use UserID instead of Token #2065

Musilah opened this issue Jan 25, 2024 · 1 comment
Assignees

Comments

@Musilah
Copy link
Contributor

Musilah commented Jan 25, 2024

Is your feature request related to a problem? Please describe.

We need to make this user ID, rather than the token.
Originally posted by @dborovcanin in absmach/magistrala-old#272 (comment)

Describe the feature you are requesting, as well as the possible use case(s) for it.

For this function we are required to use the UserID instead of token to authorize the subject over the object.

func (svc service) Authorize(ctx context.Context, pr PolicyReq) error {
	if err := svc.PolicyValidation(pr); err != nil {
		return errors.Wrap(svcerr.ErrMalformedEntity, err)
	}
	if pr.SubjectKind == TokenKind {
		key, err := svc.Identify(ctx, pr.Subject)
		if err != nil {
			return errors.Wrap(svcerr.ErrAuthentication, err)
		}
		if key.Subject == "" {
			if pr.ObjectType == GroupType || pr.ObjectType == ThingType || pr.ObjectType == DomainType {
				return errors.ErrDomainAuthorization
			}
			return svcerr.ErrAuthentication
		}
		pr.Subject = key.Subject
		pr.Domain = key.Domain
	}
	if err := svc.checkPolicy(ctx, pr); err != nil {
		return err
	}
	return nil
}

Indicate the importance of this feature to you.

Should-have

Anything else?

No response

@arvindh123
Copy link
Contributor

@dborovcanin Please provide your approach guidance for this task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Backlog
Development

No branches or pull requests

4 participants