Skip to content

Commit

Permalink
Support for member session authZ for RBAC (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
logan-stytch authored Dec 8, 2023
1 parent 2736209 commit 6d2bb65
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
22 changes: 22 additions & 0 deletions lib/stytch/method_options.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module Stytch
module MethodOptions
class Authorization
# A secret token for a given Stytch Session.
attr_accessor :session_token
# The JSON Web Token (JWT) for a given Stytch Session.
attr_accessor :session_jwt

def initialize(session_token: nil, session_jwt: nil)
@session_token = session_token
@session_jwt = session_jwt
end

def to_headers
headers = {}
headers['X-Stytch-Member-Session'] = session_token if session_token
headers['X-Stytch-Member-SessionJWT'] = session_jwt if session_jwt
headers
end
end
end
end
20 changes: 12 additions & 8 deletions lib/stytch/request_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,33 @@

module Stytch
module RequestHelper
def get_request(path)
def get_request(path, headers)
@connection.get(
path
path,
headers
).body
end

def post_request(path, payload)
def post_request(path, payload, headers)
@connection.post(
path,
payload
payload,
headers
).body
end

def put_request(path, payload)
def put_request(path, payload, headers)
@connection.put(
path,
payload
payload,
headers
).body
end

def delete_request(path)
def delete_request(path, headers)
@connection.delete(
path
path,
headers
).body
end

Expand Down

0 comments on commit 6d2bb65

Please sign in to comment.